I have this windows forms app where it is in the notification area. Clicking on the icon takes it up, clicking it again (or clicking on the application X icon) sends it back. This is the type of application, when the window is always on top, it is important when it is displayed by clicking on the icon (this is optional).
When you right-click on the icon, a context menu appears in which you can select the option "always on top" or not. When the application is first launched, the application settings are read from the XML file, and I am 99% working as I should, the property is TopMostcorrectly read (and written).
After some time (minutes, hours, days, whatever, I'm usually sleeping and rarely disconnected), it TopMoststops working. I do not change the option, I do not think that something changes the value of the parameter, but I click on the notification area icon and the application does not bring up in front. It is displayed, but it is in the background (it is displayed on Alt + Tab), it is not "always on top" as it should. I call the context menu, turn off the parameter (make it activate) and turn it on, and it starts working after that. The application is now "always on top". However, he may lose this ability at any time after some time.
I do not understand why this is happening and how it is happening. Does anyone know why? If not, any idea how I can try to debug this behavior?
EDIT:
I added a code snippet to show the MessageBox when the property TopMostwas changed to see if I could notice any strange behavior, but it was useless. This did not help, because the form was with TopMost = true, but it was still in the background ...
source
share