急,怎么判断一个CWnd* pWnd是不是一个CDialog类的指针???

解决方案 »

  1.   

    CDialog* pdlg = STATIC_DOWNCAST(CDialog, pWnd);
    if(pdlg!=NULL)
    {
      //是CDialog类指针
    }
      

  2.   

    if(pWnd->IsKindOf( RUNTIME_CLASS( CDialog ) ) )
      

  3.   

    if(pWnd->IsKindof(RUNTIME_CLASS( CDialog )))
    {
       Do your Work
    }
      

  4.   

    if(pWnd->IsKindOf( RUNTIME_CLASS( CDialog ) ) )
      

  5.   

    以上方法不行。CWND不是从COBJECT中派生的!!!!!!
      

  6.   

    行不行我没试过,不过CWnd和CDialog绝对是从CObject派生来的.
    而且CWnd是CDialog的基类
      

  7.   

    那用
    CDialog* pdlg = static_downcast(CDialog, pWnd);
      

  8.   

    是CDialog* pdlg = static_cast(CDialog, pWnd);
      

  9.   

    CAge a(21);
    CRuntimeClass* prt = a.GetRuntimeClass();
    ASSERT( strcmp( prt->m_lpszClassName, "CAge" )  == 0 );
      

  10.   

    凡是叫zhangyiXXX的我知道都不说……,呵呵,谁让我身边有一个今我讨厌的人和你有一样的名字呢??哈