Wx::MessageBox
From WxPerl wiki
::wxMessageBox
int wxMessageBox(const wxString& message, const wxString& caption = "Message", int style = wxOK | wxCENTRE, wxWindow *parent = NULL, int x = -1, int y = -1)
General purpose message dialog. style may be a bit list of the following identifiers:
wxYES_NO Puts Yes and No buttons on the message box. May be combined with wxCANCEL. wxCANCEL Puts a Cancel button on the message box. May be combined with wxYES_NO or wxOK. wxOK Puts an Ok button on the message box. May be combined with wxCANCEL. wxCENTRE Centres the text. wxICON_EXCLAMATION Displays an exclamation mark symbol. wxICON_HAND Displays an error symbol. wxICON_ERROR Displays an error symbol - the same as wxICON_HAND. wxICON_QUESTION Displays a question mark symbol. wxICON_INFORMATION Displays an information symbol.
The return value is one of: wxYES, wxNO, wxCANCEL, wxOK.
...
int answer = wxMessageBox("Quit program?", "Confirm", wxYES_NO | wxCANCEL, main_frame);
if (answer == wxYES)
delete main_frame;
...
message may contain newline characters, in which case the message will be split into separate lines, to cater for large messages. Under Windows, the native MessageBox function is used unless wxCENTRE is specified in the style, in which case a generic function is used. This is because the native MessageBox function cannot centre text. The symbols are not shown when the generic function is used.
and now for the perl example:
sub PromptSaveOptions {
my( $this ) = @_;
return () unless options_were_modified();
my( $answer ) = Wx::MessageBox(
'Do you wanna save your options?',
'Goodbye',
Wx::wxYES_NO(), # if you use Wx ':everything', it's wxYES_NO
undef, # you needn't pass anything, much less $frame
);
if( $answer == Wx::wxYES() ) {
# save options
}
}
Please be aware that the following are also at your disposal
wxYES -> 32 wxID_YES -> 5103 wxID_NO -> 5104 wxID_CANCEL -> 5101
