【错误】 error C2039:'SetWindowTextA' : is not a member of 'CString'
error C2039: 'SetWindowTextA' : is not a member of 'CString'
d:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'函数
缘由是由于在绑定成员变量时设置的“m_OpenPath”的Category为Value,而不是Control,CString的对象里没有SetWindowText的函数,在CStatic的对象里有SetWindowText函数spa
/* 在对应的有文件中的定义 */ CStatic m_SavaPath; // Yes CString m_OpenPath; // Error
【警告】warning C4018: '<' : signed/unsigned mismatch
这里就直接贴代码了,出现这个警告的缘由是由于类型不匹配,GetLenth返回的是size_tcode
void CMy6_7WindowsDlg::OnOpen() { CFileDialog dlg( TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"All Files(*.TXT)|*.TXT||",AfxGetMainWnd() ); CString strPath,strText = ""; if( dlg.DoModal( ) == IDOK ) { strPath = dlg.GetPathName( ); m_OpenPath.SetWindowText( strPath ); //m_OpenPath = strPath; // 不能显示 //MessageBox( strPath ); // Test CFile file( strPath,CFile::modeRead ); char read[10000]; file.Read( read,10000 ); // 6_7Windows通用对话框Dlg.cpp(189) : warning C4018: '<' : signed/unsigned mismatch // for( int i = 0;size_t(i) < file.GetLength( );i++ ) // 这样就不会有警告了 /* 这是个警告信息,GetLength函数返回的类型是size_t,实质是个无符号整型,能够在申明i变量时申明为:size_t i,就能够了 或是在条件里判断时把i强制转型为size_t,如:for( int i = 0;size_t(i) < file.GetLength( );i++ )便可 */ for( int i = 0;i < file.GetLength( );i++ ) { strText += read[i]; } file.Close( ); m_FileText.SetWindowText( strText ); } }