Reputation: 1254
Really need some help How do I move the parent dialog when dragging the child dialog?
I have it so that when I drag the parent dialog, the child dialog is also moved, but not the reverse relationship.
Any help would be greatly appreciated, thanks!
My Main dialog.cpp:
void MainDialog::OnMove(int x, int y)
{
CDialog::OnMove(x, y);
m_pDialog->SetWindowPos(&wndTop, x, y, 50, 50, SWP_NOZORDER); // child dialog
}
BEGIN_MESSAGE_MAP(CTranslucentDialog, CDialog)
//AFX_MSG_MAP
ON_WM_ERASEBKGND()
ON_WM_MOVE()
ON_WM_SIZE()
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
Thanks, I was able to get it to work by creating a handler for NCHITTEST and returning HTTRANSPARENT.
LRESULT CGadgetStandardDialog::OnNcHitTest(CPoint point)
{
return HTTRANSPARENT;
}
Upvotes: 0
Views: 1013
Reputation: 15365
The Problem is that the Mouse Input is consumed by the child. So clicking in a child window and dragging there, usually selects some data in the child (in an edit Control). Or for a static Control the mouse Input is forwarded to the parent.
So you. Need to decide... You always have the posibility to handle this in WM_NCHITTEST and return HTCAPTION, or you allow the parent to handle this in retunring HTTRANSPARENT.
BTW: If you want to implement moving a window with the mouse in the Client area too just handle WM_NCHITTEST and return HTCAPTION. there is no Need to implement a mouse movehandler and doing it by yourself.
Upvotes: 2