开发者

How to set input focus to an application which is not in foreground in Windows?

I want my application to capture input focus, whenever the mouse hovers over it. How do I do it in Windows?

Basically I dont want users to explicitly click on the application, or the taskbar icon before entering any text, when the application is not in foreground.

I tried the SetForegroundWindow开发者_如何学编程 API in the mouse hover notification, but that just flashes the icon in the taskbar.

Any suggestions?


Not sure where the focus is supposed to go. But if to the hovered window then fake a mouse click with SendInput().


Try GetDlgItem(QTIDD_W01_0)->SetFocus(); //QTIDD_W01_0 is the window of the screen


There are 3 ways you can make your window Active

  1. Use SetActiveWindow API to make your window active.
  2. Enumarate all the windows and get your window handle and make foreground window.
  3. Use AllowSetForegroundWindow API which accepts processid as the parameter and makes that process as active.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜