AfxFormatString1
Visual Studio 2012
Substitutes the string pointed to by lpsz1 for any instances of the characters "%1" in the template string resource identified by nIDS.
void AfxFormatString1( CString& rString, UINT nIDS, LPCTSTR 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". This function is useful for formatting strings sent to message boxes and other windows.
If the format characters "%1" appear in the string more than once, multiple substitutions will be made.
void DisplayFileNotFoundMessage(LPCTSTR pszFileName) { CString strMessage; // The IDS_FILENOTFOUND string resource contains "Error: File %1 not found" AfxFormatString1(strMessage, IDS_FILENOTFOUND, pszFileName); // In the previous call, substitute the actual file name for the // %1 placeholder AfxMessageBox(strMessage); // Display the error message }