MeshTransform
MeshTransform

Reputation: 29

MFC non-modal dialog front but not topmost

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?

Upvotes: 0

Views: 260

Answers (1)

JohnCz
JohnCz

Reputation: 1609

Xiangguan Zheng, in your original post you stated:

I only want it cover its father window but not other applications' window.

Later in your comment you mentioned:

I want do edit the father dialog by clicking the buttons on the child dialog.

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.

Upvotes: 0

Related Questions