囧。。头文件: CListCtrl* m_listCtrl; 构造函数 :m_listCtrl(NULL);OnInitialUpdate: m_listCtrl = (CListCtrl*) GetDlgItem(IDC_LIST); // do something到此,显示正常foo() { //m_listCtrl = (CListCtrl*) GetDlgItem(IDC_LIST); 加上这句就OK int index = m_listCtrl->GetItemCount(); // 不加上面这句就报错 }
CWnd* GetDlgItem( int nID ) const;void CWnd::GetDlgItem( int nID, HWND* phWnd ) const;Return ValueA pointer to the given control or child window. If no control with the integer ID given by the nID parameter exists, the value is NULL. The returned pointer may be temporary and should not be stored for later use.
构造函数 :m_listCtrl(NULL);OnInitialUpdate:
m_listCtrl = (CListCtrl*) GetDlgItem(IDC_LIST);
// do something到此,显示正常foo() {
//m_listCtrl = (CListCtrl*) GetDlgItem(IDC_LIST); 加上这句就OK
int index = m_listCtrl->GetItemCount(); // 不加上面这句就报错
}