各位大哥:
程序如下:
void CDtestDlg::Ontest()
{
// TODO: Add your control notification handler code here
int a=10, b=11;
CString ttt;
ttt.Format("a = %d, b =%d", a, b);
MessageBox(ttt);
}请问如何将
CString ttt;
ttt.Format("a = %d, b =%d", a, b);
MessageBox(ttt);
这3句话写成一个通用的宏,宏输入格式要求类似与TRACE这个宏,作用同以上3句话。
程序如下:
void CDtestDlg::Ontest()
{
// TODO: Add your control notification handler code here
int a=10, b=11;
CString ttt;
ttt.Format("a = %d, b =%d", a, b);
MessageBox(ttt);
}请问如何将
CString ttt;
ttt.Format("a = %d, b =%d", a, b);
MessageBox(ttt);
这3句话写成一个通用的宏,宏输入格式要求类似与TRACE这个宏,作用同以上3句话。
ttt.Format("a = %d, b =%d", (Arg_a), (Arg_b));\
AfxMessageBox(ttt);这样不知道行不行~
没调试过不确定哦^_^#
TRACE是直接定义为::AfxTrace也就是
void AFX_CDECL AfxTrace(LPCTSTR lpszFormat, ...);
所以除非你自己写一个带可变参数的函数
否则恐怕难以做到吧
{\
ttt.format ("a = %d,b = %d",a,b);\
MessageBox (ttt);\
}
#define MSG_OUT(Arg_a, Arg_b) CString ttt;\
ttt.Format("a = %d, b =%d", (Arg_a), (Arg_b));\
AfxMessageBox(ttt);这样不知道行不行~
没调试过不确定哦^_^#写成
#define MSG_OUT(Arg_a, Arg_b) {CString ttt;\
ttt.Format("a = %d, b =%d", (Arg_a), (Arg_b));\
AfxMessageBox(ttt);}
CString ttt;只能在{}起作用,不然可能回造成重复声明错误。
这句话
CString ttt;\是无法通过编译的
应该还是an_bachelor(一個單身漢)说的可能性比较高(实现实在),继续学习研究
#define MSG_OUT(Arg_a, Arg_b) CString s1;
s1.Format("a = %d, b =%d", (Arg_a), (Arg_b));
AfxMessageBox(s1);
ttt.Format("a = %d, b =%d", (a), (b));\
MessageBox(ttt);