我想得到一个属性页中控件的指针,作如下操作:

IMPLEMENT_DYNCREATE(VqSetTran, CPropertyPage)VqSetTran::VqSetTran() : CPropertyPage(VqSetTran::IDD)
{
CComboBox * pComboBox=NULL;
pComboBox=(CComboBox*)GetDlgItem(IDC_COMBO_TRAN_NAME,( HWND* )GetSafeHwnd());
pComboBox->AddString("abc");
}

编译时提示:
error C2440: 'type cast' : cannot convert from 'void' to 'class CComboBox *'      Expressions of type void cannot be converted to other types
呵呵,不好意思,请指教错误处在哪里?

解决方案 »

  1.   

    要在对话框的OnInitDialog() 中写这些代码VqSetTran::VqSetTran() : OnInitDialog()
    {
    CComboBox * pComboBox=NULL;
    pComboBox=(CComboBox*)GetDlgItem(IDC_COMBO_TRAN_NAME,( HWND* )GetSafeHwnd());
    pComboBox->AddString("abc");
    }
      

  2.   

    VqSetTran::VqSetTran() : CPropertyPage(VqSetTran::IDD)
    {
    CComboBox * pComboBox=NULL;
             //这句这样就够了
    pComboBox=(CComboBox*)GetDlgItem(IDC_COMBO_TRAN_NAME);
    pComboBox->AddString("abc");
    }