Free Web Site - Free Web Space and Site Hosting - Web Hosting - Internet Store and Ecommerce Solution Provider - High Speed Internet
Search the Web

Format a String

VC++ (MFC) Tips :     String


   Key Functions:    void AfxFormatString1( CString& rString, UINT nIDS, LPCTSTR lpsz1 );

   Loads the specified string resource and substitutes the characters "%1" for the string pointed to by lpsz1. . The newly formed string is stored in rString. For example, if the string in the string table is "File %1 not found", and lpsz1 is equal to "C:\MYFILE.TXT", then rString will contain the string "File C:\MYFILE.TXT not found". Look below codes:

AfxFormatString1 ("File %1 not found", "C:\MYFILE.TXT")

   Key Functions:    void AfxFormatString2( CString& rString, UINT nIDS, LPCTSTR lpsz1, LPCTSTR lpsz2 );

   Loads the specified string resource and substitutes the characters "%1" and "%2" for the strings pointed to by lpsz1 and lpsz2. The newly formed string is stored in rString. For example, if the string in the string table is "File %1 not found in directory %2", lpsz1 points to "MYFILE.TXT", and lpsz2 points to "C:\MYDIR", then rString will contain the string "File MYFILE.TXT not found in directory C:\MYDIR". Look following codes:

AfxFormatString2("File %1 not found in directory %2", "MYFILE.TXT", "C:\MYDIR")

   Note:  "Afx" is global prefix in VC++ MFC!
   Note:  If the format characters "%1" or "%2" appear in the string more than once, multiple substitutions will be made. They do not have to be in numerical order.


Copyright (c) 1999 - 2001, robert han, all rigths are reserved.