将窗口保持在前景中(即使它失去焦点) [英] Keep window in foreground (even if it loses focus)

查看:97
本文介绍了将窗口保持在前景中(即使它失去焦点)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序(C#,Windows窗体)中,我有一个电话信息屏幕:如果有打来的电话,则会显示一个向呼叫者提供其他信息的窗口。

In my application (C#, Windows Forms) I have got a telephone information screen: if there is an incoming phone call a window with additional information to the caller is shown.

此窗口应在前景中打开,并且即使用户在另一个窗口中书写也应停留在该窗口中(这样,用户仍会看到有关来电的信息)。

This window should open in foreground and should stay there even if the user is writing in another window (so the user still sees the information regarding the incoming phone call).

首先,我使用了BringToFront-但这并不是在所有情况下都有效(例如,当主应用程序不在前台时)。

First I've used BringToFront - but this didn't really work in all circumstances (e.g. when the main application was not in the foreground).

现在我我正在使用BringToFront和user32.dll函数BringWindowToTop->起作用,但是如果窗口失去焦点,它将在后台。

Right now I am using BringToFront and the user32.dll function BringWindowToTop -> which works, but if the window loses focus it is in the background.

如何实现此行为?

推荐答案

我认为您想将表单设置为 TopMost

I think you want to set your form as TopMost:

yourForm.TopMost = true;

这篇关于将窗口保持在前景中(即使它失去焦点)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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