Modifikasi Message Dialog Delphi


Tips & Trik Delphi, Tips Belajar Delphi, Belajar Delphi Online
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.

TransCODE Software

2 pemikiran pada “Modifikasi Message Dialog Delphi

  1. makasih om tutor nya,tambah ilmu saya,,,
    kalo di postingan saya tentang message dialog ternyata jauh beda dan saya masih cupu2 om hehehe
    bisa kan om kita sharing2an tentang delphi nya?
    saya masih btuh bnyak belajar…

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s