How to get notified of textbox focus?

半腔热情 提交于 2019-12-24 09:32:19

问题


Using a Windows 7 touch device Windows shows this little touch-keyboard indicator (tabing this will bring up the touch on screen keyboard) when you tab/focus a textbox or kind of input field (Notepad etc.).

I want to write an application that gets notified when exactly that happens, a textbox (etc.) gets focused (no matter which application).

Are applications informed about focusing in other applications, do I need to hook something?

Is there a way in doing so in c++?


回答1:


I believe the SetWinEventHook function and specifically the EVENT_OBJECT_FOCUS event is what you are looking for.

From the MSDN description:

An object has received the keyboard focus. The system sends this event for the following user interface elements: list-view control, menu bar, pop-up menu, switch window, tab control, tree view control, and window object. Server applications send this event for their accessible objects.

The hwnd parameter of the WinEventProc callback function identifies the window that receives the keyboard focus.



来源:https://stackoverflow.com/questions/8906568/how-to-get-notified-of-textbox-focus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!