BOOL CShangweijiDlg::IsExistence(CString str_ip)
    {
int item;
int i;
    CString str;//报警器isOpen(是否打开监控)
    item=m_listroom.GetItemCount();//获取列表控件的总项目数,返回值为int
for(i=0;i<item;i++)
{
    if(str_ip==m_listroom.GetItemText(i,1))//i为选定的行索引,后面为列索引
{
           if(m_listroom.GetItemText(i,3)=="开启")
   {
   
      
      str.Format("%d",i);
   AfxMessageBox(str);
     return TRUE;
   }
}
}
     return FALSE;}
该函数在定义为CShangweijiDlg类中的
private: 
static  BOOL IsExistence(CString str_ip);
其中m_listroom为CShangweijiDlg这个窗口中的,一个列表控件CListCtrl的关联控件变量
但是运行时:
E:\shangweiji\shangweijiDlg.cpp(713) : error C2228: left of '.GetItemCount' must have class/struct/union type
E:\shangweiji\shangweijiDlg.cpp(716) : error C2228: left of '.GetItemText' must have class/struct/union type
E:\shangweiji\shangweijiDlg.cpp(718) : error C2228: left of '.GetItemText' must have class/struct/union type
执行 cl.exe 时出错.
希望有人能详细解答下

解决方案 »

  1.   

    m_listroom在头文件中是怎么定义的,是不是漏了什么引用
      

  2.   

    静态函数中只能调用静态成员变量!static BOOL IsExistence(CString str_ip);
    去掉static
      

  3.   

    static BOOL IsExistence(CString str_ip);楼上眼尖, static不能调用非静态的数据成员
      

  4.   

     去掉static后,在另一个if(IsExistence(str_ip))
     {}会出错
    E:\shangweiji\shangweijiDlg.cpp(252) : error C2352: 'CShangweijiDlg::IsExistence' : illegal call of non-static member function
            e:\shangweiji\shangweijidlg.h(66) : see declaration of 'IsExistence'
    执行 cl.exe 时出错.
      

  5.   

    不加static会出错的,因为有传递一个变量给他
      

  6.   

    其中if(IsExistence(str_ip))
    在函数static DWORD WINAPI RecvProc(LPVOID lpParameter);里面哦
      

  7.   

    去掉static后,在另一个if(IsExistence(str_ip))
     {}会出错
    另外一个地方如果是静态函数,将他改为非静态
      

  8.   

    如果不用static如何实现if(IsExistence(str_ip))
    在函数static DWORD WINAPI RecvProc(LPVOID lpParameter);里面哦