想把CDialog类的指针,就是我们常用的this
当为参数来传,我是不是应该用CWnd *ParentWnd
来写参数啊,但用了老是出错误啊,帮帮忙!

解决方案 »

  1.   

    把this换成GetOwner()试一下!!
      

  2.   

    楼主好像对this指针的意义好像有点不太明白;
    The this pointer is a pointer accessible only within the nonstatic member functions of a class, struct, or union type. It points to the object for which the member function is called. Static member functions do not have a this pointer.
    在基于对话框的应用程序当中, 在C**Dgl中,this代表的是这个类对象的指针;而不是他的基类CDialog的指针;
      

  3.   

    是我错了啊,但我怎样来传this啊,就是传时的参数怎样啊是不是我
    上面的CWnd *ParentWnd 啊
      

  4.   

    你是要得到一个Dialog的指针吗?
    可以用这个:
    CMyDialog* dlg=(CMyDialog*)AfxGetMainWnd();
    而不是把this传出去的。
      

  5.   

    this只在类内可见,类外是不可见的,所以要把一个CDialog类的指针传递给一个非本类的成员函数,就不能用this。