开发者

How do I have my apps dialog box pop up and take focus from the current running app?

I know this type of thing is looked negatively upon but I write software for people with disabilities and sometimes good gui practices don't make sense. In this case, the user interacts with a assistive interface and under certain conditions, my control app needs to prompt the user with a question. My background process creates 开发者_JAVA百科a dialog (I'm using wxwidgets wxDialog class) and calls Show(). The dialog box appears but it does not have focus (the application that the user was previously using keeps it). Since my users can't use mice, they can't simply click on the window. I've tried calling show and then followed by SetFocus(HWND) but that doesn't do it. What's the problem? Is this even possible? Window7. I'm thinking that it might have something to do with it being a dialog and not a full window (wxFrame). Any help is greatly appreciated.


Try using SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE)


Unfortunately, not only is it 'looked negatively upon', but it is not possible. There's no getting around this; ask yourself what would happen if every application could do this? Obviously, if you can put your dialog on top of the other application, it can do exactly the same back to you.

http://blogs.msdn.com/b/oldnewthing/archive/2010/11/25/10096329.aspx

The only think I can think of would be for you to put a notification icon in the system tray, and then have it display a notification balloon.


I had to do something like this before. Simply calling functions like SetForegroundWindow or SetWindowPos didn't do the trick.

I ended up using this ForceForegroundWindow function (1st one) and it works pretty well.

I know this is Delphi code, but the API is the same and Delphi is a pretty simple language.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜