Delphi fsStayOnTop 怪事
这是交易。主窗体设置为fsNormal
。该主窗体最大化全屏并带有浮动工具栏。工具栏是正常形式,样式设置为fsStayOnTop
。
大多数时候这会按预期工作。主窗体显示,工具栏浮在其顶部。
有时(这是查找一组可重现步骤的麻烦),当使用 alt-tab 键切换到其他应用程序或从其他应用程序切换时(或单击任务栏上的 Delphi 应用程序图标时),可能会出现以下症状:
当使用 alt-tab 键离开其他 应用程序时Delphi 应用程序最顶层的浮动
fsStayOnTop
表单保留在其他应用程序之上。因此,如果我使用 alt-tab 键切换到 Firefox,那么浮动菜单也会保留在 Firefox 的顶部。- 另一个应用程序通过 alt-tab 键切换到 Delphi 应用程序时,浮动菜单不可见(因为它位于
fsNormal
主窗体后面)。
这是一个已知的错误还是有任何黑客可以强制它工作?当应用程序的多个副本运行时(它们之间没有交互,应该在自己的窗口“沙箱”中运行),这种情况似乎也最常发生。
就好像 Delphi 混淆了哪个窗口应该位于顶部并交换它们或更改浮动形式以保持在一切之上模式。
或者我误解了fsStayOnTop
?我假设将表单样式设置为 fsStayOnTop
使其位于当前应用程序中的所有其他表单之上,而不是其他正在运行的应用程序中的所有窗口。
Here is the deal. Main form set to fsNormal
. This main form is maximized full screen with a floating toolbar. Toolbar is normal form with style set to fsStayOnTop
.
Most fo the time this works as expected. The mainform displays and the toolbar floats over on top of it.
Sometimes (this is a bugger to find a reproducible set of steps) when alt-tabbing to and from other apps (or when clicking the Delphi app icon on the taskbar) the following symptoms can happen:
When alt-tabbing away from the Delphi app the floating topmost
fsStayOnTop
form stays on top of the other apps. So if I alt-tab to Firefox then the floating menu stays on top of Firefox too.When alt-tabbing from another app to the Delphi app the floating menu is not visible (as it is behind the
fsNormal
mainform).
Is this a known bug or are there any hacks to force it to work? This also seems to happen most when multiple copies of the app are running (they have no interaction between them and should be running in their own windows "sandbox").
It is as if Delphi gets confused which window is meant to be on top and swaps them or changes the floating form to stayontopofeverything mode.
Or have I misunderstood fsStayOnTop
? I am assuming setting a form style to fsStayOnTop
makes it stay on top of all other forms within the current app and not all windows across other running apps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了类似的问题,这个链接对我帮助很大: Delphi : 带有 fsStayOnTop 的气球窗体在 Win7 中不起作用
当我调用 Application.NormalizeTopMosts() 函数时,最上面的窗体会按照我的预期运行。
I had a similar problem and this link help me a lot: Delphi: Balloon Form with fsStayOnTop not working in Win7
When I call the Application.NormalizeTopMosts() function then the topmost forms behave as I expect.
更多信息和可能的解决方案。
将浮动形式设置为 fsnormal。
当 mainform.activate 事件触发时,调用 floatform.bringtofront。
但我也对所有其他应用程序对话框使用stayontop。当应用程序的多个副本正在运行时,对话框会显示相同的问题(即,如果应用程序1打开了一个对话框,并且使用alt选项卡远离该对话框,则该对话框可能会保留在所有其他程序的顶部)。
A bit more info and possible solution.
Set the floatingform to fsnormal.
When the mainform.activate event fires call floatingform.bringtofront.
But I also use stayontop for all of the other app dialogs. When multiple copies of the app are running then the dialogs show the same problem (ie if app1 has a dialog open and is alt-tabbed away from the the dialog may stay on top of all other programs).
我不知道这个区域有错误。
首先让我解释一下这个过程是如何工作的:
Delphi 在创建保存表单的窗口时首先使用
fsStayOnTop
样式,通过使用HWND_TOPMOST< 调用 win32 函数
SetWindowPos
/代码> 参数。请参阅 http://msdn.microsoft.com/en- us/library/ms633545(VS.85).aspx 了解
SetWindowPos
的详细说明。每次应用程序停用或最小化时,Delphi 都会枚举所有最顶层的窗体来规范化这些窗体(规范化是 vcl 使用的术语,表示最顶层的窗口变为非最顶层的窗口),并且它保留所有窗体的内部列表。此刻位于最上面的窗户。
每次激活或恢复应用程序时,Delphi都会使用存储在最顶层窗口列表中的信息来恢复所有最顶层的窗体(使用
setWindowPos
和HWND_TOPMOST
参数)所以对我来说问题似乎出在 Delphi 在应用程序最小化时枚举窗口时存储信息的方式。
我会侵入最小化或停用功能,并检查最上面的窗口列表(位于
Application.FTopMostList
上)是否正确列出。I don't know of a bug in this area.
Let me first explain how the process works:
Delphi first uses
fsStayOnTop
style during the creation of the window that holds the form, by invoking win32 functionSetWindowPos
withHWND_TOPMOST
parameter.See http://msdn.microsoft.com/en-us/library/ms633545(VS.85).aspx for a detailed explanation of
SetWindowPos
.Everytime the application is deactivated or minimized, Delphi enumerates all the topmost forms to normalize the forms (normalize is the term that vcl uses to mean that the windows that are topmost are turned to not being topmost) and it keeps an internal list of all of the windows that were topmost at that moment.
Everytime the application is activated or restored, Delphi uses the information stored in the list of topmost windows, to restore all the topmost forms (using
setWindowPos
withHWND_TOPMOST
parameter)So to me the problems seems to be in the way that Delphi stores the information while enumerating the windows when the application is minimized.
I would hack into the minimize or deactivate function and check if the topmost windows list (it is on
Application.FTopMostList
) are correctly listed.