L
lxmzm
Unregistered / Unconfirmed
GUEST, unregistred user!
在使用自定义对话框时,对话框中的按钮点击2次才有效,不知为啥?
代码如下: 增加execute
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls;
type
Tmydialog = class(TForm)
Panel1: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
BitBtn3: TBitBtn;
ComboBox1: TComboBox;
private
{ Private declarations }
public
text:string;
function execute:boolean;
{ Public declarations }
end;
var
mydialog: Tmydialog;
implementation
function tmydialog.execute:boolean;
begin
if showmodal=MrOK then
begin
text:=combobox1.text;
result:=true;
mydialog.close;
end;
if showmodal=MrCancel then
begin
result:=false;
mydialog.close;
end;
end;
{$R *.DFM}
end.
在form1中调用
....
uses unit5;
...
使用方式:
if mydialog.exe then
.....
代码如下: 增加execute
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls;
type
Tmydialog = class(TForm)
Panel1: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
BitBtn3: TBitBtn;
ComboBox1: TComboBox;
private
{ Private declarations }
public
text:string;
function execute:boolean;
{ Public declarations }
end;
var
mydialog: Tmydialog;
implementation
function tmydialog.execute:boolean;
begin
if showmodal=MrOK then
begin
text:=combobox1.text;
result:=true;
mydialog.close;
end;
if showmodal=MrCancel then
begin
result:=false;
mydialog.close;
end;
end;
{$R *.DFM}
end.
在form1中调用
....
uses unit5;
...
使用方式:
if mydialog.exe then
.....