I've got an application that has a main window and two
supplementary windows. (They use the wxMiniFrame style, and
don't appear on the taskbar.) This is meant to be used
alongside another program, and I expect that the various
windows will occasionally be covered. I'd like to arrange
it so that, when my app is activated (by clicking the
taskbar button or the window itself), all three windows get
brought to the top.
So, I try hooking EVT_ACTIVATE_APP, but this doesn't seem to
ever get called. When I hook EVT_ACTIVATE for my main
window, my event handler does get called, but there's a
problem. I'm using the Raise() method on my subwindows to
bring them to the top, but that then de-activates my main
window. I can't use the menu or toolbar on this window,
because when I click on anything to activate the window, it
pops the two subwindows to the top, which deactivates the
main window again... If I try raising the main window
after the two subwindows, I get stuck in an infinite loop.
I can see two possible avenues to get around this, but I'm
not sure how to implement either one. The first would be to
find some way to raise the subwindows to be just below the
main window, instead of at the very top, but Raise() (and
its complement Lower() ) seem to be all-or-nothing, topmost
or bottommost, with no option for anywhere in between. The
second way would be to figure out some way to distinguish
between losing active-window status to my subwindows, and
losing it to some other application altogether. Then I can
track whether my application is the active one, and only
raise the subwindows if it's not. (I've tried maintaining a
flag on each window, that tracks its active state, and
considered the app active if any of the windows were, but
the subwindow loses active status before the main window is
activated, so at that point, none of my windows are active
and thus my app looks inactive...)
I keep going around in circles on this, and I feel like I'm
missing something obvious, but I can't imagine what it is.
Anyone have any suggestions? A better way of doing this?
Here's the activation code that I've got (which hits
infinite-loop):
···
------------------------------------------------------
in MainWindow:
def OnActivate(self, event):
# If activating, and app not already active...
if event.GetActive() and not self.GetAppActive():
# raise all three windows
self.Active = true
self.datawindow.Raise()
# only try to raise the toolwindow if it
exists...
if self.toolwindow:
self.toolwindow.Raise()
self.Raise()
# If de-activating, then mark this window as
non-active
if self.Active and not event.GetActive():
self.Active = false
def GetAppActive(self):
if self.Active:
return true
elif self.datawindow.Active:
return true
elif self.toolwindow and self.toolwindow.Active:
return true
else:
return false
--------------------------------------------------------
Both other windows' OnActivate functions look like this:
def OnActivate(self, event):
self.Active = event.GetActive()
--------------------------------------------------------
Jeff Shannon
Technician/Programmer
Credit International