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);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-11-17
  • 2021-11-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-12-06
  • 2021-10-21
  • 2022-02-08
相关资源
相似解决方案