Click here to Skip to main content
15,899,126 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I m using VC++ 6.0, I have to create multiple dialog with a parent dialog and all other being sister dialog.

When parent dialog is moved or resized...or any other mouse operation, same should happen with sister dialog. Please suggest me some way to get dis done. Newbee here.....IF needed further clarification can be done....Thanx
Posted
Updated 15-Dec-11 18:29pm
v2

1 solution

your parent class is CParentDlg. It has two children CChildDlg1 and CChildDlg2.
Keep CChildDlg1 and CChildDlg2 pointer type as members of CParentDlg class as below
C++
class CParentDlg : public CDialog
{
.......
private:
    CChildDlg1* m_pDlg1;
    CChildDlg2* m_pDlg2;
.......
}

now from the CParentDlg class constructor initialze m_pDlg1 and m_pDlg2 to 0
C++
CParentDlg::CParentDlg(..)
{
...
m_pDlg1 = 0; // This is needed
m_pDlg2 = 0; // This is needed
...
}

now from the CParentDlg class some function create both the children dialog as modeless dialog

C++
void CParentDlg::ChildrenCreation()
{
    .......
    m_pDlg1 = new CDialog;
    m_pDlg1->Create( IDD_CHILD1 );
    m_pDlg1->ShowWindow( SW_SHOW );
    m_pDlg1->UpdateWindow();
    .......
    m_pDlg2 = new CDialog;
    m_pDlg2->Create( IDD_CHILD1 );
    m_pDlg2->ShowWindow( SW_SHOW );
    m_pDlg2->UpdateWindow();

}

now i just show you the example to move the window. For resizing and all other mouse operation u can try urself similarly.
C++
void CParentDlg::OnMove( int x, int y )
{
    .....
    if( m_pDlg1 != 0 ) // This checking in needed. Or it will crash when we invoke the parent dialog
    {
        m_pDlg1->MoveWindow( urDesiredx1, urDesiredy1, urDesiredWidth, urDesiredHeight )
    }
    if( m_pDlg2 != 0 ) // This checking in needed. Or it will crash when we invoke the parent dialog
    {
        m_pDlg2->MoveWindow( urDesiredx1, urDesiredy1, urDesiredWidth, urDesiredHeight )
    }
}
You can overrride the OnMove() method of your children dialog if you want to do something in addition on receiving this message. You can do the same using
SendMessage() also. But i prefer this way
 
Share this answer
 

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