一个应用程序能否获得另一个应用程序窗体的控件句柄? ( 积分: 0 )

  • 主题发起人 主题发起人 丁满
  • 开始时间 开始时间

丁满

Unregistered / Unconfirmed
GUEST, unregistred user!
如题!<br>答出择地给分
 
如题!<br>答出择地给分
 
用findwindow 函數。
 
FindWindowEx()
 
可以!<br> 已答何处接分
 
试试这个:<br>procedure TFrmMain.Timer1Timer(Sender: TObject);<br>var<br> &nbsp;P:TPoint;<br> &nbsp;Hwnd:THandle;<br>begin<br> &nbsp;GetCursorPos(P);<br> &nbsp;Hwnd:=WindowFromPoint(P);<br> &nbsp;tex_Hwnd.Text:=IntToStr(Hwnd);<br> &nbsp;if Hwnd&lt;&gt;0 then<br> &nbsp; &nbsp; EnumChildWindows(Hwnd, @yourproc, 0);<br>end;
 
TfrmMain = class(TForm)<br>private<br> &nbsp; &nbsp;procedure myWM_ACTIVATE(var Message: TMessage); message WM_ACTIVATE;//截获消息<br> &nbsp; &nbsp;{ Private declarations }<br>public<br> &nbsp; &nbsp;{ Public declarations }<br>end;<br><br>var <br> &nbsp; &nbsp;appHandle:HWND<br><br>procedure TfrmMain.myWM_ACTIVATE(var Message: TMessage);<br>var<br> &nbsp; &nbsp;wnd:HWND;<br>begin<br> &nbsp; &nbsp;wnd := GetForegroundWindow();<br> &nbsp; &nbsp;if (appHandle &lt;&gt; wnd ) and &nbsp;(wnd&lt;&gt;Handle) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;appHandle:=wnd;<br> &nbsp; &nbsp;end;<br>end;
 
后退
顶部