程序最小化到系统托盘中后,如何捕获桌面上的鼠标事件。 ( 积分: 100 )

  • 主题发起人 主题发起人 opeope
  • 开始时间 开始时间
O

opeope

Unregistered / Unconfirmed
GUEST, unregistred user!
程序最小化到系统托盘中后,如何捕获桌面上的鼠标事件。
 
程序最小化到系统托盘中后,如何捕获桌面上的鼠标事件。
 
在application的onmessage里面捕捉
 
可以利用重载WinProc函数实现,只要是系统消息,都能够捕捉到!
 
哈哈。看来这100是要给我了。<br>用回调消息。<br>const<br> &nbsp; &nbsp;MY_MESSAGE &nbsp; &nbsp; &nbsp;=WM_USER+100;<br>nid.uCallbackMessage:=MY_MESSAGE; &nbsp; <br>procedure OnIconNotify(var message:Tmessage); Message MY_MESSAGE;procedure Tfrmmain.OnIconNotify(var message:Tmessage);//消息处理函数。<br>const<br> &nbsp; &nbsp;Busy &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:boolean=false;<br>var<br> &nbsp; &nbsp;hand &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:hwnd;<br> &nbsp; &nbsp;appname &nbsp; &nbsp; &nbsp; &nbsp; :string;<br> &nbsp; &nbsp;pt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:Tpoint;<br><br>begin<br> &nbsp; &nbsp;appname:=application.Title;<br> &nbsp; &nbsp;hand:=FindWindow(nil,pchar(appname));<br> &nbsp; &nbsp;if not Busy then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;if message.LParam=WM_LBUTTONDOWN then<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if hand&lt;&gt;0 then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if not IsZoomed(Handle) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowWindow(hand,SW_RESTORE);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SetForegroundWindow(hand);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br>end;
 
后退
顶部