Tuesday, January 4, 2011

Modifikasi Message Dialog Delphi

unit Unit1;
interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type

TForm1 = class(TForm)
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public

{ Public declarations }
end;
var
Form1: TForm1;

implementation

{$R *.DFM}
function MyMessageDialog(const Msg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; Captions: array of string): Integer;
var
aMsgDlg: TForm;
i: Integer;
dlgButton: TButton;
CaptionIndex: Integer;
begin
aMsgDlg := CreateMessageDialog(Msg, DlgType, Buttons);
captionIndex := 0;
aMsgDlg.Color:=clYellow;
aMsgDlg.Caption:=’Pesan’;
for i := 0 to aMsgDlg.ComponentCount – 1 do
begin
if (aMsgDlg.Components[i] is TButton) then
begin
dlgButton := TButton(aMsgDlg.Components[i]);
if CaptionIndex > High(Captions) then Break;
dlgButton.Caption := Captions[CaptionIndex];
Inc(CaptionIndex);
end;
end;
Result := aMsgDlg.ShowModal;
end;
procedure Delay(msec: Longint);
var
start, stop: Longint;
begin
start := GetTickCount;
repeat
stop := GetTickCount;
Application.ProcessMessages;
until (stop – start) >= msec;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
if MyMessageDialog(‘Anda yakin…?’, mtConfirmation, mbOKCancel,
['Ya', 'Tidak']) = mrOk then
ShowMessage(‘”Ya” clicked‘)
else
ShowMessage(‘”Tidak” clicked‘);
end;


end.

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Kang Iwan K-sev | Thank's for your visit To My Site - Ridwan Mulyana | Cibeureum