将窗口保持在前景(即使它失去焦点)

发布于 2024-08-07 18:17:54 字数 305 浏览 8 评论 0原文

在我的应用程序(C#、Windows 窗体)中,我有一个电话信息屏幕:如果有来电,则会显示一个窗口,其中包含呼叫者的附加信息。

该窗口应在前台打开,并且即使用户在另一个窗口中写入,也应保留在那里(因此用户仍然可以看到有关来电的信息)。

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

现在我正在使用 BringToFront 和 user32.dll 函数 BringWindowToTop ->这是可行的,但如果窗口失去焦点,它就会在后台。

我如何实施这种行为?

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).

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).

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.

How do I implement this behaviour ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲影 2024-08-14 18:17:54

我认为您想将表单设置为 TopMost< /a>:

yourForm.TopMost = true;

I think you want to set your form as TopMost:

yourForm.TopMost = true;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文