Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Usage of messagebox in C language
Usage of messagebox in C language

The function prototype of the message box:

int MessageBox(HWND hwnd,LPCTSTR lpsztext,LPCSTR lpsztitle,UINT ustyle);

The message box function has 4 parameters :

The first parameter is the handle of the parent window. Is NULL, indicating that the message box has no parent window.

The second parameter is a pointer to the string to be displayed

The third parameter is the title of the message box itself.

The fourth parameter specifies the content and shape of the message box (that is, the message box has several buttons, text alignment, etc., and can be combined in more than 20 attribute values)

The fourth parameter of MessageBox can be a set of constant combinations defined in WINUSER.H whose prefix starts with MB_.

You can use the "or" (|) operator of C language to Select one constant from each of the three groups shown below and combine them to specify the content and shape of the message box:

Which buttons to display:

#define MB_OK 0X00000000L

#define MB_OKCANCEL 0X00000001L

#define MB_ABORTRERYGNORE 0X00000002L

#define MB_YESNOCANCEL 0X00000003L

#define MB_YESNO 0X00000004L

#define RERY CANCEL 0X00000005L

Which button is the focus on:

#define MB_DEFBUTTON1 0X00000000L

#define MB_DEFBUTTON2 0X00000100L

#define MB_DEFBUTTON3 0X00000200L

#define MB_DEFBUTTON4 0X00000300L

Appearance of the icon:

#define MB_ICONHAND 0x00000010L

#define MB_ICONQUESTION 0x00000020L

#define MB_ICONEXCLAMATION 0x00000030L

#define MB_ICONASTERISK 0x00000040L

Some of the illustrations have alternative names:

#define MB_ICONWARNING MB_ICONEXCLAMATION

#define MB_ICONERROR MB_ICONHAND< /p>

#define MB_ICONINFORMATION MB_ICONASTERISK

#define MB_ICONSTOP MB_ICONHAND

Example:

MessageBox(NULL, "Hello, Windows!","hello ", MB_OK );

MessageBox(NULL, "Hello, Windows!","HelloMsg", MB_YESNO|MB_ICONEXCLAMATION) ;

MessageBox(NULL, "Hello, Windows!", "HelloMsg", MB_YESNO|MB_DEFBUTTON1) ;//Indicates that the focus falls on the Yes (first) button after the window comes out