MessageBox的完整用法

作者在 2007-04-29 20:50:00 发布以下内容
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 s of MessageBox:
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("看见了就好!");
C# | 阅读 1309 次
文章评论,共0条
游客请输入验证码
最新评论