]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dialogs/dialogs.cpp
Committing in .
[wxWidgets.git] / samples / dialogs / dialogs.cpp
index 35a477e82954a00105902fbd5bfeee297cc35a25..e8df89afe6d535e1d2e87c045ee71b0e85bd2633 100644 (file)
@@ -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!"));
   }
 }