是无模式的,小弟不才小第试过定义指针(public)指向Dialog2(Dialog2* as) 从Dialog1中的按钮中调用as->m_list1.SetSel(-1,false);,然后就不知道该怎末办了,编译时有错误。

解决方案 »

  1.   

    我在Dialog1.h中的public:中定义Dialog* as;
    然后从Dialog2.cpp中使用 as->m_list1.SetSel(-1,true);
    我在Dialog2.cpp中已定义#include "Dialog1.h"
    为什末编译时还出错?
    D:\book\R\Dialog2.cpp(49) : error C2065: 'as' : undeclared identifier
    D:\book\R\Dialog2.cpp(49) : error C2227: left of '->m_list1' must point to class/struct/union
    D:\book\R\Dialog2.cpp(49) : error C2228: left of '.SetSel' must have class/struct/union type
      

  2.   

         你那样定义是错误的,可以查看msdn ,CDialog( LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL );  你可以在Dialog2类中定义一个变量Dialog1 *as;
      然后在初始化时把Dialog1的一个对象指针传给他就行了,
      pi譬如:
       Dialog1 *s;
       ... ....
        Dialog2.as=s;
       ......
      在Dialog2里用as->m_list1.SetSel(-1,false);
      

  3.   

    my god
    呜呜呜
    我还是不明白

    可怜自己水平太浅那
    这位大哥如果您有时间就写个例程mail过来吧
    [email protected]
    我给您分数的!