您的位置:首页 > 其它

Formatted MessageBox/AfxMessageBox

2012-05-01 17:33 246 查看
void AfxMessageBoxFormatted(LPCTSTR pFormatString, ...)
{
va_list vl;
va_start(vl, pFormatString);
CString strFormat;
strFormat.FormatV(pFormatString, vl);
AfxMessageBox(strFormat);
}


void MessageBoxFormatted(HWND hWnd, LPCTSTR pCaption, LPCTSTR pFormatString, ...)
{
va_list vl;
va_start(vl, pFormatString);
TCHAR strFormat[1024];
_vstprintf(strFormat, pFormatString, vl);
::MessageBox(hWnd, strFormat, pCaption,MB_ICONINFORMATION);
}


原文章网址: http://www.codeproject.com/Tips/120013/Formatted-MessageBox-AfxMessageBox

使用示例:

int i = 100;
MessageBoxFormatted(NULL, TEXT("Hello Kitty"), TEXT("%d"), i);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: