不会吧,这个问题本来很弱智,懒得花时间,建两个窗体,form1放一个按钮,然后双击按钮,将下面的代码全部覆盖上去,接着run,按下按钮,弹出form2,仅此一次,无论form2是否显示,都不会再弹出来<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls, Unit2;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> procedure FormDestroy(Sender: TObject);<br> private<br> <br> public<br> formDJ: TForm2;<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> if formDJ <> nil then exit;<br> formDJ:= TForm2.Create(self);<br> formDJ.show;<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br> if formDJ <> nil then<br> formDJ.free;<br>end;<br><br>end.<br><br><br>如果想form2关闭的时候,按按钮就会弹出,而弹出的时候,按钮无效,可以在form的Close事件加入代码<br><br>unit Unit2;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs;<br><br>type<br> TForm2 = class(TForm)<br> procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form2: TForm2;<br><br>implementation<br><br>{$R *.dfm}<br><br>uses Unit1;<br><br>procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br> Form1.formDJ.free;<br> Form1.formDJ:=nil;<br>end;<br><br>end.<br><br>顺便改改前面的按钮过程<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> if formDJ <> nil then<br> begin<br> formDJ.BringToFront;<br> exit;<br> end;<br> formDJ := TForm2.Create(self);<br> formDJ.show;<br>end;