Formatted MessageBox/AfxMessageBox
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);
posted on 2012-05-01 17:33 wangyao1052 阅读(367) 评论(0) 编辑 收藏 举报