函数原型1
int AfxMessageBox(
LPCTSTR lpszText,
UINT nType = MB_OK,
UINT nIDHelp = 0
);
lpszText:弹窗内容
nType :弹窗类型和按钮类型进行或,比如询问框等
函数原型2
int AFXAPI AfxMessageBox(
UINT nIDPrompt,
UINT nType = MB_OK,
UINT nIDHelp = (UINT) –1
);
nIDPrompt:为文本字符串ID
1.AfxMessageBo是一个全局函数,不需要对应着一个窗口类,不能控制消息框标题,常用于调试程序时的内部数据输出或警告;
2.MessageBox比较正式,常用在要提交的应用程序版本中,可以控制标题内容而不必采用含义不明的可执行文件名为标题
MB_ABORTRETRYIGNORE :Abort、Retry、Ignore按钮
MB_OK :OK按钮
MB_OKCANCEL :OK、Cancel按钮
MB_RETRYCANCEL :Retry、Cancel按钮
MB_YESNO :Yes、No按钮
MB_YESNOCANCEL :Yes、No、Cancel按钮
MB_ICONINFORMATION :i图标,表示提示
MB_ICONEXCLAMATION :惊叹号图标,表示警告
MB_ICONSTOP :手形图标,表示警告或严重错误
MB_ICONQUESTION :问号图标,表示疑问
IDABORT、IDCANCEL、IDIGNORE、IDNO、IDOK 、IDRETRY、IDYES
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
int AfxMessageBox(
LPCTSTR lpszText,
UINT nType = MB_OK,
UINT nIDHelp = 0
);
AfxMessageBox(_T("加载失败"),MB_OK |MB_ICONEXCLAMATION );
int nRet = AfxMessageBox(_T("加载失败"),MB_YESNO|MB_ICONQUESTION);
if(IDYES == nRet){
AfxMessageBox(_T("是"),MB_ICONINFORMATION );
}else{
AfxMessageBox(_T("否"),MB_ICONINFORMATION );
}
int nRet = AfxMessageBox(_T("加载失败"),MB_ABORTRETRYIGNORE );
if(IDABORT == nRet ){
AfxMessageBox(_T("中止"),MB_ICONINFORMATION );
}
else if(IDRETRY == nRet){
AfxMessageBox(_T("重试"),MB_ICONINFORMATION );
}
else if(IDIGNORE == nRet){
AfxMessageBox(_T("忽略"),MB_ICONINFORMATION );
}
int nRet = AfxMessageBox(_T("加载失败"),MB_OKCANCEL|MB_ICONQUESTION );
if(IDOK == nRet ){
AfxMessageBox(_T("确定"),MB_ICONINFORMATION );
}
else if(IDCANCEL == nRet){
AfxMessageBox(_T("取消"),MB_ICONINFORMATION );
}
int nRet = AfxMessageBox(_T("加载失败"),MB_RETRYCANCEL |MB_ICONQUESTION );
if(IDRETRY == nRet ){
AfxMessageBox(_T("重试"),MB_ICONINFORMATION );
}
else if(IDCANCEL == nRet){
AfxMessageBox(_T("取消"),MB_ICONINFORMATION );
}
int nRet = AfxMessageBox(_T("加载失败"),MB_YESNOCANCEL |MB_ICONQUESTION );
if(IDYES == nRet ){
AfxMessageBox(_T("是"),MB_ICONINFORMATION );
}
if(IDNO == nRet ){
AfxMessageBox(_T("否"),MB_ICONINFORMATION );
}
else if(IDCANCEL == nRet){
AfxMessageBox(_T("取消"),MB_ICONINFORMATION );
}
int AFXAPI AfxMessageBox(
UINT nIDPrompt,
UINT nType = MB_OK,
UINT nIDHelp = (UINT) –1
);
这个函数里面的nIDPrompt可用string table里面的ID
AfxMessageBox(IDS_STRING102,MB_OK |MB_ICONEXCLAMATION );