Thanks, Harald. Once again, you've busted me out of the mental box I was in. Your program so clearly works, one would wonder why mine doesn't. The difference is in the fact that I'm calling BringWindowToTop from a Notify icon click (which was clear from the sample code I provided), and you are not. Why this should be different is apparently due to the choice of the Windows designers in implementing the System Tray icon business.
Clicking on a window, or a sub-item in a window, as is done to reach the Belly button in your code, "activates" your Main window, and gives it the keyboard focus. Then, with the application already being activated, the BringWindowToTop function is sufficient to raise the other window from whatever depths it is in! Clicking on a System Tray icon apparently doesn't activate the application windows, just passes the click message in to the app. So then, if the result of the click is that the application wants to come to the foreground, it has to activate itself! Seems Win32::GUI doesn't provide that capability: it documents GetFocus and GetActiveWindow, but doesn't document SetFocus or SetActiveWindow! Poking around in gui.xs reveals that it has a SetFocus, but not a SetActiveWindow. So I made a SetActiveWindow out of Win32::API. However, it still doesn't do the trick. Now, even though I SetFocus, SetActiveWindow, BringWindowToTop, and Show the window, it still doesn't come to the front when I click the Notify Icon. This is on NT 4 sp 6, by the way. "Piske, Harald" wrote: > Works with me ... I have two windows, one button in the first window brings > the other to top. Complete code snippet attached for you to check if it > works with you and figure out the differences to yours. Oh, and I only > checked on Win2k. > > Have fun, > Harald > > > -----Original Message----- > > From: Glenn Linderman [mailto:[EMAIL PROTECTED] > > Sent: Mittwoch, 6. Juni 2001 18:25 > > To: Win32::GUI > > Subject: [perl-win32-gui-users] BringWindowToTop doesn't > > > > > > Hi, > > > > So I've got this code, and it doesn't bring the window to the top. I > > can see that each time I click on the notify icon that the code gets > > executed, both because the print statement fires, and the window > > redraws. But the window stays behind other windows, in spite of the > > BringWindowToTop call. It does that with or without the Hide/Show > > sequence, and with or with a Disable/Enable sequence wrapped > > around the > > BringWindowToTop. ActivePerl 5.6.1 build 626, Win32::GUI > > 0.0.558. What > > trick am I missing? > > > > I'm quite willing to throw all this away, and use whatever > > works... this > > is just what sounded like should work from the documentation. > > > > I should note that $mw is using the "parent window" trick to > > avoid being > > on the task bar. I further note that sufficient Alt-Tab keystrokes do > > eventually raise the window to the top. > > > > sub notify_icon_Click > > { if ( $mw -> IsVisible ()) > > { print "Bring Main to Top\n"; > > $mw -> Hide (); > > $mw -> BringWindowToTop (); > > $mw -> Show (); > > } > > } > > > > -- > > Glenn > > ===== > > Due to the current economic situation, the light at the > > end of the tunnel will be turned off until further notice. > > > > > > > > _______________________________________________ > > Perl-Win32-GUI-Users mailing list > > Perl-Win32-GUI-Users@lists.sourceforge.net > > http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > > > > ------------------------------------------------------------------------ > > X.PLName: X.PL > Type: Perl Program (application/x-perl) -- Glenn ===== Due to the current economic situation, the light at the end of the tunnel will be turned off until further notice.