客户端内部的活动对话框是父对话框 [英] Active dialog inside the client are of parent dialog

查看:77
本文介绍了客户端内部的活动对话框是父对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我使用的是VC ++ 6.0,我必须创建一个带有父对话框的对话框,而其他所有对话框都是姐妹对话框.

当父对话框移动或调整大小...或任何其他鼠标操作时,姊妹对话框也应如此.请建议我一些解决问题的方法. Newbee在这里.....如果需要进一步的说明,可以做.... Thanx

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

推荐答案

您的父类是CParentDlg.它有两个孩子CChildDlg1和CChildDlg2.
保持CChildDlg1和CChildDlg2指针类型为CParentDlg类的成员,如下所示
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
class CParentDlg : public CDialog
{
.......
private:
    CChildDlg1* m_pDlg1;
    CChildDlg2* m_pDlg2;
.......
}


现在从CParentDlg类构造函数将m_pDlg1和m_pDlg2初始化为0


now from the CParentDlg class constructor initialze m_pDlg1 and m_pDlg2 to 0

CParentDlg::CParentDlg(..)
{
...
m_pDlg1 = 0; // This is needed
m_pDlg2 = 0; // This is needed
...
}


现在,从CParentDlg类中,一些函数将两个子对话框都创建为无模式对话框


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

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.

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 )
    }
}

如果要在接收此消息的同时执行其他操作,则可以覆盖子对话框的OnMove()方法.您可以使用
做同样的事情 SendMessage()也.但是我更喜欢这种方式

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


这篇关于客户端内部的活动对话框是父对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆