您的位置:首页 > 编程语言 > C语言/C++

Win32|一个超级喜欢的自定义MessageBox打印代码|c++

2011-11-25 15:12 519 查看
int CDECL MessageBoxPrintf (TCHAR * szCaption, TCHAR * szFormat, ...)
{
	TCHAR   szBuffer [1024] ;
	va_list pArgList ;

	// The va_start macro (defined in STDARG.H) is usually equivalent to:
	// pArgList = (char *) &szFormat + sizeof (szFormat) ;

	va_start (pArgList, szFormat) ;

	// The last argument to wvsprintf points to the arguments

	_vsntprintf (szBuffer, sizeof (szBuffer) / sizeof (TCHAR), 
		szFormat, pArgList) ;

	// The va_end macro just zeroes out pArgList for no good reason

	va_end (pArgList) ;

	return MessageBox (NULL, szBuffer, szCaption, 0) ;
}

调用时:

MessageBoxPrintf (TEXT ("button1 value"), 
			TEXT ("The button1 wMsg %i wParam %i pixels lParam %i  ."),
			wMsg,wParam, lParam) ;


恩,看懂了吗,没有,赶快谷歌吧(不给百度卖广告)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐