如何保持一个窗口只在我的应用程序的所有其他窗口的顶部? [英] How to keep a window on top of all other windows in my application only?

查看:338
本文介绍了如何保持一个窗口只在我的应用程序的所有其他窗口的顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的C#的Windows显示一个状态窗口窗体应用程序,通知当应用程序等待获取锁定的用户。这是一个应用程序定义的事,然而,窗口应该是可见的,并始终保持在我的申请的所有其他窗口的顶部,即使当在另一窗口中用户点击(例如像较大的主后面窗口)。



它不能是模式(所以的ShowDialog()不能使用),因为应用程序需要不断地尝试在后台关闭,如果自动锁定最终可能被收购的窗口,它真的不应该是最顶层为整个窗口站(即在终端会话中运行的所有应用程序)。



我知道Form.TopMost属性,但它只能带来并保持高于一切的单一窗口,即使是那些从其他应用程序。这显然不是我要找的。

我知道这是可能的,我以前在其他应用中看到了很多次。我只是不知道它是如何完成的。


解决方案

如果您通过您的主要形式进入的 显示 地位形式方法,它会留在上面的主要形式,但不是在其他应用顶部。因此,在主窗体可以有像这样的代码:

  StatusForm statusForm =新StatusForm(); 
statusForm.Show(本);



然而,这样只会指出你的应用程序作为业主之一,单一窗口。


I would like to display a status window in my C# Windows Forms application that informs the user when the application is waiting to acquire a lock. This is an application-defined thing, however, the window should be visible and always remain on top of all other windows of my application, even when the user clicks on another window (like for example the larger main window behind it).

It must not be modal (so ShowDialog() cannot be used) because the app needs to keep trying in the background and close the window automatically if the lock could eventually be acquired, and it really should not be top-most for the entire window station (i.e. all applications running in that terminal session).

I know the Form.TopMost property, but it can only bring and keep a single window above all others, even those from other applications. This is clearly not what I'm looking for.

I know that this is possible, I've seen it many times before in other applications. I just don't know how it can be done.

解决方案

If you pass your main form into the Show method of the status form, it will stay on top of the main form, but not on top of other applications. So, in the main form you can have code like so:

StatusForm statusForm = new StatusForm();
statusForm.Show(this);

However, this will only point out one single window of your application as the owner.

这篇关于如何保持一个窗口只在我的应用程序的所有其他窗口的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆