首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

弹出窗口按钮没反应解决方案

2012-02-26 
弹出窗口按钮没反应unitUnit2interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Contro

弹出窗口按钮没反应
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掉了!

热点排行