Y
yanyuwuhen
Unregistered / Unconfirmed
GUEST, unregistred user!
我是这样做的:<br> 1.获得所有窗体句柄<br> 2.postmessage()<br> 3.在自身窗体中截获WM_SYSCOMMAND消息,处理最小化事件。<br> 1.2实现正常,所有的窗体都最小化了,而且3中也接收到了的最消化消息,但我的窗体<br>还是被最小化了!请各位高手帮帮忙,谢谢!<br>//*************************************************************************<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> CheckBox1: TCheckBox;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> procedure WMSysCommand(var Msg: TMessage);message WM_SYSCOMMAND;<br> end;<br><br>var<br> Form1: TForm1;<br> flagMin:boolean;<br>implementation<br><br>{$R *.dfm}<br>procedure MinAllForms;<br>var<br> hw:HWnd;<br>begin<br> hw:=Form1.handle;<br> while hw>0 do<br> begin<br> if IsWindowVisible(hw) then<br> Postmessage(hw,WM_SYSCOMMAND,SC_MINIMIZE,0);<br> hw:=GetnextWindow(hw,GW_HWNDNEXT);<br> end;<br>end;<br>procedure TForm1.WMSysCommand(var Msg: TMessage);<br>begin<br> case Msg.WParam of<br> SC_MINIMIZE: showmessage('Min');<br> else inherited;<br> end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> MinAllForms;<br>end;<br><br>end.<br>