Wednesday, January 30, 2008

Customise your Message Dialog


procedure TForm1.Button2Click(Sender: TObject);
var
Dlg: TForm;
Rslt: Integer;
begin
Dlg := CreateMessageDialog('Customised MessageBox, hope this is helpful', mtConfirmation, [mbYes, mbNo, mbNoToAll]);

{ change the messagedlg caption }
Dlg.Caption := 'Please Confirm';

{change the button texts }
TButton(Dlg.FindComponent('Yes')).Caption := 'Indeed!';
TButton(Dlg.FindComponent('No')).Caption := 'Surely Not!';
TButton(Dlg.FindComponent('NoToAll')).Caption := 'None please!';

{ change the button fonts }
TButton(Dlg.FindComponent('Yes')).Font.Name := 'C4 Text';
TButton(Dlg.FindComponent('No')).Font.Name := 'C4 TextMedium' ;
TButton(Dlg.FindComponent('NoToAll')).Font.Name := 'Tahoma';
//this sets the buttons font to Bold & Underlined
TButton(Dlg.FindComponent('NoToAll')).Font.Style:=[fsBold];

{ change the Message's appearance }
TLabel(Dlg.FindComponent('Message')).Font.Name := 'Courier New';
TLabel(Dlg.FindComponent('Message')).Font.Size := 12;
TLabel(Dlg.FindComponent('Message')).Font.Color := clRed;

Rslt := Dlg.ShowModal;

case Rslt of
mrYes: { do "Yes" stuff };
mrNo: { do "No" stuff };
mrNoToAll: { do "No to All" stuff };
end;
end;

2 comments:

Anonymous said...

Nice idea, thnaks a lot!

Beaumont Cabinets said...

Thank you for bbeing you