c++ - 由 CreateEx() 创建的子窗口被兄弟窗口重叠

标签 c++ mfc window

我尝试使用以下方法创建子窗口:

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/

相关文章:

c++ - Win32 C++将窗口位置设置为右下角

java - 制作带有可见边框的透明 JFrame

c++ - 检查 CString 是否包含特定的文本 MFC

c++ - 如何更新MFC源代码?

c++ - 未解析的外部符号 receiveThread(这是 _beginthread 的入口点)

C++删除一组列表中的重复项

c# - 无法使用 TestStack.White 自动编辑控件和列表框

java - 最小化时防止窗口重绘

c++ - 动态数组,动态构造函数

c++ - 成员函数之外的封闭类的定义中需要默认成员初始值设定项