Custom ShowMessage,MessageDlg

showMessage:

代码
{
--Author Ming
--Version V01.001
--Creation Date 2009/03/25
--Last Updated Date
}
unit unitShowMsg;

interface

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

type
TfrmShowMsg
= class(TForm)
moMsg: TMemo;
btOK: TButton;
Panel1: TPanel;
procedure btOKClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure ChangeLanguage;
public
{ Public declarations }
class procedure CustShowMessage(aMsg:String);
end;

var
frmShowMsg: TfrmShowMsg;

implementation

const
K_CH
= 'CN';
K_EN
= 'EN';
LanguageFlag
= K_CH;

{$R *.dfm}

procedure TfrmShowMsg.ChangeLanguage;
begin
if LanguageFlag = K_CH then
begin
btOK.Caption :
= '确定';
end
else
begin
btOK.Caption :
= 'OK';
end;
end;

class procedure TfrmShowMsg.CustShowMessage(aMsg:String);
begin
with TfrmShowMsg.Create(nil) do
try
moMsg.Clear;
moMsg.Lines.Add(aMsg);
ShowModal;
finally
Free;
end
end;

procedure TfrmShowMsg.btOKClick(Sender: TObject);
begin
Close;
end;

procedure TfrmShowMsg.FormCreate(Sender: TObject);
begin
ChangeLanguage;
end;

end.
MessageDlg:

代码
{
--Author Ming
--Version V01.001
--Creation Date 2009/03/25
--Last Updated Date
}
unit unitMsgDlg;

interface

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

type
TfrmMsgDlg
= class(TForm)
btYes: TButton;
btNo: TButton;
Panel1: TPanel;
moMsg: TMemo;
procedure btYesClick(Sender: TObject);
procedure btNoClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure ChangeLanguage;
public
{ Public declarations }
class function CustMessageDlg(aMsg:String):Boolean;
end;

var
frmMsgDlg: TfrmMsgDlg;

implementation

const
K_CH
= 'CN';
K_EN
= 'EN';
LanguageFlag
= K_CH;

{$R *.dfm}

procedure TfrmMsgDlg.ChangeLanguage;
begin
if LanguageFlag = K_CH then
begin
btYes.Caption :
= '确定';
btNo.Caption :
= '取消';
end
else
begin
btYes.Caption :
= 'Yes';
btNo.Caption :
= 'No';
end;
end;

class function TfrmMsgDlg.CustMessageDlg(aMsg:String):Boolean;
begin
with TfrmMsgDlg.Create(nil) do
try
moMsg.Clear;
moMsg.Lines.Add(aMsg);
ShowModal;
Result :
= ModalResult = mrYes;
finally
Free;
end;
end;

procedure TfrmMsgDlg.btYesClick(Sender: TObject);
begin
Self.ModalResult :
= mrYes;
end;

procedure TfrmMsgDlg.btNoClick(Sender: TObject);
begin
Self.ModalResult :
= mrNo;
end;

procedure TfrmMsgDlg.FormCreate(Sender: TObject);
begin
ChangeLanguage;
end;

end.

 

posted @ 2010-12-26 16:21  Jekhn  阅读(161)  评论(0编辑  收藏  举报