Delphi:带 fsStayOnTop 的气球窗体在 Win7 中不起作用
我有一个使用我自己的气球形式的应用程序。 这是一种无边框、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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
过去,当我在处理停留在顶部的表单时,什么对我有用:
尝试这个而不是您的
ShowWindow
调用。它位于所有窗口的顶部(您真的想要这个吗?)。而且它感觉有点 hacky,因为它省略了文档中说我们应该调用的RestoreTopMosts
调用(因此应用程序中的其他停留在顶部的窗口将受到影响)。所以可能有更好的解决方案。What worked for me in the past when struggling with stay-on-top forms:
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 theRestoreTopMosts
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.我尝试了上述解决方案,但它在辅助表单上不起作用。我相信它适用于主要形式,但不适用于次要形式。然而,我确实找到了一个适用于辅助表单的解决方案,这听起来像是原始海报想要的,因为“气球表单”通常是弹出窗口。
将其放入“Form B”OnCreate 事件中:
FormStyle:= fsStayOnTop;
但仅此还不够...
将 TApplicationEvents 拖到“Form B”
上ApplicationEvents1 的 OnDeactivate 事件,添加以下内容:
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!