关于鼠标钩子的问题,(50分)

  • 主题发起人 主题发起人 不可一世
  • 开始时间 开始时间

不可一世

Unregistered / Unconfirmed
GUEST, unregistred user!
能不能拦截到鼠标按下的按钮的句柄?如能该如何实现?
 
★★★取指定点的控件句柄:<br><br>function GetWindowFromPoint(const p: TPoint): HWND;<br>var<br>&nbsp; pp: TPoint;<br>&nbsp; h: HWND;<br>&nbsp; bEnd: Boolean;<br>begin<br>&nbsp; bEnd := False;<br>&nbsp; Result := WindowFromPoint(p);<br><br>&nbsp; while not bEnd do<br>&nbsp; begin &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; pp := p;<br>&nbsp; &nbsp; Windows.ScreenToClient(Result, pp);<br>&nbsp; &nbsp; h := ChildWindowFromPoint(Result, pp);<br>&nbsp; &nbsp; if (h &lt;= 0) or (h = Result) then bEnd := True else Result := h;<br>&nbsp; end;<br>end;<br><br>在鼠标钩子中检测到鼠标消息后调用这个方法即可。<br><br>关于鼠标钩子,可以看看这个帖子:<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=1883318<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=1850588<br>
 
接受答案了.
 
后退
顶部