+// ----------------------------------------------------------------------------
+// MyModalDialog
+// Demonstrates context-sensitive help
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(MyModalDialog, wxDialog)
+ EVT_HELP(-1, MyModalDialog::OnContextHelp)
+END_EVENT_TABLE()
+
+MyModalDialog::MyModalDialog(wxWindow *parent)
+ : wxDialog()
+{
+ // Add the context-sensitive help button on the caption, MSW only
+ SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
+
+ wxDialog::Create(parent, -1, wxString("Modal dialog"));
+
+ wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
+ wxBoxSizer *sizerRow = new wxBoxSizer(wxHORIZONTAL);
+
+ wxButton* btnOK = new wxButton(this, wxID_OK, "&OK");
+ wxButton* btnCancel = new wxButton(this, wxID_CANCEL, "&Cancel");
+ sizerRow->Add(btnOK, 0, wxALIGN_CENTER | wxALL, 5);
+ sizerRow->Add(btnCancel, 0, wxALIGN_CENTER | wxALL, 5);
+
+ // Add the explicit context-sensitive help button, non-MSW
+#ifndef __WXMSW__
+ sizerRow->Add(new wxContextHelpButton(this), 0, wxALIGN_CENTER | wxALL, 5);
+#endif
+
+ sizerTop->Add(new wxTextCtrl(this, wxID_APPLY, wxT("A demo text control"), wxDefaultPosition, wxSize(300, 100), wxTE_MULTILINE),
+ 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+ sizerTop->Add(sizerRow, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+
+ SetAutoLayout(TRUE);
+ SetSizer(sizerTop);
+
+ sizerTop->SetSizeHints(this);
+ sizerTop->Fit(this);
+
+ btnOK->SetFocus();
+ btnOK->SetDefault();
+}
+
+void MyModalDialog::OnContextHelp(wxHelpEvent& event)
+{
+ wxString msg;
+ switch (event.GetId())
+ {
+ case wxID_OK:
+ {
+ msg = _("The OK button confirms the dialog choices.");
+ break;
+ }
+ case wxID_CANCEL:
+ {
+ msg = _("The Cancel button cancels the dialog.");
+ break;
+ }
+ case wxID_APPLY:
+ {
+ msg = _("This is a text control that does nothing in particular.");
+ break;
+ }
+ case wxID_CONTEXT_HELP:
+ {
+ msg = _("If you didn't know what this button is for, why did you press it? :-)");
+ break;
+ }
+ }
+ if (!msg.IsEmpty())
+ wxMessageBox(msg, _("Help"), wxICON_INFORMATION, this);
+}
+