我的 WindowsFormsApplication 落后于所有应用程序
我开发了一个 WindowsFormsApplication,其边框样式窗体为“FixedToolWindow”,现在的问题是,当我要最小化任何其他打开的应用程序时,我的应用程序会落后于所有已打开的应用程序。我不明白问题到底出在哪里。那么有人可以帮我找出问题所在以及如何将其短路吗?
任何帮助将不胜感激。 提前致谢
I developed a WindowsFormsApplication having a Form of Border Style as "FixedToolWindow", now the problem is while I am going to minimize any other opened application then my application going behind of all the application opened already. I am not getting where the problem is exactly. So can anybody help me to find out where the problem and how to short out it ?
Any help will be appreciated.
Thanks in Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该问题称为Z 顺序,它是由Windows 维护的屏幕上出现的窗口的内部从上到下的顺序。
当您单击该其他应用程序将其最小化时,它会成为“活动”应用程序,并且其窗口将移动到前台。这会将您的应用程序(曾经是前台窗口)推入后台,位于其他应用程序后面。这会导致其窗口被隐藏或遮挡在其他应用程序的窗口后面。单击应用程序的窗口将再次将其带到前台,使其覆盖其后面的所有窗口。
但要回答您真正的问题,不,您不应该为应用程序的主窗口的
BorderStyle
指定“FixedToolWindow”。具有该边框样式的窗口不会出现在任务栏中,并且不会被视为应用程序的主窗口。该样式适用于除了应用程序主窗口之外还显示的工具窗口,例如浮动调色板。The problem is called Z order, which is the internal top-to-bottom ordering of the windows that appear on the screen maintained by Windows.
When you click on that other application to minimize it, it becomes the "active" application and its window is moved to the foreground. That pushes your application (which used to be the foreground window) into the background, behind the other application. That causes its window to be hidden or obscured behind the window of the other application. Clicking on your application's window will bring it to the foreground again, causing it to cover up any windows that lie behind it.
But in answer to your real question, no, you should not have specified "FixedToolWindow" for the
BorderStyle
of your application's main window. Windows with that border style do not appear in the taskbar and are not treated as the main window of an application. That style is intended for tool windows, such as floating palettes, displayed in addition to an application's main window.如果您的表单旨在成为工具窗口,那么您可能希望它在显示时出现在所有其他表单之上。
因此,将其 TopMost 属性设置为 True。
否则,我同意 Cody Gray,主窗体不应具有 FixedToolWindow 边框样式。
If your form is intended to be a tool window then perhaps you would like it to appear above all other forms when shown.
Therefore, set it's TopMost property to True.
Otherwise, I agree with Cody Gray, no main form should have a FixedToolWindow border style.