1 void AfxMessageBoxFormatted(LPCTSTR pFormatString, ...) 2 { 3 va_list vl; 4 va_start(vl, pFormatString); 5 CString strFormat; 6 strFormat.FormatV(pFormatString, vl); 7 AfxMessageBox(strFormat); 8 }
1 void MessageBoxFormatted(HWND hWnd, LPCTSTR pCaption, LPCTSTR pFormatString, ...) 2 { 3 va_list vl; 4 va_start(vl, pFormatString); 5 TCHAR strFormat[1024]; 6 _vstprintf(strFormat, pFormatString, vl); 7 ::MessageBox(hWnd, strFormat, pCaption,MB_ICONINFORMATION); 8 }
原文章网址: http://www.codeproject.com/Tips/120013/Formatted-MessageBox-AfxMessageBox
使用示例:
int i = 100;
MessageBoxFormatted(NULL, TEXT("Hello Kitty"), TEXT("%d"), i);