截取WM_Activate消息,其LParam参数是刚失去窗口的Handle,<br>下面是我以前写的一段测试代码。<br><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 Button1Click(Sender: TObject);<br> procedure GorFore(var Msg: Tmessage); message WM_Activate;<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br>end;<br><br>var<br> Form1: TForm1;<br> ForeHandle:thandle;<br>implementation<br>procedure Tform1.GotFore(var Msg: Tmessage);<br>begin<br> ForeHandle:=Msg.LParam;<br>end;<br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br><br>begin<br> windows.setactivewindow(ForeHandle);<br>end;<br><br><br>PS: 这个问题也不给点分:-(