如何使子窗口最顶层? [英] How can I make a child window topmost?
问题描述
我有一个父窗体,其中有一些子窗口(不是窗体 - 只是窗口,例如标签控件).在某些情况下,我希望将其中一个子窗口绘制在其他子窗口的上方",以在整个主窗体上显示一条消息.
I have a parent form, with some child windows (not forms - just windows, for example label controls) inside it. Under certain circumstances, I want one of those child windows to be drawn "above" the others, to display a message over the entire main form.
我已经尝试在子窗口上设置 HWND_TOPMOST 和 HWND_TOP,但它似乎根本没有任何效果.是我做错了什么,还是 HWND_TOPMOST 和 HWND_TOP 只适用于表单,而不是表单中的控件?
I've tried setting HWND_TOPMOST and HWND_TOP on the child windows, but it doesn't seem to have any effect at all. Am I doing something wrong, or do HWND_TOPMOST and HWND_TOP only work on forms, as opposed to controls within forms?
谢谢.
推荐答案
HWND_TOPMOST 仅适用于顶级窗口,不适用于子窗口.
HWND_TOPMOST only applies to top level windows, not child windows.
使用带有 HWND_TOP 标志的 SetWindowPos 来更改目标子窗口的 zorder,使其位于其兄弟窗口中 zorder 的顶部.
Use SetWindowPos withthe HWND_TOP flag to change the target child window's zorder to put it at the top of the zorder among its siblings.
请注意,子窗口中的 zorder 仅适用于同级 - 具有相同父级的 hwnd.
Note that zorder in child windows only applies to siblings - hwnds with the same parent.
这篇关于如何使子窗口最顶层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!