(************************************************************************
*    This File is Part of the AHM Triton Tools                          *
*    for Borland Delphi and C++ Builder.                                *
*************************************************************************
* Copyright © 1995-1999 Alexander H. Mehlhorn (AHM) and Tritontools.com *
* All Rights reserved.                                                  *
*                                                                       *
*    For more Information contact us at                                 *
*    E-Mail : support@tritontools.com                                   *
*    URL : http://www.tritontools.com                                   *
*                                                                       *
*    AHM is copyright by Alexander H. Mehlhorn                          *
*    All Parts of this Collection were developed,                       *
*    designed and implemented by AHM                                    *
*                                                                       *
*    Under no Circumstances may you distribute this file                *
*    in this or any other format. This File is supplied                 *
*    as Evaluation of Source only. No Delphi Components may be developed*
*    using extracts or subsets of this code without expressed permission*
*    by AHM.                                                            *
*                                                                       *
*************************************************************************)
unit AHMTMsgDlgHolder;
{$R AHMTDLGEx.res}
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls,StdCtrls,AHMSystemClass;
type
  TAHMMsgDlgHolder = class;
  TAHMMsgDlgs = class;
  TAHMMsgDlg = class;
  TAHMMsgDlgEvent = procedure (Sender:TObject;Var Message,EditText : String) of object;
  TAHMDlgEditClass = Class(TPersistent)
  private
    FPassWordChar: Char;
    FMaxLength: Integer;
    FText: String;
    FCaption: String;
    FColor: TColor;
    FCharCase: TEditCharCase;
    FFOntColor: TColor;
    procedure SetCaption(const Value: String);
    procedure SetCharCase(const Value: TEditCharCase);
    procedure SetColor(const Value: TColor);
    procedure SetMaxLength(const Value: Integer);
    procedure SetPasswordChar(const Value: Char);
    procedure SetText(const Value: String);
    procedure SetFontColor(const Value: TColor);
    { Private declarations }
  public
    Constructor Create; virtual;
  published
    Property FontColor : TColor read FFOntColor write SetFontColor default clWindowText;
    Property Color : TColor read FColor write SetColor default clWindow;
    Property Caption : String read FCaption write SetCaption;
    Property PasswordChar : Char read FPassWordChar write SetPasswordChar;
    Property Text : String read FText write SetText;
    Property MaxLength : Integer read FMaxLength write SetMaxLength default 0;
    Property CharCase : TEditCharCase read FCharCase write SetCharCase default ecNormal;
  end;
  TAHMBaseDlgButtonClass = Class(TPersistent)
  private
    FNumGlyphs: Integer;
    FGlyph: TBitmap;
    FCaption: String;
    FVisible: Boolean;
    FEnabled: Boolean;
    procedure SetCaption(const Value: String);
    procedure SetEnabled(const Value: Boolean);
    procedure SetVisible(const Value: Boolean);
    procedure SetGlyph(const Value: TBitmap);
    procedure SetNumGlyphs(const Value: Integer);
    { Private declarations }
  public
    Constructor Create;
    Destructor Destroy; override;
  published
    Property Glyph : TBitmap read FGlyph write SetGlyph;
    Property NumGlyphs : Integer read FNumGlyphs write SetNumGlyphs default 1;
    Property Caption : String read FCaption write SetCaption;
    Property Visible : Boolean read FVisible write SetVisible default True;
    Property Enabled : Boolean read FEnabled write SetEnabled default True;
  end;
  TAHMMsgDlgButtonClass = Class(TAHMBaseDlgButtonClass)
  private
    FModalResult: TModalResult;
    FDefault: Boolean;
    FDialog : TAHMMsgDlg;
    procedure OnChangeDefault(Sender : TObject);
    procedure SetDefault(const Value: Boolean);
  protected
  public
    Constructor Create(ADialog : TAHMMsgDlg); virtual;
  published
    Property ModalResult : TModalResult read FModalResult write FModalResult default mrNone;
    Property Default : Boolean read FDefault write SetDefault;
  end;
  TAHMDlgHelpButtonClass = Class(TAHMBaseDlgButtonClass)
  private
    FHelpContext: LongInt;
  public
    Constructor Create;
  published
    property HelpContext : LongInt read FHelpContext write FHelpContext default 0;
  end;
  TAHMMsgDlg = class(TCollectionItem)
  private
    FAHMMsgDlgHolder : TAHMMsgDlgHolder;
    FMessage: String;
    FCaption: String;
    FFont : TFont;
    FBeepType : TAHMBeeptype;
    FMsgButton1: TAHMMsgDlgButtonClass;
    FMsgButton2: TAHMMsgDlgButtonClass;
    FMsgButton3: TAHMMsgDlgButtonClass;
    FHelpButton: TAHMDlgHelpButtonClass;
    FButtonWidth: LongInt;
    FFormWidth: Integer;
    FOnBtn1Click: TNotifyEvent;
    FOnBtn3Click: TNotifyEvent;
    FOnBtn2Click: TNotifyEvent;
    FOnHelpClick: TNotifyEvent;
    FMsgType: TMsgDlgType;
    FIcon: TIcon;
    FOnmrAll: TNotifyevent;
    FOnmrCancel: TNotifyevent;
    FOnmrYes: TNotifyevent;
    FOnmrIgnore: TNotifyevent;
    FOnmrNone: TNotifyevent;
    FOnmrYesToAll: TNotifyevent;
    FOnmrOk: TNotifyevent;
    FOnmrNoToAll: TNotifyevent;
    FOnmrNo: TNotifyevent;
    FOnmrRetry: TNotifyevent;
    FOnmrAbort: TNotifyevent;
    FBeforePopup: TAHMMsgDlgEvent;
    FEditBox: TAHMDlgEditClass;
    FReturn: String;
    Procedure SetFont(Const Value : TFont);
    Procedure SetMessage(Const Value : String);
    { Private declarations }
    procedure SetButtonWidth(const Value: LongInt);
    procedure SetFormWidth(const Value: Integer);
    Procedure Button1Click(Sender : TObject);
    Procedure Button2Click(Sender : TObject);
    Procedure Button3Click(Sender : TObject);
    Procedure HelpButtonClick(Sender : TObject);
    procedure SetMessageType(const Value: TMsgDlgType);
    procedure SetIcon(const Value: TIcon);
    procedure ProcessMessages(Value : TModalResult);
  protected
    function GetDisplayName: string; override;
  public
    constructor Create(Collection: TCollection); override;
    procedure Assign(Source: TPersistent); override;
    property Owner : TAHMMsgDlgHolder read FAHMMsgDlgHolder;
    property DisplayName : String read GetDisplayName;
    Destructor Destroy; override;
    { Public declarations }
    Function Execute : String;
    Property Return : String read FReturn;
  published
    Property Buttonwidth : LongInt read FButtonWidth write SetButtonWidth default 80;
    Property Sound : TAHMBeeptype read FBeepType write FBeepType default bNone;
    Property Editbox : TAHMDlgEditClass read FEditBox write FEditBox;
    Property MsgButton1 : TAHMMsgDlgButtonClass read FMsgButton1 write FMsgButton1;
    Property MsgButton2 : TAHMMsgDlgButtonClass read FMsgButton2 write FMsgButton2;
    Property MsgButton3 : TAHMMsgDlgButtonClass read FMsgButton3 write FMsgButton3;
    Property MsgType : TMsgDlgType read FMsgType write SetMessageType default mtInformation;
    Property HelpButton : TAHMDlgHelpButtonClass read FHelpButton write FHelpButton;
    Property FormWidth : Integer read FFormWidth write SetFormWidth default 320;
    Property Message : String read FMessage write SetMessage;
    Property CustomIcon : TIcon read FIcon write SetIcon;
    Property Caption : String read FCaption write FCaption;
    Property Font : TFont read FFont write SetFont;
    property BeforePopup : TAHMMsgDlgEvent read FBeforePopup write FBeforePopup;
    Property OnBtn1Click : TNotifyEvent read FOnBtn1Click write FOnBtn1Click;
    Property OnBtn2Click : TNotifyEvent read FOnBtn2Click write FOnBtn2Click;
    Property OnBtn3Click : TNotifyEvent read FOnBtn3Click write FOnBtn3Click;
    Property OnHelpClick : TNotifyEvent read FOnHelpClick write FOnHelpClick;
    Property OnmrNone : TNotifyevent read FOnmrNone write FOnmrNone;
    Property OnmrAbort : TNotifyevent read FOnmrAbort write FOnmrAbort;
    Property OnmrAll : TNotifyevent read FOnmrAll write FOnmrAll;
    Property OnmrCancel : TNotifyevent read FOnmrCancel write FOnmrCancel;
    Property OnmrIgnore : TNotifyevent read FOnmrIgnore write FOnmrIgnore;
    Property OnmrNo : TNotifyevent read FOnmrNo write FOnmrNo;
    Property OnmrOk : TNotifyevent read FOnmrOk write FOnmrOk;
    Property OnmrRetry : TNotifyevent read FOnmrRetry write FOnmrRetry;
    Property OnmrYes : TNotifyevent read FOnmrYes write FOnmrYes;
    Property OnmrNoToAll : TNotifyevent read FOnmrNoToAll write FOnmrNoToAll;
    Property OnmrYesToAll : TNotifyevent read FOnmrYesToAll write FOnmrYesToAll;
  end;
  TAHMMsgDlgs = class(TCollection)
  private
    FAHMMsgDlgHolder : TAHMMsgDlgHolder;
    function GetAHMMsgDlg(Index: Integer): TAHMMsgDlg;
    procedure SetAHMMsgDlg(Index: Integer; Value: TAHMMsgDlg);
  protected
    function GetOwner : TPersistent; override;
  public
    constructor Create(AOwner: TAHMMsgDlgHolder);
    function Add : TAHMMsgDlg;
   Function Delete(Index :Integer) :Boolean;
    property Owner : TAHMMsgDlgHolder read FAHMMsgDlgHolder;
    property Items[Index: Integer]: TAHMMsgDlg
             read GetAHMMsgDlg write SetAHMMsgDlg; default;
  end;
  TAHMMsgDlgHolder = class(TAHMSystemsComponent)
  private
    FAHMMsgDlgs : TAHMMsgDlgs;
    FBeforePopup: TAHMMsgDlgEvent;
    procedure SetAHMMsgDlgs(Value: TAHMMsgDlgs);
  protected
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    Function Execute(Index : Integer) : String;
  published
    property BeforePopup : TAHMMsgDlgEvent read FBeforePopup write FBeforePopup;
    property Messages: TAHMMsgDlgs read FAHMMsgDlgs write SetAHMMsgDlgs;
  end;

implementation

{//$R AHMTMessagesEx.res}
uses Buttons;

Type TAHMMsgDlgForm = class(TForm)
     private
       MsgText : String;
       EditText : String;
       MyTxtRect : TRect;
       Edit : TEdit;
       Procedure SetupSelf;
       Procedure SelfPaint(Sender : TObject);
       Procedure OnSelfShow(Sender : TObject);
     protected
     public
     published
       FAHMMsgDlg : TAHMMsgDlg;
     end;
var
  AHMMsgForm : TAHMMsgDlgForm = nil;


procedure TAHMMsgDlgForm.SelfPaint(Sender : TObject);
Var Myrect : TRect;
begin
  Font:=FAHMMsgDlg.FFont;
  MyRect:=Clientrect;
  InflateRect(MyRect,-10,-10);
  if (FAHMMsgDlg.FIcon.Empty) and (FAHMMsgDlg.MsgType=mtCustom) then MyRect.Left:=14 else
  MyRect.Left:=MyRect.Left+47;
  MyRect.Right:=MyRect.Right-FAHMMsgDlg.FButtonwidth-18;
  SetBkMode(Canvas.Handle,Transparent);
  DrawText(Canvas.Handle,PChar(MsgText),-1,myrect,DT_LEFT or DT_WORDBREAK or DT_CALCRECT);
  if MyRect.Bottom-MyRect.Top<(3*(Self.Canvas.TextHeight('W')+10)) then
  begin
    Clientheight:=(6*(Self.Canvas.TextHeight('W')+10));
  end else
  begin
    ClientHeight:=MyRect.Bottom-MyRect.Top+(2*(Self.Canvas.TextHeight('W')+10))+30;
  end;
  DrawText(Canvas.Handle,PChar(MsgText),-1,myrect,DT_LEFT or DT_WORDBREAK);
  InFlateRect(MyRect,5,5);
  MyTxtRect:=MyRect;
  MyTxtRect.Right:=ClientWidth-FAHMMsgDlg.FButtonWidth-5;
end;

procedure TAHMMsgDlgForm.OnSelfShow(Sender: TObject);
begin
  case FAHMMsgDlg.FBeepType of
    bDefault      : MessageBeep(MB_OK);
    bAsterix      : MessageBeep(MB_ICONAsterisk);
    bExclamation  : MessageBeep(MB_ICONEXCLAMATION);
    bQuestion     : MessageBeep(MB_ICONQUESTION);
    bCriticalStop : MessageBeep(MB_ICONHAND);
  end;
end;

Procedure TAHMMsgDlgForm.SetupSelf;
begin
  BorderStyle:=bsDialog;
  Caption:=FAHMMsgDlg.FCaption;
  Position:=poScreenCenter;
  ClientWidth:=FAHMMsgDlg.FFormWidth;
  ClientHeight:=200;
  KeyPreview:=True;
  SelfPaint(Self);
  with TBitBtn.Create(self) do
  begin
    Parent:=self;
    Width:=FAHMMsgDlg.FButtonWidth;
    Height:=Self.Canvas.TextHeight('W')+10;
    Left:=Self.ClientWidth-FAHMMsgDlg.FButtonWidth-5;
    Top:=4;
    ModalResult:=FAHMMsgDlg.MsgButton1.FModalResult;
    Caption:=FAHMMsgDlg.MsgButton1.FCaption;
    Visible:=FAHMMsgDlg.MsgButton1.FVisible;
    Enabled:=FAHMMsgDlg.MsgButton1.Enabled;
    Default:=FAHMMsgDlg.MsgButton1.Default;
    Glyph:=FAHMMsgDlg.MsgButton1.FGlyph;
    NumGlyphs:=FAHMMsgDlg.MsgButton1.FNumGlyphs;
    OnClick:=FAHMMsgDlg.Button1Click;
  end;
  with TBitBtn.Create(self) do
  begin
    Parent:=self;
    Width:=FAHMMsgDlg.FButtonWidth;
    Height:=Self.Canvas.TextHeight('W')+10;
    Left:=Self.ClientWidth-FAHMMsgDlg.FButtonWidth-5;
    Top:=6+(Self.Canvas.TextHeight('W')+10);
    ModalResult:=FAHMMsgDlg.MsgButton2.FModalResult;
    Caption:=FAHMMsgDlg.MsgButton2.FCaption;
    Visible:=FAHMMsgDlg.MsgButton2.FVisible;
    Enabled:=FAHMMsgDlg.MsgButton2.Enabled;
    Default:=FAHMMsgDlg.MsgButton2.Default;
    Glyph:=FAHMMsgDlg.MsgButton2.FGlyph;
    NumGlyphs:=FAHMMsgDlg.MsgButton2.FNumGlyphs;
    OnClick:=FAHMMsgDlg.Button2Click;
  end;
  with TBitBtn.Create(self) do
  begin
    Parent:=self;
    Width:=FAHMMsgDlg.FButtonWidth;
    Height:=Self.Canvas.TextHeight('W')+10;
    Left:=Self.ClientWidth-FAHMMsgDlg.FButtonWidth-5;
    Top:=8+(2*(Self.Canvas.TextHeight('W')+10));
    ModalResult:=FAHMMsgDlg.MsgButton3.FModalResult;
    Caption:=FAHMMsgDlg.MsgButton3.FCaption;
    Visible:=FAHMMsgDlg.MsgButton3.FVisible;
    Enabled:=FAHMMsgDlg.MsgButton3.Enabled;
    Default:=FAHMMsgDlg.MsgButton3.Default;
    Glyph:=FAHMMsgDlg.MsgButton3.FGlyph;
    NumGlyphs:=FAHMMsgDlg.MsgButton3.FNumGlyphs;
    OnClick:=FAHMMsgDlg.Button3Click;
  end;
  with TBitBtn.Create(self) do
  begin
    Parent:=self;
    Width:=FAHMMsgDlg.FButtonWidth;
    Height:=Self.Canvas.TextHeight('W')+10;
    Left:=Self.ClientWidth-FAHMMsgDlg.FButtonWidth-5;
    Top:=10+(3*(Self.Canvas.TextHeight('W')+10));;
    Caption:=FAHMMsgDlg.HelpButton.FCaption;
    Visible:=FAHMMsgDlg.HelpButton.FVisible;
    Enabled:=FAHMMsgDlg.HelpButton.Enabled;
    Glyph:=FAHMMsgDlg.HelpButton.FGlyph;
    NumGlyphs:=FAHMMsgDlg.HelpButton.FNumGlyphs;
    OnClick:=FAHMMsgDlg.HelpButtonClick;
  end;
  with TImage.Create(self) do
  begin
    Parent:=self;
    Transparent:=True;
    Width:=32;
    Height:=32;
    Left:=15;
    Top:=10;
    if assigned(FAHMMsgDlg.FIcon) and (not FAHMMsgDlg.FIcon.Empty) and (FAHMMsgDlg.MsgType=mtCustom) then
    begin
      Picture.Icon:=FAHMMsgDlg.FIcon;
    end else
    case FAHMMsgDlg.FMsgType of
      mtError : Picture.Bitmap.LoadFromResourceName(HInstance,'AHMDLGEXERROR');
      mtInformation : Picture.Bitmap.LoadFromResourceName(HInstance,'AHMDLGEXINFORMATION');
      mtConfirmation : Picture.Bitmap.LoadFromResourceName(HInstance,'AHMDLGEXCONFIRMATION');
      mtWarning : Picture.Bitmap.LoadFromResourceName(HInstance,'AHMDLGEXWARNING');
    else
    end;
  end;
  Edit:=TEdit.Create(Self);
  with Edit do
  begin
    Parent:=self;
    Left:=10;
    Top:=Self.ClientHeight-8-Edit.Height-MyTxtRect.Top;
    Width:=Self.ClientWidth-FAHMMsgDlg.FButtonWidth-25;
    PasswordChar:=FAHMMsgDlg.FEditBox.FPasswordChar;
    MaxLength:=FAHMMsgDlg.FEditbox.FMaxLength;
    Text:=FAHMMsgDlg.FEditbox.FText;
    with TLabel.Create(Self) do
    begin
      Parent:=Self;
      Left:=10;
      Top:=Edit.Top-Self.Canvas.TextHeight('W')-4;
      Width:=Edit.Width;
      Height:=Self.Canvas.TextHeight('W')+2;
      Caption:=FAHMMsgDlg.FEditbox.FCaption;
    end;
    Color:=FAHMMsgDlg.FEditbox.FColor;
    Font.Color:=FAHMMsgDlg.FEditbox.FFontColor;
    CharCase:=FAHMMsgDlg.FEditbox.FCharCase;
  end;
  ActiveControl:=Edit;
  with TBevel.Create(Self) do
  begin
    Parent:=Self;
    Shape:=bsFrame;
    Left:=5;
    Top:=5;
    Height:=Self.ClientHeight-4-MyTxtRect.Top;
    Width :=Self.ClientWidth-FAHMMsgDlg.FButtonWidth-15;
  end;
end;

Function TAHMMsgDlg.Execute : String;
Var MdlResult : Word;
begin
  AHMMsgForm:=TAHMMsgDlgForm.CreateNew(Application);
  AHMMsgForm.MsgText:=FMessage;
  AHMMsgForm.EditText:=FEditBox.Text;
  if assigned(FBeforePopup) then FBeforePopup(self,AHMMsgForm.MsgText,AHMMsgForm.EditText);
  if assigned(FAHMMsgDlgHolder.FBeforePopup) then FAHMMsgDlgHolder.FBeforePopup(self,AHMMsgForm.MsgText,AHMMsgForm.EditText);
  with AHMMsgForm do
  try
    FAHMMsgDlg:=self;
    SetUpSelf;
    OnPaint:=SelfPaint;
    OnShow:=OnSelfShow;
    MdlResult:=showmodal;
    FReturn:=Edit.Text;
    result:=FReturn;
  finally
    free;
  end;
  AHMMsgForm:=nil;
  ProcessMessages(MdlResult);
end;

Destructor TAHMMsgDlg.Destroy;
begin
  FEditBox.Free;
  FIcon.Free;
  FHelpButton.Free;
  FMsgButton1.Free;
  FMsgButton2.Free;
  FMsgButton3.Free;
  FFont.Free;
  inherited Destroy;
end;

Procedure TAHMMsgDlg.SetFont(Const Value : TFont);
begin
  FFont.Assign(Value);
end;

Procedure TAHMMsgDlg.SetMessage(Const Value : String);
begin
  FMessage:=Value;
end;

{ TAHMDlgButtonClass }

constructor TAHMBaseDlgButtonClass.Create;
begin
  inherited Create;
  FGlyph:=TBitmap.Create;
  FNumGlyphs:=1;
  FVisible:=True;
  FCaption:='MsgBtn';
  FEnabled:=True;
end;

destructor TAHMBaseDlgButtonClass.Destroy;
begin
  FGlyph.Free;
  inherited Destroy;
end;

procedure TAHMBaseDlgButtonClass.SetCaption(const Value: String);
begin
  FCaption := Value;
end;

procedure TAHMBaseDlgButtonClass.SetEnabled(const Value: Boolean);
begin
  FEnabled := Value;
end;

procedure TAHMBaseDlgButtonClass.SetGlyph(const Value: TBitmap);
begin
  FGlyph.assign(Value);
end;

procedure TAHMBaseDlgButtonClass.SetNumGlyphs(const Value: Integer);
begin
  FNumGlyphs := Value;
end;

procedure TAHMBaseDlgButtonClass.SetVisible(const Value: Boolean);
begin
  FVisible := Value;
end;


{ TAHMDlgHelpButtonClass }

constructor TAHMDlgHelpButtonClass.Create;
begin
  inherited Create;
  FHelpContext:=0;
end;

{ TAHMMsgDlgButtonClass }

constructor TAHMMsgDlgButtonClass.Create(ADialog : TAHMMsgDlg);
begin
  inherited Create;
  FDialog:=ADialog;
  FModalResult:=mrNone;
end;

procedure TAHMMsgDlgButtonClass.OnChangeDefault(Sender: TObject);
begin
  if (Sender is TAHMMsgDlgButtonClass) then
  begin
    FDialog.MsgButton1.FDefault:=False;
    FDialog.MsgButton2.FDefault:=False;
    FDialog.MsgButton3.FDefault:=False;
    TAHMMsgDlgButtonClass(Sender).FDefault:=True;
  end;
end;

procedure TAHMMsgDlgButtonClass.SetDefault(const Value: Boolean);
begin
  FDefault := Value;
  if Value then OnChangeDefault(Self);
end;

{ TAHMBaseDlgButtonClass }

procedure TAHMMsgDlg.SetButtonWidth(const Value: LongInt);
begin
  FButtonWidth := Value;
end;

procedure TAHMMsgDlg.SetFormWidth(const Value: Integer);
begin
  if Value>=320 then FFormWidth := Value;
end;

procedure TAHMMsgDlg.Button1Click(Sender: TObject);
begin
  if assigned(FOnBtn1Click) then FOnBtn1Click(self);
end;

procedure TAHMMsgDlg.Button2Click(Sender: TObject);
begin
  if assigned(FOnBtn2Click) then FOnBtn2Click(self);
end;

procedure TAHMMsgDlg.Button3Click(Sender: TObject);
begin
  if assigned(FOnBtn3Click) then FOnBtn3Click(self);
end;

procedure TAHMMsgDlg.HelpButtonClick(Sender: TObject);
begin
  Application.HelpContext(FHelpButton.FHelpContext);
  if assigned(FOnHelpClick) then FOnHelpClick(self);
end;

procedure TAHMMsgDlg.SetMessageType(const Value: TMsgDlgType);
begin
  FMsgType := Value;
end;


procedure TAHMMsgDlg.SetIcon(const Value: TIcon);
begin
  FIcon.assign(Value);
end;

constructor TAHMMsgDlg.Create(Collection: TCollection);
begin
  inherited Create(Collection);
  FAHMMsgDlgHolder :=(((Collection as TAHMMsgDlgs).GetOwner)
                                          as TAHMMsgDlgHolder);
  FFont:=TFont.Create;
  FEditbox:=TAHMDlgEditClass.Create;
  FMsgButton1:=TAHMMsgDlgButtonClass.Create(Self);
  FMsgButton1.FCaption:='&Ok';
  FMsgButton2:=TAHMMsgDlgButtonClass.Create(Self);
  FMsgButton2.FCaption:='&Cancel';
  FMsgButton3:=TAHMMsgDlgButtonClass.Create(Self);
  FMsgButton3.FCaption:='&Custom..';
  FHelpButton:=TAHMDlgHelpButtonClass.Create;
  FHelpButton.FCaption:='&Help';
  FCaption:='My Caption';
  FMsgType:=mtInformation;
  FIcon:=TIcon.Create;
  FBeepType:=bNone;
  FButtonWidth:=80;
  FFormWidth:=320;
end;

function TAHMMsgDlg.GetDisplayName: string;
begin
{  Result := 'Alex';
  if Result = '' then}
  Result := inherited GetDisplayName;
  if FMessage<>'' then Result:=FMessage
    else Result:='No message defined';
  {Other than Delphi3 -> if Result = '' then Result := 'TAHMADFIELD';}
end;

function TAHMMsgDlgs.GetOwner: TPersistent;
begin
  Result := FAHMMsgDlgHolder;
end;

procedure TAHMMsgDlg.Assign(Source: TPersistent);
begin
  if Source is TAHMMsgDlg then
  begin
    Exit;
  end;
  inherited Assign(Source);
end;

constructor TAHMMsgDlgs.Create(AOwner: TAHMMsgDlgHolder);
begin
  inherited Create(TAHMMsgDlg);
  FAHMMsgDlgHolder := AOwner;
end;

function TAHMMsgDlgs.Add: TAHMMsgDlg;
begin
  Result := TAHMMsgDlg(inherited Add);
end;

function TAHMMsgDlgs.GetAHMMsgDlg(Index: Integer): TAHMMsgDlg;
begin
  Result := TAHMMsgDlg(inherited GetItem(Index));
end;

procedure TAHMMsgDlgs.SetAHMMsgDlg(Index: Integer; Value: TAHMMsgDlg);
begin
  inherited SetItem(Index, Value);
end;

constructor TAHMMsgDlgHolder.Create(AOwner: TComponent);
begin
  inherited create(AOwner);
  FAHMMsgDlgs:=TAHMMsgDlgs.Create(self);
end;

destructor TAHMMsgDlgHolder.Destroy;
begin
  FAHMMsgDlgs.Free;
  inherited Destroy;
end;

function TAHMMsgDlgHolder.Execute(Index: Integer): String;
begin
  if (Index>-1) and (Index<FAHMMsgDlgs.Count) then
  result:=FAHMMsgDlgs[Index].Execute else result:='';
end;

procedure TAHMMsgDlgHolder.SetAHMMsgDlgs(Value: TAHMMsgDlgs);
begin
  FAHMMsgDlgs.Assign(Value);
end;


function TAHMMsgDlgs.Delete(Index: Integer): Boolean;
begin
  result := true;
  Try
    Items[Index].free;
  Except
    result := false;
    Application.handleexception(self);
  End;
end;

procedure TAHMMsgDlg.ProcessMessages(Value: TModalResult);
begin
  case Value of
    mrAll : if assigned(FOnmrAll) then  FOnmrAll(Self);
    mrCancel : if assigned(FOnmrCancel) then  FOnmrCancel(Self);
    mrYes : if assigned(FOnmrYes) then  FOnmrYes(Self);
    mrIgnore : if assigned(FOnmrIgnore) then  FOnmrIgnore(Self);
    mrNone : if assigned(FOnmrNone) then  FOnmrNone(Self);
    mrYesToAll : if assigned(FOnmrYesToAll) then  FOnmrYesToAll(Self);
    mrOk : if assigned(FOnmrOk) then  FOnmrOk(Self);
    mrNoToAll : if assigned(FOnmrNoToAll) then  FOnmrNoToAll(Self);
    mrNo : if assigned(FOnmrNo) then  FOnmrNo(Self);
    mrRetry : if assigned(FOnmrRetry) then  FOnmrRetry(Self);
    mrAbort : if assigned(FOnmrAbort) then  FOnmrAbort(Self);
  else
    if assigned(FOnmrNone) then  FOnmrNone(Self);
  end;
end;

{ TAHMDlgEditClass }

constructor TAHMDlgEditClass.Create;
begin
  inherited Create;
  FCaption:='Label';
  FCharCase:=ecNormal;
  FColor:=clWindow;
  FMaxLength:=0;
  FPasswordChar:=#0;
  FFontColor:=clWindowText;
end;

procedure TAHMDlgEditClass.SetCaption(const Value: String);
begin
  FCaption := Value;
end;

procedure TAHMDlgEditClass.SetCharCase(const Value: TEditCharCase);
begin
  FCharCase := Value;
end;

procedure TAHMDlgEditClass.SetColor(const Value: TColor);
begin
  FColor := Value;
end;

procedure TAHMDlgEditClass.SetFontColor(const Value: TColor);
begin
  FFOntColor := Value;
end;

procedure TAHMDlgEditClass.SetMaxLength(const Value: Integer);
begin
  FMaxLength := Value;
end;

procedure TAHMDlgEditClass.SetPasswordChar(const Value: Char);
begin
  FPassWordChar := Value;
end;

procedure TAHMDlgEditClass.SetText(const Value: String);
begin
  FText := Value;
end;

end.
