type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Button2: TButton;<br> procedure FormCreate(Sender: TObject);<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> procedure My_Message(var Msg: TMsg; var Handled: Boolean);<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>uses Unit2, Unit3;<br><br>{$R *.dfm}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> Application.OnMessage:= My_Message;<br>end;<br><br>procedure TForm1.My_Message(var Msg: TMsg; var Handled: Boolean);<br>var<br> j:integer;<br>begin<br> Handled:=False;<br> if (Msg.message=45057) and (Msg.hwnd<>Self.Handle) then<br> begin<br> caption:=inttostr(Msg.message);<br> end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> form2.ShowModal;<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br> form3.ShowModal;<br>end;<br>当form2或form3最小话后会触发这个消息。但不知道是否正确。