X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/49b957be80cf3ba9c8b9aa35678d733296e2f2c9..9988e82e748d9a2f1f8363fe16c10199353b88a8:/samples/dialogs/dialogs.cpp diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 35a477e829..e8df89afe6 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -239,19 +239,25 @@ void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) ) void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) ) { - wxFontData data; - data.SetInitialFont(wxGetApp().m_canvasFont); - data.SetColour(wxGetApp().m_canvasTextColour); + wxFontData data; + data.SetInitialFont(wxGetApp().m_canvasFont); + data.SetColour(wxGetApp().m_canvasTextColour); - wxFontDialog *dialog = new wxFontDialog(this, &data); - if (dialog->ShowModal() == wxID_OK) - { - wxFontData retData = dialog->GetFontData(); + // you might also do this: + // + // wxFontDialog dialog; + // if ( !dialog.Create(this, data) { ... error ... } + // + wxFontDialog dialog(this, data); + + if (dialog.ShowModal() == wxID_OK) + { + wxFontData retData = dialog.GetFontData(); wxGetApp().m_canvasFont = retData.GetChosenFont(); wxGetApp().m_canvasTextColour = retData.GetColour(); myCanvas->Refresh(); - } - dialog->Destroy(); + } + //else: cancelled by the user, don't change the font } #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW @@ -326,19 +332,19 @@ void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event) ) switch ( dialog.ShowModal() ) { case wxID_YES: - wxLogStatus("You pressed \"Yes\""); + wxLogStatus(wxT("You pressed \"Yes\"")); break; case wxID_NO: - wxLogStatus("You pressed \"No\""); + wxLogStatus(wxT("You pressed \"No\"")); break; case wxID_CANCEL: - wxLogStatus("You pressed \"Cancel\""); + wxLogStatus(wxT("You pressed \"Cancel\"")); break; default: - wxLogError("Unexpected wxMessageDialog return code!"); + wxLogError(wxT("Unexpected wxMessageDialog return code!")); } }