弹出窗口按钮没反应解决方案
弹出窗口按钮没反应
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm2 = class(TForm)
ComboBox1: TComboBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label1: TLabel;
Label2: TLabel;
Image1: TImage;
OpenDialog1: TOpenDialog;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button2Click(Sender: TObject);
begin
form2.Close;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
openDialog1.Execute;
end;
end.
下面是Form1中调用弹出窗口Form2的代码
procedure TForm1.N1Click(Sender: TObject);
begin
form2 := tform2.create(nil);
try
form2.showmodal;
finally
form2.free;
end;
end;
------解决方案--------------------
看看form的visable属性.改成false看看.
------解决方案--------------------
procedure TForm1.N1Click(Sender: TObject);
begin
Application.CreateForm(tform2,form2);
form2 :=form2.Create(Application);
tform2.ShowModal;
end;
------解决方案--------------------
被Free掉了!
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm2 = class(TForm)
ComboBox1: TComboBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label1: TLabel;
Label2: TLabel;
Image1: TImage;
OpenDialog1: TOpenDialog;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button2Click(Sender: TObject);
begin
form2.Close;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
openDialog1.Execute;
end;
end.
下面是Form1中调用弹出窗口Form2的代码
procedure TForm1.N1Click(Sender: TObject);
begin
form2 := tform2.create(nil);
try
form2.showmodal;
finally
form2.free;
end;
end;
------解决方案--------------------
看看form的visable属性.改成false看看.
------解决方案--------------------
procedure TForm1.N1Click(Sender: TObject);
begin
Application.CreateForm(tform2,form2);
form2 :=form2.Create(Application);
tform2.ShowModal;
end;
------解决方案--------------------
被Free掉了!