home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SRC / WINSTR.CP_ / WINSTR.CP
Encoding:
Text File  |  1993-02-08  |  2.5 KB  |  91 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library. 
  2. // Copyright (C) 1992 Microsoft Corporation 
  3. // All rights reserved. 
  4. //  
  5. // This source code is only intended as a supplement to the 
  6. // Microsoft Foundation Classes Reference and Microsoft 
  7. // QuickHelp and/or WinHelp documentation provided with the library. 
  8. // See these sources for detailed information regarding the 
  9. // Microsoft Foundation Classes product. 
  10.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFX_CORE1_SEG
  14. #pragma code_seg(AFX_CORE1_SEG)
  15. #endif
  16.  
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char BASED_CODE THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23. // Windows extensions to strings
  24.  
  25. BOOL CString::LoadString(UINT nID)
  26. {
  27.     ASSERT(nID != 0);       // 0 is an illegal string ID
  28.     // NOTE: resource strings limited to 255 characters
  29.     char szBuffer[256];
  30.     UINT nSize;
  31.     if ((nSize = _AfxLoadString(nID, szBuffer)) == 0)
  32.         return FALSE;
  33.     AssignCopy(nSize, szBuffer);
  34.     return TRUE;
  35. }
  36.  
  37. void CString::AnsiToOem()
  38. {
  39.     ::AnsiToOem(m_pchData, m_pchData);
  40. }
  41.  
  42. void CString::OemToAnsi()
  43. {
  44.     ::OemToAnsi(m_pchData, m_pchData);
  45. }
  46.  
  47. #ifndef _AFXDLL     // non-DLL version
  48. int PASCAL _AfxLoadString(UINT nID, char* szBuf)
  49. {
  50.     ASSERT(AfxIsValidAddress(szBuf, 256));  // must be big enough for 256 bytes
  51. #ifdef _DEBUG
  52.     // LoadString without annoying warning from the Debug kernel if the
  53.     //  segment containing the string is not present
  54.     if (::FindResource(AfxGetResourceHandle(),
  55.        MAKEINTRESOURCE((nID>>4)+1), RT_STRING) == NULL)
  56.         return 0; // not found
  57. #endif //_DEBUG
  58.     return ::LoadString(AfxGetResourceHandle(), nID, szBuf, 255);
  59. }
  60. #endif //!_AFXDLL
  61.  
  62. /////////////////////////////////////////////////////////////////////////////
  63.  
  64. BOOL AFXAPI AfxExtractSubString(CString& rString, LPCSTR lpszFullString,
  65.     int iSubString, char chSep)
  66. {
  67.     if (lpszFullString == NULL)
  68.         return FALSE;
  69.  
  70.     while (iSubString--)
  71.     {
  72.         lpszFullString = _AfxStrChr(lpszFullString, chSep);
  73.         if (lpszFullString == NULL)
  74.         {
  75.             rString.Empty();        // return empty string as well
  76.             return FALSE;
  77.         }
  78.         lpszFullString++;       // point past the separator
  79.     }
  80.     LPCSTR lpchEnd = _AfxStrChr(lpszFullString, chSep);
  81.     int nLen = (lpchEnd == NULL) ?
  82.         lstrlen(lpszFullString) : (int)(lpchEnd - lpszFullString);
  83.     ASSERT(nLen >= 0);
  84.     _fmemcpy(rString.GetBufferSetLength(nLen), lpszFullString, nLen);
  85.     return TRUE;
  86. }
  87.  
  88.  
  89. /////////////////////////////////////////////////////////////////////////////
  90.  
  91.