Title: Dialog BOX
Question: Personalizing a dialog box with Check Box
Answer:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject) ;
var
AMsgDialog: TForm;
ACheckBox: TCheckBox;
begin
AMsgDialog := CreateMessageDialog('Test for CheckBox', mtWarning, [mbYes, mbNo]) ;
ACheckBox := TCheckBox.Create(AMsgDialog) ;
with AMsgDialog do
try
Caption := 'Dialog Title' ;
Height := 169; // Height del DialogBOX
with ACheckBox do
begin
Parent := AMsgDialog;
Width := 150;
Caption := 'Select TRUE / FALSE';
Top := 121;
Left := 8;
end;
if (ShowModal = ID_YES) then
begin
if ACheckBox.Checked then
showmessage('CheckBox is TRUE')
else
showmessage('CheckBox is FALSE')
end;
finally
Free;
end;
end;
end.