MFC 有没有弹框(类似MessageBox)函数能像TRACE 一样带参数呢
多谢各位热心帮助,但这些方法我已用过了,现在就想找一种方法能像TRACE一样方便使用,并且最好可以被_NDEBUG编译忽略...
多谢各位热心帮助, 但这些方法我已用过了, 现在就想找一种方法能像TRACE一样方便使用, 并且最好可以被_NDEBUG编译忽略
展开
4个回答
展开全部
没有现成的,也没有必要有现成的,因为可以先用CString格式化完后再输出:
CString str;
str.Format(_T("..."),...);
MessageBox(str, ...);
CString str;
str.Format(_T("..."),...);
MessageBox(str, ...);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-03-28
展开全部
int AfxMessageBox(
LPCTSTR lpszText,
UINT nType = MB_OK,
UINT nIDHelp = 0
);
int AFXAPI AfxMessageBox(
UINT nIDPrompt,
UINT nType = MB_OK,
UINT nIDHelp = (UINT
) -1
);
Parameters
lpszText
Points to a CString object or null-terminated string containing the message to be displayed in the message box.
nType
The style of the message box. Apply any of the message-box styles to the box.
nIDHelp
The Help context ID for the message; 0 indicates the application's default Help context will be used.
nIDPrompt
A unique ID used to reference a string in the string table.
Return Value
Zero if there is not enough memory to display the message box; otherwise, one of the following values is returned:
IDABORT The Abort button was selected.
IDCANCEL The Cancel button was selected.
IDIGNORE The Ignore button was selected.
IDNO The No button was selected.
IDOK The OK button was selected.
IDRETRY The Retry button was selected.
IDYES The Yes button was selected.
If a message box has a Cancel button, the IDCANCEL value will be returned if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing the ESC key has no effect.
Example
// A simple message box, with only the OK button.
AfxMessageBox("Simple message box.");
// A message box that uses a string from a string table
// with yes and no buttons and the stop icon.
// NOTE: nStringID is an integer that contains a valid id of
// a string in the current resource.
AfxMessageBox(nStringID, MB_YESNO|MB_ICONSTOP);
LPCTSTR lpszText,
UINT nType = MB_OK,
UINT nIDHelp = 0
);
int AFXAPI AfxMessageBox(
UINT nIDPrompt,
UINT nType = MB_OK,
UINT nIDHelp = (UINT
) -1
);
Parameters
lpszText
Points to a CString object or null-terminated string containing the message to be displayed in the message box.
nType
The style of the message box. Apply any of the message-box styles to the box.
nIDHelp
The Help context ID for the message; 0 indicates the application's default Help context will be used.
nIDPrompt
A unique ID used to reference a string in the string table.
Return Value
Zero if there is not enough memory to display the message box; otherwise, one of the following values is returned:
IDABORT The Abort button was selected.
IDCANCEL The Cancel button was selected.
IDIGNORE The Ignore button was selected.
IDNO The No button was selected.
IDOK The OK button was selected.
IDRETRY The Retry button was selected.
IDYES The Yes button was selected.
If a message box has a Cancel button, the IDCANCEL value will be returned if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing the ESC key has no effect.
Example
// A simple message box, with only the OK button.
AfxMessageBox("Simple message box.");
// A message box that uses a string from a string table
// with yes and no buttons and the stop icon.
// NOTE: nStringID is an integer that contains a valid id of
// a string in the current resource.
AfxMessageBox(nStringID, MB_YESNO|MB_ICONSTOP);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我一般是用之前格式化下字符串。
追问
类似于CString::Fomat()的格式化串参数
追答
我的意思是你先用 fomat 函数,然后再调用MessageBox。
直接用MessageBox的话,据我所知没有这个函数,但是如果必要的话,你可以写一个自定义函数来实现它。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询