MSGBOX function


Display a message box containing a text string and an optional title, using one or more styles, and returning the button selected by the user.


lResult& = MSGBOX(txt$ [, [style&], title$])


The MSGBOX function is comprised of the following elements:


Indicates the text to display within the message box.


Optional parameter which determines the appearance of the message box. Some styles may be combined (OR'ed together) to specify the button and icon displayed in the message box. If style& is omitted, PowerBASIC substitutes %MB_OK. The following styles are defined in WIN32API.INC, in the form of numeric equates:


Display OK button (default)


Display OK and Cancel buttons


Display Abort, Retry and Ignore


Display Yes, No and Cancel


Display Yes and No buttons


Display Retry and Cancel buttons


Display Error icon (stop sign)


Display Information icon ("i")


Display Query icon (question mark)


Display Warning icon (exclamation)


Default to 1st button (default)


Default to 2nd button


Default to 3rd button


Application Modal - Despite the name, the user can continue to interact with other dialogs without dismissing the MSGBOX. (default)


System Modal - Operates identically to %MB_APPLMODAL, except the MSGBOX is given the %WS_EX_TOPMOST style so that it remains above all other windows and dialogs.


Task Modal - All top-level windows belonging to the current application are disabled until the MSGBOX is dismissed. %MB_TASKMODAL is commonly used to display a truly modal MSGBOX.


Optional title to be displayed in the caption of the message box. If title$ is not specified, "PowerBASIC" is used automatically.


Identifies the Button selected by the user. This will be equal to one of the following equates:


OK button


Cancel button


Abort button


Retry button


Ignore button


Yes button


No button

Additional styles may be found in WIN32API.INC in the section prefixed with %MB_. If you are not interested in which button the user selects, use a MSGBOX statement rather than a MSGBOX function.

A question mark may be used as an abbreviation for the MSGBOX statement.


Strings displayed by the MSGBOX function are displayed only up to the first $NUL character, if any.

See also

INPUTBOX$, MSGBOX statement, TXT pseudo-object


lResult& = MSGBOX("Overwrite registry file?", %MB_OKCANCEL OR %MB_DEFBUTTON2 _

             OR %MB_TASKMODAL, "Critical Warning")