-
December 28th, 2016, 11:02 PM
#1
Moving Parent Dialog while moving Child Dialog MFC
How to move the parent Dialog while moving the child dialog.
Child Dialog is shown infront of parent and covers the parent dialog. I want to move the parent while child is moving so that parent is just invisible to the user.
-
January 13th, 2017, 03:09 AM
#2
Re: Moving Parent Dialog while moving Child Dialog MFC
Please detail you issue: what kind of app is (Dialog based, MDI, etc.), and child window are modal, are spread whole screen, etc. Then, you get some answers.
-
January 18th, 2017, 11:54 AM
#3
Re: Moving Parent Dialog while moving Child Dialog MFC
Hopefully, the OP is still waiting an answer...
Handle WM_MOUSEMOVE in child dialog and do like in the following example:
Code:
void CChildDialog::OnMouseMove(UINT nFlags, CPoint point)
{
__super::OnMouseMove(nFlags, point);
CWnd* pWndParent = GetParent();
ASSERT_VALID(pWndParent);
ClientToScreen(&point);
if (DragDetect(point))
{
CPoint pointNew;
::GetCursorPos(&pointNew);
CRect rcParent;
pWndParent->GetWindowRect(rcParent);
pWndParent->SetWindowPos(NULL,
rcParent.left + (pointNew.x - point.x),
rcParent.top + (pointNew.y - point.y),
0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
}
}
NOTE: it's not clear if you refer to a child dialog (having WS_CHILD / WC_CHILDWINDOW style set) or a top-level dialog which can have or can have not an owner but has never a parent.
See:
-
January 21st, 2017, 11:04 AM
#4
Re: Moving Parent Dialog while moving Child Dialog MFC
Another (but almost similar) way is handling WM_WINDOWPOSCHANGED (or WM_WINDOWPOSCHANGING) message and check the absence of SWP_NOMOVE flag... Then - move the parent window the same way as Ovidiu suggested for his solution (the call DragDetect(...) won't be needed in that case).
Note that this solution will also work for the case when the child dialog would be moved using some code..
Victor Nijegorodov
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|