How to make a window always stay on top in .Net?(如何使窗口始终保持在.Net 的顶部?)
问题描述
我有一个在另一个程序中运行宏的 C# winforms 应用程序.另一个程序会不断地弹出窗口,并且通常会让事情看起来很疯狂,因为没有更好的词.我想实现一个取消按钮来停止进程运行,但我似乎无法让窗口保持在顶部.如何在 C# 中执行此操作?
I have a C# winforms app that runs a macro in another program. The other program will continually pop up windows and generally make things look, for lack of a better word, crazy. I want to implement a cancel button that will stop the process from running, but I cannot seem to get the window to stay on top. How do I do this in C#?
我尝试过 TopMost = true; ,但其他程序不断在顶部弹出自己的窗口.有没有办法每 n 毫秒将我的窗口发送到顶部?
I have tried TopMost = true; , but the other program keeps popping up its own windows over top. Is there a way to send my window to the top every n milliseconds?
我解决此问题的方法是添加一个系统托盘图标,该图标将通过双击它来取消该过程.系统托盘图标不会被掩盖.感谢所有回复的人.我阅读了关于为什么没有超级顶部"窗口的文章......它在逻辑上不起作用.
The way I solved this was by adding a system tray icon that will cancel the process by double-clicking on it. The system tray icon does no get covered up. Thank you to all who responded. I read the article on why there is not a 'super-on-top' window... it logically does not work.
推荐答案
Form.TopMost 将工作,除非其他程序正在创建最顶层的窗口.
Form.TopMost will work unless the other program is creating topmost windows.
无法创建未被另一个进程的新顶层窗口覆盖的窗口.Raymond Chen解释了原因.
There is no way to create a window that is not covered by new topmost windows of another process. Raymond Chen explained why.
这篇关于如何使窗口始终保持在.Net 的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使窗口始终保持在.Net 的顶部?
基础教程推荐
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
