本文介绍了如何使窗口始终保持在 .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 的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 05:17