How to avoid getting focus? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Frank
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Jan 01, 2005 6:19 pm

How to avoid getting focus?

Post by Frank » Tue Nov 27, 2007 4:56 pm

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

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Tue Nov 27, 2007 5:41 pm

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 ;)

Frank
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Jan 01, 2005 6:19 pm

Post by Frank » Tue Nov 27, 2007 7:34 pm

That works :)

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

Thank you
Frank

pete_b
Knows some wx things
Knows some wx things
Posts: 41
Joined: Fri Jan 05, 2007 9:52 am

Post by pete_b » Tue Nov 27, 2007 11:10 pm

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.

Post Reply