我尝试使用以下方法创建子窗口:
CreateWindowEx( NULL, NULL, "MyChild", WS_CHILD | WS_VISIBLE | WS_BORDER, 300, 300, 400, 200, hParentWnd, NULL, NULL );
其中父 HWND hParentWnd 已经有许多其他子窗口。但是,这会创建一个隐藏在所有 sibling 后面的子窗口。 Windows Spy++ 显示它位于 hParentWnd 的子窗口中 z 顺序的顶部(第一个)。我尝试了所有不同的 win32 命令,包括 SetWindowPos()
、BringWindowToTop()
、SetForegroundWindow()
、SetFocus()
, SetActiveWindow()
, SendMessage(WM_ACTIVATE, 0, 0)
等等,但是没有一个从 sibling 的后面带来。当我在 CreateWindowEx()
命令中用 WS_OVERLAPPEDWINDOW
替换 WS_CHILD
时,创建的非子窗口没有问题显示为最顶层的前景事件窗口.那么我必须怎么做才能让子窗口从 sibling 的后面升到顶部呢?
感谢一百万。
z/0
最佳答案
CreateWindowEx() 的 MSDN 文章中非常明确:
If the created window is a child window, its default position is at the bottom of the Z-order. If the created window is a top-level window, its default position is at the top of the Z-order.
您需要使用 SetWindowPos() 将其移动到 Z 顺序的顶部。
关于c++ - 由 CreateEx() 创建的子窗口被兄弟窗口重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9490137/