
To create a wxWidgets modal dialog some source code must be added to your existing wxWidget application.
[codesyntax lang=”cpp”]
int dlgWidth = 300; int dlgHeight = 300;
[/codesyntax]
The next section of code will establish the class and the reference to the modal dialog.
[codesyntax lang=”cpp”]
class CustomDialog: public wxDialog // @suppress(“Symbol is not resolved”)
{
public:
CustomDialog(const wxString& title);
private:
};
CustomDialog::CustomDialog(const wxString & title) :
wxDialog(NULL, -1, title, wxDefaultPosition, wxSize(dlgWidth, dlgHeight)) // @suppress(“Symbol is not resolved”)
{
wxPanel *panel = new wxPanel(this, -1); // @suppress(“Type cannot be resolved”)
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
Centre(); // @suppress(“Function cannot be resolved”)
ShowModal(); // @suppress(“Function cannot be resolved”) Destroy(); // @suppress(“Function cannot be resolved”)
}
[/codesyntax]
The final section of code shows how to invoke the modal dialog.
[codesyntax lang=”cpp”]
dlgWidth = 300; dlgHeight = 300; CustomDialog("Caption Goes Here!");
[/codesyntax]
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.