AfxFormatString1
使用字符替换为字符串指向由 lpsz1“%1 的所有实例"。nIDS确定的模板字符串资源。
void AfxFormatString1(
CString& rString,
UINT nIDS,
LPCTSTR lpsz1
);
参数
rString
对于将包含该给定的字符串的 CString 对象的引用,该替换执行后。nIDS
该替换将执行模板字符串的资源 ID。lpsz1
将替换格式字符“%1 "在模板字符串的字符串。
备注
该新窗体的字符串在 rString存储。 例如,因此,如果字符串在字符串表中为“%1 文件未找到”和 lpsz1 与“C:\MYFILE.TXT”相等,然后 rString 将包含该字符串“文件未找到的 C:\MYFILE.TXT”。 此功能为格式字符串是有用的发送到消息框和其他窗口。
如果格式字符“%1 "多次出现。该字符串,多个替换将使。
示例
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
}
要求
Header: afxwin.h