Click here to Skip to main content
15,909,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using a Dialog and on its OnInitDialog() ,creating another modeless dialog at run time ,the Dialog runs fine but when Parent window is Resize the child window(modelless dialog) is not moving with parent.Please someone help how to make child window (modelless dialog) move with parent Window?

[edit]on behalf of OP
Thanks a lot to all who replied to my query, Finally i achieved what was needed.
I just used ClientToScreen() function to get co ordinates according to parent window and its working fine.
Catch the code below

C++
void CParentDialog::OnMove(int x, int y)
{
    CDialogEx::OnMove(x, y);
    CRect rt;
    GetClientRect(&rt);
    ClientToScreen(&rt);     
    if(::IsWindow (m_pModelles->m_hWnd ))
    {     
        m_pModelles->SetWindowPos(NULL,rt.left+214,rt.bottom-220,(rt.right- 10)-(rt.left+214,222,SWP_SHOWWINDOW|SWP_NOOWNERZORDER|SWP_NOACTIVATE);
    }
}
Posted
Updated 2-Feb-12 2:57am
v2

A modeless dialog is not directly connected to the parent so it will not be signalled when the parent moves or resizes. You will need to add some logic to send it a message when those events occur.
 
Share this answer
 
Comments
sunny chouhan 2-Feb-12 6:25am    
i have tried to set the position of modeless dialog,under OnSize() function of Parent window using ScreenToClient(),
am i doing correct
Richard MacCutchan 2-Feb-12 6:31am    
Possibly, but I am not really sure what you are trying to achieve. Take a look at Creating a Modeless Dialog Box for more information.
Dialogs are by default not docked to their parent window. If you want to implement it, you may add OnSize() and OnMove() handlers to your parent window to send WM_SIZE and WM_MOVE messages to the child dialog.

This can also handle moving of the child window when resizing the parent (which is extraordinary behaviour).
 
Share this answer
 
Comments
sunny chouhan 2-Feb-12 6:45am    
i have tried doing so but child window is not moving
Jochen Arndt 2-Feb-12 6:52am    
Put some TRACE calls to the OnSize() and OnMove() handlers of parent and child window and see what happens.
Member 14575848 19-Sep-19 7:15am    
how to select CFontdlg font size for controls and buttons

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900