wb_message_box

int wb_message_box (int parent, string message [, string title [, int style]])

Creates and displays a message box under the style supplied and returns a value according to the button pressed.

Message box styles

The following styles are defined in WinBinder:

Value for style

What is displayed

WBC_OK (the default)

An OK button.

WBC_INFO

An information icon and an OK button.

WBC_WARNING

An exclamation point icon and an OK button.

WBC_STOP

A stop icon and an OK button.

WBC_QUESTION

A question mark icon and an OK button.

WBC_OKCANCEL

A question mark icon, an OK button and a Cancel button.

WBC_YESNO

A question mark icon, a Yes button and a No button.

WBC_YESNOCANCEL

A question mark icon, a Yes button, a No button and a Cancel button.

NOTE

The style parameter accepts all styles available to the Windows function MessageBox().

Return values

See the following table.

Button pressed

Return value

OK

TRUE

Retry

TRUE

Yes

TRUE

No

0 (zero)¹

Cancel

FALSE

Ignore

FALSE

Abort

FALSE

(Others)

FALSE

(Error)

NULL

¹ The value the No button returns is zero to differentiate it from the other negative values. This distinction is only necessary when you use the WBC_YESNOCANCEL style. See the example below.

Example

// Asks for confirmation before closing an application window

function process_main($window, $id)
{ 
   switch($id) { 
       case ID_EXIT: 
       case IDCLOSE: 
           if(wb_message_box($window, "Are your sure?", APPNAME, WBC_YESNO)) 
               wb_destroy_window($window); 
           break;
   }
}

// The code snippet below differentiates between buttons No and Cancel

$ret = wb_message_box(null, "Save file before exiting?", null, WBC_YESNOCANCEL);

if($ret === FALSE)     // The '===' operator checks value and type
  $text = 'Cancel';
elseif($ret)
  $text = 'Yes';
else
  $text = 'No';

See also

Dialog functions