Membuat Message Dialog sendiri

Kali ini kita mencoba bikin Message Dialog sendiri.

Langsung saja sourcenya ya :
Form Utama
unit u_coba;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;

type
Tf_Coba = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
f_Coba: Tf_Coba;

implementation

uses Unit_bantuan;

{$R *.dfm}

procedure Tf_Coba.BitBtn1Click(Sender: TObject);
var jawab:byte;
begin
jawab:=PesanOn3('Pertanyaan Cinta','DSJFHSDF SDFSJDLS FSLDFSLDFSD FSDFLSDFSDLJFSDF Test mencintainya ?',16);
showmessage(inttostr(jawab));
case jawab of
1 : MessageDlg('OK', mtWarning, [mbOK], 0);
2 : ;
7 : MessageDlg('Tidak', mtWarning, [mbOK], 0);
end;
end;

procedure Tf_Coba.BitBtn2Click(Sender: TObject);
var jawab:byte;
begin
jawab:=PesanOn1('','',10);
case jawab of
1 : Showmessage('OK');
2 : ;
7 : Showmessage('Batal');
end;
end;

end.














------------------------------
Ini source Unit Bantuan letakkan di Create New Unit
unit Unit_bantuan;

interface
uses Windows, Forms, Messages, SysUtils, Variants, Classes, Graphics, Controls,
u_dialog, u_dialog1, Dialogs, ExtCtrls, StdCtrls, Buttons;

Function PesanOn3(title,msg:string;sizefont:byte):TModalResult;
Function PesanOn1(title,msg:string;sizefont:byte):TModalResult;

implementation


Function PesanOn3(title,msg:string;sizefont:byte):TModalResult;
begin
f_pesan:=Tf_pesan.create(nil);
f_pesan.title.Caption:=title;
f_pesan.txt.Font.Size:=sizefont;
f_pesan.txt.Caption:=msg;
f_pesan.ShowModal;
result:=f_pesan.ModalResult;
f_pesan.Free;
end;

Function PesanOn1(title,msg:string;sizefont:byte):TModalResult;
begin
f_dialog1:=Tf_dialog1.create(nil);
f_dialog1.ShowModal;
result:=f_dialog1.ModalResult;
f_dialog1.Free;
end;

end.

-----------------------------
bikin form dialognya

unit u_dialog;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons;

type
Tf_pesan = class(TForm)
Panel1: TPanel;
title: TPanel;
Image1: TImage;
txt: TStaticText;
Panel3: TPanel;
a1: TBitBtn;
a2: TBitBtn;
a3: TBitBtn;
Image2: TImage;
procedure a3Click(Sender: TObject);
procedure a2Click(Sender: TObject);
procedure a1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
f_pesan: Tf_pesan;

implementation

{$R *.dfm}

procedure Tf_pesan.a3Click(Sender: TObject);
begin
ModalResult:=mrOK;
end;

procedure Tf_pesan.a2Click(Sender: TObject);
begin
ModalResult:=mrCancel;
end;

procedure Tf_pesan.a1Click(Sender: TObject);
begin
ModalResult:=mrNo;
end;

end.

1 komentar:

Anonim mengatakan...

sip mas,,, sangat keren..

SIAKAD

SIAKAD
Sistem Informasi Akademik

Hit Counter


View My Stats

Simpeg

Simpeg
Sistem Informasi Kepegawaian

SIMPAU

SIMPAU
Sistem Informasi Perijinan Angkutan Umum