我有一个方法很简单,完全代码如下:<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure FormCreate(Sender: TObject);<br> procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);<br> procedure Button1Click(Sender: TObject);<br> private<br> mux:integer;<br> procedure myminimize(sender:Tobject);<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> application.OnMinimize:=myminimize;<br> mux:=0;<br>end;<br>procedure TForm1.myminimize(Sender:Tobject);<br>begin<br>//insert your minize code...<br>end;<br>procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);<br>begin<br> if mux<>1 then<br> canclose:=false<br> else<br> canclose:=true;<br> //if you really close window ,you should set canclose to True...<br> //insert your close code...<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> mux:=1;<br> close;<br>end;<br><br>end.