现在的位置: 首页 > 综合 > 正文

MessageBox()方法使用

2013年10月14日 ⁄ 综合 ⁄ 共 2279字 ⁄ 字号 评论关闭

 MessageBox (NULL, TEXT ("Hello World"), TEXT ("Hello2"), MB_OK);

MessageBox函数原型如下:
int MessageBox (HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
第1个参数是顶层窗口的句柄,它是消息窗口的父窗口。目前我们把这个参数置为NULL,因为Hello2还没有任何其它窗口。第2个参数是准备显示在窗口里的文字。注意传入的字符串是用TEXT宏包裹的,确保它能够编译成Unicode版本。第3个参数lpCaption是显示在窗口标题栏的文字。最后一个参数uType是一系列标志位,规定消息框如何显示在屏幕上。标志位规定了消息框中按扭的数量和类型,规定了图标的类型以及消息框窗口的风格设置。

表1-1列出了Windows CE下有效的标志位
表1-1: 默认标志位

 

标志位                                                                       按钮或者图标
 
用于按钮


  
MB_OK                                                                       OK
 


MB_OKCANCEL                                                              OK and Cancel
 


MB_RETRYCANCEL                                                         Retry and Cancel
 


MB_YESNO                                                                   Yes and No
 


MB_YESNOCANCEL                                                         Yes, No, and Cancel
 


MB_ABORTRETRYIGNORE                                                Abort, Retry, and Ignore
 


用于图标
  


 
MB_ICONEXCLAMATION, MB_ICONWARNING                         Exclamation point


 
MB_ICONINFORMATION, MB_ICONASTERISK                         Lower case i within a circle


 
MB_ICONQUESTION                                                          Question mark
 


MB_YESNO                                                                 Yes and No


 
MB_ICONSTOP, MB_ICONERROR, MB_ICONHAND                Stop sign
 


MB_DEFBUTTON1                                                         First button
 


MB_DEFBUTTON2                                                        Second button
 


MB_DEFBUTTON3                                                       Third button
 


For Window Styles: 
  


MB_SETFOREGROUND                                                    Bring the message box to the foreground.
 


MB_TOPMOST                                                                Make the message box the topmost window.
 


 

MessageBox的返回值指出用户按了哪个按扭。

返回值如下:


IDOK                                      OK button pressed
 


IDYES                                    Yes button pressed
 


IDNO                                    No button pressed


 
IDCANCEL                              Cancel button pressed or Esc key pressed


 
IDABORT                                 Abort button pressed
 


IDRETRY                                Retry button pressed
 


IDIGNORE                              Ignore button pressed
 

 

抱歉!评论已关闭.