Really annoying bug with Topmost property in Windows Forms
Posted
by Nazgulled
on Stack Overflow
See other posts from Stack Overflow
or by Nazgulled
Published on 2010-05-06T00:51:42Z
Indexed on
2010/05/06
0:58 UTC
Read the original article
Hit count: 304
Hi,
I have this Windows Forms application where it sits in the notification area. Clicking on the icon brings it up front, clicking it again (or clicking on the app X icon) sends it back. This is the type of app that having the window always on top is important when it's displayed by clicking the icon, but it's optional.
Right-clicking the icon brings up a context menu where one can select to enable the "always on top" option or not. When the application first starts up, the app settings are read from an XML file and I'm 99% that this is working as it should, the Topmost properly is properly read (and written).
After some time (minutes, hours, days, whatever, I normally hibernate and rarely shutdown) the Topmost stops working. I don't change the option, I don't think anything is changing the option but I click the notification area icon and app is not brought up front. It shows up (it displays on Alt+Tab) but it's on the background, it's not topmost as it should. I bring up the context menu, disable the option (cause it's enabled) and enable it back and it starts to work after that. The app is now topmost. However, it can lose this ability anytime after while.
I can't understand why this happens and how this happens. Does anyone have any idea why? If not, any idea how could I try to debug such behavior?
© Stack Overflow or respective owner