System Tray Iconised App Under Aero
-
Minimising an application to the system tray and removing it from the task-bar is a pretty common task for the makers of all kinds of helpful utilities so I thought I'd share my recent experiences in this area under Vista which had me scratching my head for a couple of days...:confused: It's probably worth noting that our app does quite a bit of custom drawing in non-client (including the main frame window) as well as client areas, the windows default paint handlers might not exhibit the same behaviour, I haven't checked (& currently don't have time to). Our main app window is initially created without the WS_VISIBLE or WS_EX_APPWINDOW styles set (if you only clear WS_VISIBLE and not WS_EX_APPWINDOW, the app is still visible in the Alt-tab list), going straight to the systray. The main window can then be activated by a right-click menu selection or double-click on the systray icon. The event handlers for both of these actions call a common method to make the main window visible. All I thought this method had to do was: 1) Modify the window style and extended style to set WS_VISIBLE & WS_EX_APPWINDOW 2) Show the window in its restored state. 3) Redraw the main window. 4) Bring the main window into the foreground Pretty straight-forward stuff & all was well until we tested it on a Vista notebook. The right-click menu selection brought up the window as expected but a double-click on the sys-tray icon only showed the window on the task-bar, not the window itself. The only way to get the application to show itself again after this was to right click on the sys-tray icon (which would show the main window's frame but not refresh the client area), then switch tasks back and forth with another application with an overlapping main window. To solve this I tried: Any number of combinations and orderings of WinAPI (through MFC) calls to: RedrawWindow, Invalidate, UpdateWindow, BringWindowToTop, SetForegroundWindow and ActivateFrame (or so I thought, keep reading...) and sending &/or posting WM_PAINT & WM_NCPAINT messages. After trying the first of the above combinations on a Vista installation on a Virtual PC & seeing the app behave as expected I left it alone until the Vista lap-top mentioned above was brought back into the equation. The Original problem was still there and further investigation (though if I'd really paid attention to all the related announcements I probably would have already known) revealed that the Aero Glass theme was not available on a Virtual PC installation of Vista, throwing out
-
Minimising an application to the system tray and removing it from the task-bar is a pretty common task for the makers of all kinds of helpful utilities so I thought I'd share my recent experiences in this area under Vista which had me scratching my head for a couple of days...:confused: It's probably worth noting that our app does quite a bit of custom drawing in non-client (including the main frame window) as well as client areas, the windows default paint handlers might not exhibit the same behaviour, I haven't checked (& currently don't have time to). Our main app window is initially created without the WS_VISIBLE or WS_EX_APPWINDOW styles set (if you only clear WS_VISIBLE and not WS_EX_APPWINDOW, the app is still visible in the Alt-tab list), going straight to the systray. The main window can then be activated by a right-click menu selection or double-click on the systray icon. The event handlers for both of these actions call a common method to make the main window visible. All I thought this method had to do was: 1) Modify the window style and extended style to set WS_VISIBLE & WS_EX_APPWINDOW 2) Show the window in its restored state. 3) Redraw the main window. 4) Bring the main window into the foreground Pretty straight-forward stuff & all was well until we tested it on a Vista notebook. The right-click menu selection brought up the window as expected but a double-click on the sys-tray icon only showed the window on the task-bar, not the window itself. The only way to get the application to show itself again after this was to right click on the sys-tray icon (which would show the main window's frame but not refresh the client area), then switch tasks back and forth with another application with an overlapping main window. To solve this I tried: Any number of combinations and orderings of WinAPI (through MFC) calls to: RedrawWindow, Invalidate, UpdateWindow, BringWindowToTop, SetForegroundWindow and ActivateFrame (or so I thought, keep reading...) and sending &/or posting WM_PAINT & WM_NCPAINT messages. After trying the first of the above combinations on a Vista installation on a Virtual PC & seeing the app behave as expected I left it alone until the Vista lap-top mentioned above was brought back into the equation. The Original problem was still there and further investigation (though if I'd really paid attention to all the related announcements I probably would have already known) revealed that the Aero Glass theme was not available on a Virtual PC installation of Vista, throwing out
Thanks for that, I've got an app that uses the "Sys Tray" that i've got to move to vista in the near future. I'm looking forward to it! BTW, apparently the Systray has never been called the Systray. It's called something like the notification panel. I used the word Systray on an MSDN forum once and got flamed by a load of MS coders who had the attitude that if I didn't know what to call it I was unlikely to be able to code against it. Russ
-
Thanks for that, I've got an app that uses the "Sys Tray" that i've got to move to vista in the near future. I'm looking forward to it! BTW, apparently the Systray has never been called the Systray. It's called something like the notification panel. I used the word Systray on an MSDN forum once and got flamed by a load of MS coders who had the attitude that if I didn't know what to call it I was unlikely to be able to code against it. Russ
Clearly those particular coders don't pay attention to the world outside of Microsoft, then, as every person I've heard talk about it has called it the SysTray, including myself.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan Portland, Oregon, USA
www.defaultn.com