当前位置: 移动技术网 > 科技>软件教程>编程开发 > 利用字符串资源显示MessageBox

利用字符串资源显示MessageBox

2009年06月11日  | 移动技术网科技  | 我要评论
利用字符串资源显示MessageBox
c++代码
//////////////////////////////////////////////////////////////////////////
// infobox
// 利用字符串资源显示messagebox
// hparent - 父窗口句柄
// uidstring - 字符串资源id
// lpszcaption - messagebox窗口标题
// utype - 同messagebox最后一个参数
// 返回值:同messagebox
// 备注:
// 1.可以像wsprintf那样加入可选附加参数;
// 2.最大字符串长度为max_path。
//////////////////////////////////////////////////////////////////////////
int cdecl infobox( hwnd hparent, uint uidstring, lpctstr lpszcaption, uint utype, ... )
{
va_list arglist;
tchar str[max_path], strload[max_path];
va_start( arglist, utype );
loadstring( null, uidstring, strload, max_path );
wvsprintf( str, strload, arglist );
va_end( arglist );
return messagebox( hparent, str, lpszcaption, utype );
}
补充两点:第一,字符串资源是一种很好用的资源,利用字符串资源显示messagebox可以使消息文本容易更改;第二,字符串有长度的限制,如果希望突破这种限制,可以参考mfc中cstring::format的代码对字符串的长度进行动态计算。


如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网