我的对话框应用程序基于CDialog_Base类,我向这个程序加入了2个资源对话框。分别为类CDialog1和CDialog2,然后我在CDialog_Base类中申明了类CDialog1和CDialog2的2个对象m1和m2,好了,我想实现的功能是在CDialog2的函数中用m1(在CDialog_Base类中定义)来控制m1自己的变化,但是你知道,m1是不被承认的,所以。。我该怎么办?就是说,我该怎么控制m1?有人说用友元函数,但是我试过了,不行。还有没有别的方法,比如怎么获得父窗口的指针??这个函数我不知道,有谁可以指点1,2? 谢谢!

解决方案 »

  1.   

    CWnd::GetParent  
    CWnd* GetParent( ) const;Return ValueIdentifies the parent window if the member function is successful. Otherwise, the value is NULL, which indicates an error or no parent window. The returned pointer may be temporary and should not be stored for later use.
      

  2.   

    另外,this是指向自己的指針,你應該知道吧。
      

  3.   

    干脆动态创建试试?或者:AfxGetApp()-m1 得到M1的指针进行操作
      

  4.   

    程序的子对话框窗口中如何调用ShellExecute,代码如下
     ShellExecute(GetParent()->m_hWnd, "explore", "http://www.tsingmei.com", NULL, NULL, SW_SHOWNORMAL); 函数的第一个参数要求是父对话框的句柄,但是就是不执行!我该怎么办??
      

  5.   

    在 DIALOG2的头文件中加入DIALOG1的前视声明:
    class CDialog1;