Page 1 of 1

How to avoid getting focus?

Posted: Tue Nov 27, 2007 4:56 pm
by Frank
Hi,

I'm writing a Notification-Window (like Thunderbirds "You have new Mail" Thingy).

My Problem is, as soon as I call Show() on the Window, it steals the focus. I don't want it to disturb the User in his work, so it should only display it's message for a few seconds and disapear.

The window is a simple wxFrame without any decorations with a single Panel in it. The Panel holds only a static bitmap and a static text. So there are no controls wich can get the focus. It seems to be the frame itself that steals the focus.

How can I avoid that my notification frame steals the focus? I thougt about looking who has the focus before and just give it back after the call to Show(). The Problem is, the notification can also be displayed when the user works in another, non WX application, so that seems no option (okay, I could use WinAPI, but I try to avoid it).

Any Hints?

Thanks in advance
Frank

Posted: Tue Nov 27, 2007 5:41 pm
by Auria
Perhaps take a look at the flag wxFRAME_TOOL_WINDOW, on most system I believe such window will not have focus. I believe however that it behaves differently according to platforms.

I am not sure how i'd do that, but Code::Blocks does it so there must be a way somehow ;)

Posted: Tue Nov 27, 2007 7:34 pm
by Frank
That works :)

At least on Windows, wich is good enough for now.

Thank you
Frank

Posted: Tue Nov 27, 2007 11:10 pm
by pete_b
The other option on Windows is to override Show() and give the SW_SHOWNOACTIVATE or SW_SHOWNA flag to ShowWindow (search in the wxwidgets msw source for showwindow).

This will also have the effect of ensuring that the title bar of your main frame does not change colour.

I've used this for displaying a floating translucent frame when dragging a custom splitter in a dockable layout.