最後附完整的此自定義函數的程序清單:
unit udfForm;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type TfrmShowMsg = class(TForm)
Button1: TButton;
Label1: TLabel;
Button2: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;
function ShowMsg(btn1, btn2, msg, titleMsg: string): Integer;
implementation
{$R *.DFM}
function ShowMsg(btn1, btn2, msg, titleMsg: string): Integer;
var
frmshowMsg: TfrmShowMsg;
begin
frmShowMsg := TfrmShowMsg.Create(Application);
with frmShowMsg do
try
button1.Caption := btn1;
button2.Caption := btn2;
Label1.Caption := msg;
Caption := titleMsg;
if ShowModal=mrOK
then result:=1
else result:=2;
finally Free;
end;
end;
end.