标题或许有问题....主要是不知道怎么描述!
我在MFC里面插入一个对话框B,然后嵌入到原对话框A里面。怎么在B的类里面改变A类里面的值!

解决方案 »

  1.   

    GetParent()->GetDlgItem(IDC_EDIT1)->SetWindowText("hello");
      

  2.   

    B有个构造函数
    B(CWnd *pParent);
    CWnd *parent;
    B::B(CWnd *pParent)
    {
    parent = (B*) pParent;
    }
      

  3.   


    // 在子对话框中获取父窗口的指针
    CParentDlg* pParentDlg = (CParentDlg*)GetParent();
    if (pParentDlg != NULL)
    {
        pParentDlg->.....
    }(1)首先,创建子窗口时要指定父窗口;
    (2)要看你修改的变量的属性是public还是private的,public可以直接修改;private则需要写一个修改值的public接口,调用接口就可以了.
      

  4.   

    先获取父窗口指针,然后根据指针进行操作
    比如
    CParentDlg* pDlg = (CParentDlg*)GetParent();
    根据pDlg值灵活操作