Can a window be both active and hidden? Apparently so! Help 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
maxinuruguay
I live to help wx-kind
I live to help wx-kind
Posts: 198
Joined: Sat Oct 28, 2006 3:36 am

Can a window be both active and hidden? Apparently so! Help

Post by maxinuruguay »

I have a watchdog timer that checks if a certain window is active (using wxGetActiveWindow). If that window is active it calls Hide() on it. The next time the timer runs (1 sec) it checks to see if the window is still active and, lo and behold, it still is. How can that be? I found this comment on Wine message board:
Recent tests confirm that a hidden window can have an input focus, and
the message test shows that a focus should be moved out of a window
being destroyed.
Is this what happens? wxGetActiveWindow calls (on MSW) GetActiveWindow which is supposed to

The GetActiveWindow function retrieves the window handle to the active window attached to the calling thread's message queue.
Is this the same as the applications foreground window? Regards, max
JSThePatriot
Earned some good credits
Earned some good credits
Posts: 146
Joined: Sun Nov 26, 2006 7:37 am
Location: Tennessee, USA
Contact:

Post by JSThePatriot »

The active window isn't always the foreground window. As you have found out. You may want to deactivate the window after hiding it. That would be the work around.

On MSW you can check out AutoIt. You can see in that scripting automation language that windows can be hidden and still active.

I hope you get it worked out,
JS
OS Windows XP Pro
Compiler MinGW 3.4.5
wxWidgets 2.8.7 (Unicode : Monolithic : Release)
IDE Code::Blocks (Latest Release)
RAD wxFormBuilder (Latest Release)
redrgreen
Knows some wx things
Knows some wx things
Posts: 30
Joined: Tue Oct 26, 2004 9:44 am

Post by redrgreen »

If you are going to hide the window why not check to see if its hidden by using IsShown()?
JSThePatriot
Earned some good credits
Earned some good credits
Posts: 146
Joined: Sun Nov 26, 2006 7:37 am
Location: Tennessee, USA
Contact:

Post by JSThePatriot »

Excellent point ;).

I am still a novice with wxWidgets.

JS
OS Windows XP Pro
Compiler MinGW 3.4.5
wxWidgets 2.8.7 (Unicode : Monolithic : Release)
IDE Code::Blocks (Latest Release)
RAD wxFormBuilder (Latest Release)
maxinuruguay
I live to help wx-kind
I live to help wx-kind
Posts: 198
Joined: Sat Oct 28, 2006 3:36 am

Post by maxinuruguay »

You may want to deactivate the window after hiding it. That would be the work around.

JS
Thanks for the response, I really appreciate it. How do you disactivate a window? I tried calling Hide() followed by Disable() but that does not work. Any ideas? max
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

If this is indeed relaterd to the exerpt you posted, i would just try making another component request the focus
maxinuruguay
I live to help wx-kind
I live to help wx-kind
Posts: 198
Joined: Sat Oct 28, 2006 3:36 am

Post by maxinuruguay »

Thanks to those that helped me. For future reference, I found a good site that explains the difference between focus and activation (among other things).


http://blogs.msdn.com/jfoscoding/archiv ... 86141.aspx
Post Reply