AfxFormatString2
Visual Studio 2010
Loads the specified string resource and substitutes the characters "%1" and "%2" for the strings pointed to by lpsz1 and lpsz2.
void AfxFormatString2( CString& rString, UINT nIDS, LPCTSTR lpsz1, LPCTSTR 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"
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.
void DisplayFileNotFoundMessage(LPCTSTR pszFileName, LPCTSTR pszDirectory) { CString strMessage; // The IDS_FILENOTFOUND string resource contains "Error: File %1 not // found in directory %2" AfxFormatString2(strMessage, IDS_FILENOTFOUND2, pszFileName, pszDirectory); // In the previous call, substitute the actual file and directory // names into the message string AfxMessageBox(strMessage); // Display the error message }