[英]How to concate values in messagebox text using C++ win32 API?
i want to show the messsagebox using win32 API... 我想使用Win32 API显示messsagebox ...
int pwdexpirydays=5; MessageBox(hdlg,(LPCSTR)("Your password will expire in %d days",&pwdexpirydays),(LPCSTR)"Logon Message",MB_OK | MB_ICONINFORMATION);
But i cant get the value... 但是我无法获得价值...
How to i concate the pwdexpirydays
values into "Your password will expire in %d days"
this string. 我如何将
pwdexpirydays
值连接到该字符串"Your password will expire in %d days"
。
您可以使用snprintf
或std :: string进行串联。
If you are doing it a lot you might want to consider a function to make it quick and easy. 如果您经常执行此操作,则可能需要考虑使它快速简便的功能。
int MsgBoxPrint(HWND hWnd, int Type, char *Caption, char *Format, ...)
{
va_list ArgList;
char Temp[4096];
va_start(ArgList, Format);
vsnprintf(Temp, 4096, Format, ArgList);
va_end(ArgList);
return MessageBox(hWnd, Temp, Caption, Type);
}
Then you would call it like so: 然后,您将这样称呼它:
MsgBoxPrint(hdlg, MB_OK | MB_ICONINFORMATION, "Logon Message", \
"Your password will expire in %d days", pwdexpirydays);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.