CString s( "abcdef" ); ASSERT( s.Find( 'c' ) == 2 ); ASSERT( s.Find( "de" ) == 3 ); Cstring str(“The stars are aligned”); Ing n = str.Find('e',5); ASSERT(n == 12) CString::Left CString Left( int nCount ) const; throw( CMemoryException ); 返回的字符串是前n...
CString str(_T("abcd")); int num = str.Delete(1, 3); //str == a, num == 1 ⑤、字符串的提取: Left、Mid、Right 三个函数分别实现从 CString 对象的 左、中、右 进行字符串的提取操作; CString str(_T("abcd")); CString strResult = str.Left(2); //strResult == ab strResult = ...
①、CString 类对象的初始化: CString str; CString str1(_T("abc")); CString str2 = _T("defg"); TCHAR szBuf[] = _T("kkk"); CString str3(szBuf); CString str4 = szBuf; TCHAR *p = _T("1k2"); //TCHAR * 转换为 CString CString str5(p); CString str6 = p; CString str7(...
22.CString::Empty Void Empty( ); 返回值:没有返回值 清空操作; 示例: CString s( "abc" ); s.Empty(); ASSERT( s.GetLength( ) == 0 ); 23.CString::Find int Find( TCHAR ch ) const; int Find( LPCTSTR lpszSub ) const; int Find( TCHAR ch, int nStart ) const; ...
// CString::Find( TCHAR ch )CString s( "abcdef" );s.Find( 'c' ) 为 2 ;s.Find( "de" ) 为 3 ;// 下面演示第二个例子 // CString::Find(TCHAR ch,int nStart)CString str("The stars are aligned");int n = str.Find('e',5);//从第5个位置开始往后找 n 等于 12 ...
CString s( _T("abcdef") ); ASSERT( s.Left(2) == _T("ab") ); 3.CString::LoadString BOOL LoadString( UINT nID ); throw( CMemoryException ); 返回值:如果加载资源成功则返回非零值;否则返回0。 nID 一个Windows字符串资源ID。 说明:此成员函数用来读取一个由nID标识的Windows字符串资源,并放...
一般可创建一个所有页可见的枚举,如: enum{QUERY_MY_STRING, QUERY_SOMETHING_ELSE,…….} 然后,在一个属性页需要其他属性页中的信息时,使用代码: CString myString; if(lL == QuerySiblings(QUERY_MY_STRING,(LPARAM)&myString)) { ….//获取字符串 } 提供字符串的页处理PSM_QUERYSIBLINGS消息: LRESULT ...
星期三";CString b =a.Left(a.Find(" ",0));CString c =a.Right(a.GetLength()-a.Find(" ...
1.CString::IsEmpty BOOL IsEmpty( ) const; 返回值:如果CString 对象的长度为0,则返回非零值;否则返回0。 说明:此成员函数用来测试一个CString 对象是否是空的。 示例: 下面的例子说明了如何使用CString::IsEmpty。 // CString::IsEmpty 示例 CString s; ...
//截取“$”到“#”的字符串,完善了一些,加入了字符判断,在字符串中发现了作为参照的字母才提取 CString str,sSubStr;int first,last;first= str.Find("$");if (first != -1){ last= str.Find("#",first);} if (first!= -1 && last!= -1){ int nCount = last-first+1 s...