Definition (for Visual Basic 6.0): declare the function messageboxlib "user 32" alias "messagebox a”(byval hwnd is long, byval LP text is string, byval LP caption is string, byval WType is long) as long.
Parameter description:
hWnd:
Specifies the owner window of the dialog box. If this parameter is empty (0), the dialog box does not belong to any window (? )。
lpText:
The message displayed in the dialog box.
lpCaption:
The string expression displayed in the title bar of the dialog box. If this parameter is empty (vbNullString), the default "Error" is used as the title of the dialog box.
wType:
Specify the number and form of display buttons, icon style used, default buttons and mandatory response of message boxes. Can be one of the following constants or the sum of several values.
Specify button style:
MB_ABORTRETRYIGNORE
Show abort, retry and ignore buttons.
MB _ ok
Only the OK button is displayed. (Default)
MB _ ok to cancel
Show OK and Cancel buttons.
MB_RETRYCANCEL
Show retry and cancel buttons.
MB _ whether or not
Show Yes and No buttons.
MB _ is cancelled.
Show Yes, No and Cancel buttons.
Specify icon style:
MB _ icon exclamation point, MB _ icon warning
Show warning message icon.
MB _ icon information, MB _ icon asterisk
Displays the information message icon.
MB_ICONQUESTION
Display warning query icon.
MB_ICONSTOP,MB_ICONERROR,MB_ICONHAND
Displays the key message icon.
Specify the default button:
MB_DEFBUTTON 1
The first button is the default value. (Default)
MB_DEFBUTTON2
The second button is the default value.
MB_DEFBUTTON3
The third button is the default value.
MB_DEFBUTTON4
The fourth button is the default value.
Specify dialogue mode, etc:
MB _ application mode
The application forced a return; The application is suspended until the user responds to the message box.
MB _ system mode
System forced return; All applications are suspended until the user responds to the message box.
MB_TASKMODAL
MB _ Default _ Desktop _ Only
MB _ help
Add a help button to the message box.
MB _ right
Right-aligned text.
MB_RTLREADING
Specifies that text should be displayed from right to left in Hebrew and Arabic systems.
MB_SETFOREGROUND
Specifies the message box window as the foreground window.
MB _ highest
MB _ service _ notification
MB _ service _ notification _NT3X
MB _ service _ notification
Return value:
Returns 0 if there is not enough memory to create a message dialog box.
If the function runs successfully, it will return one of the following values:
Idabot
The user clicked the abort button.
IDCANCEL
The user clicked the Cancel button.
Idiniole
The user clicked the Ignore button.
IDNO
The user clicked the No button.
Idok
The user clicked the OK button.
IDRETRY
The user clicked the retry button.
Idis
The user clicked the "Yes" button.
If the dialog box displays the Cancel button, pressing the ESC key has the same effect as clicking the Cancel button.
2, program example:
# include & ltwindows.h & gt
//Remember! On the phone
int? Master ()
{
int? The result? =? MessageBox(? NULL? ,? TEXT ("This is a dialog box")? ,? Text ("Hello")? ,? MB _ icon information | MB _ yes no);
Switch (result)/* Attention! Use Unicode to apply a text enclosing string */
{
Case? IDYES:MessageBox(NULL, TEXT ("You chose Yes"), TEXT ("Yes"), MB _ OK); Break;
Case? IDNO:MessageBox(NULL, TEXT ("Did you choose No"), TEXT ("No"), MB _ OK); Break;
}
Return? 0;
}