void CTask1App::OnOK()
{
int index=m_listbox.GetCurSel();
if(index!=LB_ERR)
{
m_listbox.GetText(index,m_selected);
}
else
{
m_selected=" ";
}
CDialog::OnOK();
}void CTask1App::OnCancel()
{
m_selected=" ";
CDialog::OnCancel();
}编译后就是:e:\c++\task1\task1.cpp(166) : error C2065: 'm_listbox' : undeclared identifier
e:\c++\task1\task1.cpp(166) : error C2228: left of '.GetCurSel' must have class/struct/union type
e:\c++\task1\task1.cpp(169) : error C2228: left of '.GetText' must have class/struct/union type
e:\c++\task1\task1.cpp(169) : error C2065: 'm_selected' : undeclared identifier
e:\c++\task1\task1.cpp(173) : error C2440: '=' : cannot convert from 'char [2]' to 'int'
...........................
怎么解决啊
{
int index=m_listbox.GetCurSel();
if(index!=LB_ERR)
{
m_listbox.GetText(index,m_selected);
}
else
{
m_selected=" ";
}
CDialog::OnOK();
}void CTask1App::OnCancel()
{
m_selected=" ";
CDialog::OnCancel();
}编译后就是:e:\c++\task1\task1.cpp(166) : error C2065: 'm_listbox' : undeclared identifier
e:\c++\task1\task1.cpp(166) : error C2228: left of '.GetCurSel' must have class/struct/union type
e:\c++\task1\task1.cpp(169) : error C2228: left of '.GetText' must have class/struct/union type
e:\c++\task1\task1.cpp(169) : error C2065: 'm_selected' : undeclared identifier
e:\c++\task1\task1.cpp(173) : error C2440: '=' : cannot convert from 'char [2]' to 'int'
...........................
怎么解决啊
怎么是在类CTask1App中的成员函数呢?,难道你对话框所在的类叫这个?
你的这两个函数应该是你的对话框的函数,你方错位置了。