如何获得Delphi中光标下的控件?(How do I get the Control that is under the cursor in Delphi?)

我需要相反的信息,问题是“如何在控件上获取光标位置?” 问。

鉴于当前的光标位置,我如何找到表单(在我的应用程序中)和光标当前结束的控件? 我需要它的句柄,以便我可以使用Windows.SetFocus(Handle) 。

作为参考,我使用的是Delphi 2009。

I need the opposite information that the question "How to get cursor position on a control?" asks.

Given the current cursor position, how can I find the form (in my application) and the control that the cursor is currently over? I need the handle to it so that I can use Windows.SetFocus(Handle).

For reference, I'm using Delphi 2009.

最满意答案

我认为FindVCLWindow将满足您的需求。 一旦在光标下面有了窗口控件,就可以通过父链来找到窗口所在的窗体。

I think FindVCLWindow will meet your needs. Once you have the windowed control under the cursor you can walk the parent chain to find the form on which the window lives.

更多推荐