MessageBox 用法

MessageBox 用法
      int MessageBox( LPCTSTR lpszText, LPCTSTR lpszCaption = NULL,
 UINT nType = MB_OK );
参数:
lpszText: 消息正文
lpszCaption:消息框标题(默认没有)
nType:消息框的风格

nType取值:
1.消息框的风格
 ? MB_ICONQUESTION
 ! MB_ICONWARNING
 X MB_ICONHAND or MB_ICONSTOP
 i MB_ICONINFORMATION
2.Button Array:
 按钮 消息框类型

 [YES] [NO] MB_YESNO
 [YES][NO][CANCEL] MB_YESNOCANCEL
 [RETRY][CANCEL] MB_RETRYCANCEL
 [OK] MB_OK
 [OK][CANCEL] MB_OKCANCEL
 [ABORT][RETRY][IGNORE] MB_ABORTRETRYIGNORE
 (想在弹出的对话框中显示的按钮,默认为MB_OK)

Return Values of MessageBox:
 Value Meaning

IDABORT Abort button was selected.
IDCANCEL Cancel button was selected.
IDIGNORE Ignore button was selected
IDNO No button was selected.
IDOK OK button was selected
IDRETRY Retry button was selected.
IDYES Yes button was selected

nType中可以组合使用, for examble:
...
int iRes = MessageBox("你看见消息框了吗?","测试",MB_YESNO | MB_ICONWARNING);
 if( iRes == IDYES )
 MessageBox("看见了就好!");

你可能感兴趣的:(MessageBox 用法)