Delphi:带 fsStayOnTop 的气球窗体在 Win7 中不起作用

发布于 2024-12-12 08:58:36 字数 292 浏览 0 评论 0原文

我有一个使用我自己的气球形式的应用程序。 这是一种无边框、fsStayOnTop 类型的表单。

我用这段代码展示它:

ShowWindow(Handle, SW_SHOWNOACTIVATE);
Visible := True;

今天我意识到,如果我激活另一个应用程序,那么气球就不会出现! 因此,它正在失去保持顶级风格的能力。

环境: Win7/x64 Delphi 6 Professional

我可以用它做什么?

谢谢: DD

I have an application that uses my own balloon form.
This is a non-bordered, fsStayOnTop kind form.

I show it with this code:

ShowWindow(Handle, SW_SHOWNOACTIVATE);
Visible := True;

Today I realized that if I activate another application then the balloon is not appearing!
So it is loosing it's stay on top style.

Environment:
Win7/x64
Delphi 6 Professional

What I can do with it?

Thanks:
dd

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

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

发布评论

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

评论(2

£冰雨忧蓝° 2024-12-19 08:58:37

过去,当我在处理停留在顶部的表单时,什么对我有用:

Form := TMyForm.Create(Self);
Application.NormalizeTopMosts;
SetWindowPos(Form.Handle, HWND_TOPMOST, 0, 0, 0, 0,
             SWP_NOACTIVATE + SWP_NOMOVE + SWP_NOSIZE);
Form.Show;

尝试这个而不是您的 ShowWindow 调用。它位于所有窗口的顶部(您真的想要这个吗?)。而且它感觉有点 hacky,因为它省略了文档中说我们应该调用的 RestoreTopMosts 调用(因此应用程序中的其他停留在顶部的窗口将受到影响)。所以可能有更好的解决方案。

What worked for me in the past when struggling with stay-on-top forms:

Form := TMyForm.Create(Self);
Application.NormalizeTopMosts;
SetWindowPos(Form.Handle, HWND_TOPMOST, 0, 0, 0, 0,
             SWP_NOACTIVATE + SWP_NOMOVE + SWP_NOSIZE);
Form.Show;

Try this instead of your ShowWindow call. This stays on top of all windows (do you really want this?). Also it feelds kind of hacky because it omits the RestoreTopMosts call which the documentation says we should call (so other stay-on-top windows in your application will be affected). So there might be a better solution.

莫言歌 2024-12-19 08:58:37

我尝试了上述解决方案,但它在辅助表单上不起作用。我相信它适用于主要形式,但不适用于次要形式。然而,我确实找到了一个适用于辅助表单的解决方案,这听起来像是原始海报想要的,因为“气球表单”通常是弹出窗口。

将其放入“Form B”OnCreate 事件中:

FormStyle:= fsStayOnTop;

但仅此还不够...

TApplicationEvents 拖到“Form B”

ApplicationEvents1OnDeactivate 事件,添加以下内容:

SetForegroundWindow(Handle);

当我的主窗体处于处理站点外的数据。做工精美!

I tried the above solution and it did not work on a secondary form. I believe it will work on a main form, but not on a secondary form. However, I did find a solution that works for a secondary form, which sounds like what the original poster wanted, as a "balloon form" is typically a pop-up.

Put this in the "Form B" OnCreate event:

FormStyle:= fsStayOnTop;

but that alone isn't enough...

Drag a TApplicationEvents onto your "Form B"

In the OnDeactivate event for ApplicationEvents1, add the following:

SetForegroundWindow(Handle);

I keep an eye on a small status window while my main form is crunching data out of site. Works beautifully!

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