Really annoying bug with TopMost property in Windows Forms

只愿长相守 提交于 2019-12-05 11:01:49

There is more than just one "Topmost" window. Topmost just says "Before all non-topmost windows".

I am pretty sure a reinitialization of the desktop (such as when hibernating) requires another SetWindowPos(hwnd, HWND_TOPMOST, ...) (which is the underlying Win32 API call).

As a workaround, you could reset and set the property again when showing the window.

Another possibility is that hiding the window also changes the Z order - either implicitely how Win32 implements that, or explicitely in the way WinForms call the hide/show window.

Like peterchen i also don't have a clue how to get the root cause. But why not make it a little bit simpler?

When you click on your Icon you'll show up your window and rely that TopMost is still active. Why not call SetWindowPos() with the current setting right before you show the window. This shouldn't make any performance problems (only happens if the user clicks the icon) nor any other side effect.

I know, it would be great to find out the root cause, but maybe it's not worth if you can solve it with such a little workaround.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!