MFC非模态对话框位于最前面但不是最顶层
最近,我想在它的父窗口前面放置一个对话框(总是这样做,无论它的父窗口是否获得焦点),但不是最上面的。换句话说,我只希望它覆盖其父窗口,而不是其他应用程序的窗口。
我试过了:
// this covers other windows
SetWindowPos(&wndTopMost, rectPos.left, rectPos.top, width, height, SWP_SHOWWINDOW);
// this doesn't work
SetWindowPos(&GetParentFrame()->wndTop, rectPos.left, rectPos.top, width, height, SWP_SHOWWINDOW);
有什么想法吗?
Recently I would like to bring a dialog in front of it's father window(always do, no matter its father window gets focus or not) but not topmost. In other words, I only want it cover its father window but not other applications' window.
I've tried:
// this covers other windows
SetWindowPos(&wndTopMost, rectPos.left, rectPos.top, width, height, SWP_SHOWWINDOW);
// this doesn't work
SetWindowPos(&GetParentFrame()->wndTop, rectPos.left, rectPos.top, width, height, SWP_SHOWWINDOW);
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
郑向官,您在原来的帖子中表示:
后来在您的评论中提到:
这是两个完全不同的要求。
如果您希望在父对话框区域中包含第二个对话框,可以通过为第二个对话框设置 WS_CHILD 样式并调用 Create 来实现此目的。这将在父对话框的顶部显示子对话框,并将其保留在父区域内。
要满足第二个要求,您必须将指向父对话框的指针作为 Create 调用中的第二个参数传递,或者在实例化子对话框时传递它。无论哪种方式,您都必须将该指针保存在子对话框中,并使用它来调用父对话框公开的公共函数,或者使用该指针向父对话框发送/发布消息。
Xiangguan Zheng, in your original post you stated:
Later in your comment you mentioned:
These are two completely different requirements.
If you want a second dialog to be contained in the parent dialog area, you can achieve this by setting WS_CHILD style to the second dialog and calling Create. this will show the child dialog over the top of the parent and keep it within the parent area.
to fulfill the second requirement, you will have to pass the pointer to the parent dialog as the second parameter in Create call, or pass it when the child dialog is instantiated. Either way, you will have to save that pointer in the child dialog and use it to either call the public function exposed by the parent or use the pointer to send/post messaged to the parent.