]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dialogs/dialogs.cpp
The UseAntiAliasing is off by default on wxMac. Add a menu item to
[wxWidgets.git] / samples / dialogs / dialogs.cpp
index 9dc3dcfa7ac535f88e5f0d5ed6738ce667c750a1..2441a6090455f2228a76d80142c5763a25fbb535 100644 (file)
@@ -5,11 +5,11 @@
 // Modified by:
 // Created:     04/01/98
 // RCS-ID:      $Id$
 // Modified by:
 // Created:     04/01/98
 // RCS-ID:      $Id$
-// Copyright:   (c) Julian Smart and Markus Holzem
+// Copyright:   (c) Julian Smart
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(__APPLE__)
 #pragma implementation
 #pragma interface
 #endif
 #pragma implementation
 #pragma interface
 #endif
 #include "wx/wx.h"
 #endif
 
 #include "wx/wx.h"
 #endif
 
+#ifdef __WXWINCE__
+#include "wx/msw/wince/time.h"
+#endif
+
 #include "wx/colordlg.h"
 #include "wx/filedlg.h"
 #include "wx/dirdlg.h"
 #include "wx/colordlg.h"
 #include "wx/filedlg.h"
 #include "wx/dirdlg.h"
@@ -34,6 +38,7 @@
 #include "wx/progdlg.h"
 #include "wx/fdrepdlg.h"
 #include "wx/busyinfo.h"
 #include "wx/progdlg.h"
 #include "wx/fdrepdlg.h"
 #include "wx/busyinfo.h"
+#include "wx/image.h"
 
 #define wxTEST_GENERIC_DIALOGS_IN_MSW 0
 
 
 #define wxTEST_GENERIC_DIALOGS_IN_MSW 0
 
@@ -44,7 +49,7 @@
 
 #define wxUSE_DIRDLGG 0
 
 
 #define wxUSE_DIRDLGG 0
 
-#if !defined(__WXMSW__) || defined(wxUSE_DIRDLGG) && wxUSE_DIRDLGG
+#if !(defined(__WXMSW__) || defined(__WXMAC__)) || wxUSE_DIRDLGG
 #include "wx/generic/dirdlgg.h"
 #endif
 
 #include "wx/generic/dirdlgg.h"
 #endif
 
@@ -71,6 +76,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_MENU(DIALOGS_FILES_OPEN,                    MyFrame::FilesOpen)
     EVT_MENU(DIALOGS_FILE_SAVE,                     MyFrame::FileSave)
     EVT_MENU(DIALOGS_DIR_CHOOSE,                    MyFrame::DirChoose)
     EVT_MENU(DIALOGS_FILES_OPEN,                    MyFrame::FilesOpen)
     EVT_MENU(DIALOGS_FILE_SAVE,                     MyFrame::FileSave)
     EVT_MENU(DIALOGS_DIR_CHOOSE,                    MyFrame::DirChoose)
+    EVT_MENU(DIALOGS_DIRNEW_CHOOSE,                 MyFrame::DirChooseNew)
 #if defined(__WXMSW__) || defined(__WXMAC__)
     EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE,            MyFrame::GenericDirChoose)
 #endif // wxMSW || wxMAC
 #if defined(__WXMSW__) || defined(__WXMAC__)
     EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE,            MyFrame::GenericDirChoose)
 #endif // wxMSW || wxMAC
@@ -118,11 +124,15 @@ MyCanvas *myCanvas = (MyCanvas *) NULL;
 // `Main program' equivalent, creating windows and returning main app frame
 bool MyApp::OnInit()
 {
 // `Main program' equivalent, creating windows and returning main app frame
 bool MyApp::OnInit()
 {
+#if wxUSE_IMAGE
+    wxInitAllImageHandlers();
+#endif
+
 #if defined(__WXGTK__) && defined(wxUSE_UNICODE)
   wxConvCurrent = &wxConvLibc;
 #endif
 
 #if defined(__WXGTK__) && defined(wxUSE_UNICODE)
   wxConvCurrent = &wxConvLibc;
 #endif
 
-  m_canvasTextColour = wxColour("BLACK");
+  m_canvasTextColour = wxColour(_T("BLACK"));
   m_canvasFont = *wxNORMAL_FONT;
 
   // Create the main frame window
   m_canvasFont = *wxNORMAL_FONT;
 
   // Create the main frame window
@@ -130,7 +140,7 @@ bool MyApp::OnInit()
 
   // Make a menubar
   wxMenu *file_menu = new wxMenu;
 
   // Make a menubar
   wxMenu *file_menu = new wxMenu;
-
+  
   file_menu->Append(DIALOGS_CHOOSE_COLOUR, _T("&Choose colour"));
 
 #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
   file_menu->Append(DIALOGS_CHOOSE_COLOUR, _T("&Choose colour"));
 
 #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
@@ -142,8 +152,8 @@ bool MyApp::OnInit()
 
 #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
   file_menu->Append(DIALOGS_CHOOSE_FONT_GENERIC, _T("Choose f&ont (generic)"));
 
 #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
   file_menu->Append(DIALOGS_CHOOSE_FONT_GENERIC, _T("Choose f&ont (generic)"));
-
 #endif
 #endif
+
   file_menu->AppendSeparator();
   file_menu->Append(DIALOGS_LOG_DIALOG, _T("&Log dialog\tCtrl-L"));
   file_menu->Append(DIALOGS_MESSAGE_BOX, _T("&Message box\tCtrl-M"));
   file_menu->AppendSeparator();
   file_menu->Append(DIALOGS_LOG_DIALOG, _T("&Log dialog\tCtrl-L"));
   file_menu->Append(DIALOGS_MESSAGE_BOX, _T("&Message box\tCtrl-M"));
@@ -160,9 +170,12 @@ bool MyApp::OnInit()
   file_menu->Append(DIALOGS_FILES_OPEN,  _T("Open &files\tCtrl-Q"));
   file_menu->Append(DIALOGS_FILE_SAVE,  _T("Sa&ve file\tCtrl-S"));
   file_menu->Append(DIALOGS_DIR_CHOOSE,  _T("&Choose a directory\tCtrl-D"));
   file_menu->Append(DIALOGS_FILES_OPEN,  _T("Open &files\tCtrl-Q"));
   file_menu->Append(DIALOGS_FILE_SAVE,  _T("Sa&ve file\tCtrl-S"));
   file_menu->Append(DIALOGS_DIR_CHOOSE,  _T("&Choose a directory\tCtrl-D"));
+  file_menu->Append(DIALOGS_DIRNEW_CHOOSE,  _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"));
 #if defined(__WXMSW__) || defined(__WXMAC__)
   file_menu->Append(DIALOGS_GENERIC_DIR_CHOOSE,  _T("&Choose a directory (generic implementation)"));
 #endif // wxMSW || wxMAC
 #if defined(__WXMSW__) || defined(__WXMAC__)
   file_menu->Append(DIALOGS_GENERIC_DIR_CHOOSE,  _T("&Choose a directory (generic implementation)"));
 #endif // wxMSW || wxMAC
+  file_menu->AppendSeparator();
+
 #if wxUSE_PROGRESSDLG
   file_menu->Append(DIALOGS_PROGRESS, _T("Pro&gress dialog\tCtrl-G"));
 #endif // wxUSE_PROGRESSDLG
 #if wxUSE_PROGRESSDLG
   file_menu->Append(DIALOGS_PROGRESS, _T("Pro&gress dialog\tCtrl-G"));
 #endif // wxUSE_PROGRESSDLG
@@ -170,13 +183,15 @@ bool MyApp::OnInit()
   file_menu->Append(DIALOGS_BUSYINFO, _T("&Busy info dialog\tCtrl-B"));
 #endif // wxUSE_BUSYINFO
 #if wxUSE_FINDREPLDLG
   file_menu->Append(DIALOGS_BUSYINFO, _T("&Busy info dialog\tCtrl-B"));
 #endif // wxUSE_BUSYINFO
 #if wxUSE_FINDREPLDLG
-  file_menu->Append(DIALOGS_FIND, _T("&Find dialog\tCtrl-F"), "", TRUE);
-  file_menu->Append(DIALOGS_REPLACE, _T("Find and &replace dialog\tShift-Ctrl-F"), "", TRUE);
+  file_menu->Append(DIALOGS_FIND, _T("&Find dialog\tCtrl-F"), _T(""), TRUE);
+  file_menu->Append(DIALOGS_REPLACE, _T("Find and &replace dialog\tShift-Ctrl-F"), _T(""), TRUE);
 #endif // wxUSE_FINDREPLDLG
   file_menu->AppendSeparator();
 #endif // wxUSE_FINDREPLDLG
   file_menu->AppendSeparator();
+
   file_menu->Append(DIALOGS_MODAL, _T("Mo&dal dialog\tCtrl-W"));
   file_menu->Append(DIALOGS_MODAL, _T("Mo&dal dialog\tCtrl-W"));
-  file_menu->Append(DIALOGS_MODELESS, _T("Modeless &dialog\tCtrl-Z"), "", TRUE);
+  file_menu->Append(DIALOGS_MODELESS, _T("Modeless &dialog\tCtrl-Z"), _T(""), TRUE);
   file_menu->AppendSeparator();
   file_menu->AppendSeparator();
+
   file_menu->Append(wxID_EXIT, _T("E&xit\tAlt-X"));
   wxMenuBar *menu_bar = new wxMenuBar;
   menu_bar->Append(file_menu, _T("&File"));
   file_menu->Append(wxID_EXIT, _T("E&xit\tAlt-X"));
   wxMenuBar *menu_bar = new wxMenuBar;
   menu_bar->Append(file_menu, _T("&File"));
@@ -226,13 +241,13 @@ void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) )
     }
 
     wxColourDialog dialog(this, &data);
     }
 
     wxColourDialog dialog(this, &data);
-    dialog.SetTitle("Choose the background colour");
+    dialog.SetTitle(_T("Choose the background colour"));
     if (dialog.ShowModal() == wxID_OK)
     {
         wxColourData retData = dialog.GetColourData();
         col = retData.GetColour();
         myCanvas->SetBackgroundColour(col);
     if (dialog.ShowModal() == wxID_OK)
     {
         wxColourData retData = dialog.GetColourData();
         col = retData.GetColour();
         myCanvas->SetBackgroundColour(col);
-        myCanvas->Clear();
+        myCanvas->ClearBackground();
         myCanvas->Refresh();
     }
 }
         myCanvas->Refresh();
     }
 }
@@ -278,7 +293,7 @@ void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event))
         wxColour col = retData.GetColour();
 //        wxBrush *brush = wxTheBrushList->FindOrCreateBrush(&col, wxSOLID);
         myCanvas->SetBackgroundColour(col);
         wxColour col = retData.GetColour();
 //        wxBrush *brush = wxTheBrushList->FindOrCreateBrush(&col, wxSOLID);
         myCanvas->SetBackgroundColour(col);
-        myCanvas->Clear();
+        myCanvas->ClearBackground();
         myCanvas->Refresh();
       }
       dialog->Destroy();
         myCanvas->Refresh();
       }
       dialog->Destroy();
@@ -302,7 +317,7 @@ void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) )
 }
 #endif // wxTEST_GENERIC_DIALOGS_IN_MSW
 
 }
 #endif // wxTEST_GENERIC_DIALOGS_IN_MSW
 
-void MyFrame::LogDialog(wxCommandEvent& event)
+void MyFrame::LogDialog(wxCommandEvent& WXUNUSED(event))
 {
     // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
     // being flushed -- test it
 {
     // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages
     // being flushed -- test it
@@ -375,7 +390,7 @@ void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event))
 {
     wxString pwd = wxGetPasswordFromUser(_T("Enter password:"),
                                          _T("Password entry dialog"),
 {
     wxString pwd = wxGetPasswordFromUser(_T("Enter password:"),
                                          _T("Password entry dialog"),
-                                         "",
+                                         _T(""),
                                          this);
     if ( !!pwd )
     {
                                          this);
     if ( !!pwd )
     {
@@ -438,10 +453,11 @@ void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) )
     if ( count )
     {
         wxString msg;
     if ( count )
     {
         wxString msg;
-        msg.Printf(wxT("You selected %u items:\n"), count);
+        msg.Printf(wxT("You selected %u items:\n"), (unsigned)count);
         for ( size_t n = 0; n < count; n++ )
         {
         for ( size_t n = 0; n < count; n++ )
         {
-            msg += wxString::Format(wxT("\t%u: %u (%s)\n"), n, selections[n],
+            msg += wxString::Format(wxT("\t%u: %u (%s)\n"),
+                                    (unsigned)n, (unsigned)selections[n],
                                     choices[selections[n]].c_str());
         }
         wxLogMessage(msg);
                                     choices[selections[n]].c_str());
         }
         wxLogMessage(msg);
@@ -457,9 +473,15 @@ void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
                     _T("Testing open file dialog"),
                     _T(""),
                     _T(""),
                     _T("Testing open file dialog"),
                     _T(""),
                     _T(""),
+#ifdef __WXMOTIF__
+                    _T("C++ files (*.cpp)|*.cpp")
+#else
                     _T("C++ files (*.h;*.cpp)|*.h;*.cpp")
                     _T("C++ files (*.h;*.cpp)|*.h;*.cpp")
+#endif
                  );
 
                  );
 
+    dialog.SetDirectory(wxGetHomeDir());
+
     if (dialog.ShowModal() == wxID_OK)
     {
         wxString info;
     if (dialog.ShowModal() == wxID_OK)
     {
         wxString info;
@@ -501,8 +523,14 @@ void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) )
 
 void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) )
 {
 
 void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) )
 {
+    wxString wildcards = 
+#ifdef __WXMOTIF__
+                    _T("C++ files (*.cpp)|*.cpp");
+#else
+                    _T("All files (*.*)|*.*|C++ files (*.h;*.cpp)|*.h;*.cpp");
+#endif
     wxFileDialog dialog(this, _T("Testing open multiple file dialog"),
     wxFileDialog dialog(this, _T("Testing open multiple file dialog"),
-                        "_T(", ")", wxFileSelectorDefaultWildcardStr,
+                        _T(""), _T(""), wildcards,
                         wxMULTIPLE);
 
     if (dialog.ShowModal() == wxID_OK)
                         wxMULTIPLE);
 
     if (dialog.ShowModal() == wxID_OK)
@@ -517,10 +545,12 @@ void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) )
         for ( size_t n = 0; n < count; n++ )
         {
             s.Printf(_T("File %d: %s (%s)\n"),
         for ( size_t n = 0; n < count; n++ )
         {
             s.Printf(_T("File %d: %s (%s)\n"),
-                     n, paths[n].c_str(), filenames[n].c_str());
+                     (int)n, paths[n].c_str(), filenames[n].c_str());
 
             msg += s;
         }
 
             msg += s;
         }
+        s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex());
+        msg += s;
 
         wxMessageDialog dialog2(this, msg, _T("Selected files"));
         dialog2.ShowModal();
 
         wxMessageDialog dialog2(this, msg, _T("Selected files"));
         dialog2.ShowModal();
@@ -532,39 +562,48 @@ void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) )
     wxFileDialog dialog(this,
                         _T("Testing save file dialog"),
                         _T(""),
     wxFileDialog dialog(this,
                         _T("Testing save file dialog"),
                         _T(""),
-                        _T("myletter.txt"),
+                        _T("myletter.doc"),
                         _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
                         wxSAVE|wxOVERWRITE_PROMPT);
 
                         _T("Text files (*.txt)|*.txt|Document files (*.doc)|*.doc"),
                         wxSAVE|wxOVERWRITE_PROMPT);
 
+    dialog.SetFilterIndex(1);
+
     if (dialog.ShowModal() == wxID_OK)
     {
     if (dialog.ShowModal() == wxID_OK)
     {
-        wxChar buf[400];
-        wxSprintf(buf, _T("%s, filter %d"), (const wxChar*)dialog.GetPath(), dialog.GetFilterIndex());
-        wxMessageDialog dialog2(this, wxString(buf), _T("Selected path"));
-        dialog2.ShowModal();
+        wxLogMessage(_T("%s, filter %d"),
+                     dialog.GetPath().c_str(), dialog.GetFilterIndex());
     }
 }
 
     }
 }
 
-void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
+void MyFrame::DoDirChoose(int style)
 {
     // pass some initial dir to wxDirDialog
     wxString dirHome;
     wxGetHomeDir(&dirHome);
 
 {
     // pass some initial dir to wxDirDialog
     wxString dirHome;
     wxGetHomeDir(&dirHome);
 
-    wxDirDialog dialog(this, _T("Testing directory picker"), dirHome);
+    wxDirDialog dialog(this, _T("Testing directory picker"), dirHome, style);
 
     if (dialog.ShowModal() == wxID_OK)
     {
 
     if (dialog.ShowModal() == wxID_OK)
     {
-        wxMessageDialog dialog2(this, dialog.GetPath(), _T("Selected path"));
-        dialog2.ShowModal();
+        wxLogMessage(_T("Selected path: %s"), dialog.GetPath().c_str());
     }
 }
 
     }
 }
 
+void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
+{
+    DoDirChoose(wxDD_DEFAULT_STYLE & ~wxDD_NEW_DIR_BUTTON);
+}
+
+void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) )
+{
+    DoDirChoose(wxDD_DEFAULT_STYLE | wxDD_NEW_DIR_BUTTON);
+}
+
 #if defined(__WXMSW__) || defined(__WXMAC__)
 
 void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) )
 {
 #if defined(__WXMSW__) || defined(__WXMAC__)
 
 void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) )
 {
-#if !defined(__WXMSW__) || defined(wxUSE_DIRDLGG) && wxUSE_DIRDLGG
+#if !(defined(__WXMSW__) || defined(__WXMAC__)) || wxUSE_DIRDLGG
     // pass some initial dir to wxDirDialog
     wxString dirHome;
     wxGetHomeDir(&dirHome);
     // pass some initial dir to wxDirDialog
     wxString dirHome;
     wxGetHomeDir(&dirHome);
@@ -609,7 +648,7 @@ void MyFrame::ModelessDlg(wxCommandEvent& event)
     }
 }
 
     }
 }
 
-void MyFrame::ShowTip(wxCommandEvent& event)
+void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event))
 {
 #if wxUSE_STARTUP_TIPS
     static size_t s_index = (size_t)-1;
 {
 #if wxUSE_STARTUP_TIPS
     static size_t s_index = (size_t)-1;
@@ -655,6 +694,7 @@ void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) )
                             this,   // parent
                             wxPD_CAN_ABORT |
                             wxPD_APP_MODAL |
                             this,   // parent
                             wxPD_CAN_ABORT |
                             wxPD_APP_MODAL |
+                            // wxPD_AUTO_HIDE | -- try this as well
                             wxPD_ELAPSED_TIME |
                             wxPD_ESTIMATED_TIME |
                             wxPD_REMAINING_TIME);
                             wxPD_ELAPSED_TIME |
                             wxPD_ESTIMATED_TIME |
                             wxPD_REMAINING_TIME);
@@ -705,13 +745,16 @@ void MyFrame::ShowBusyInfo(wxCommandEvent& WXUNUSED(event))
 {
     wxWindowDisabler disableAll;
 
 {
     wxWindowDisabler disableAll;
 
-    wxBusyInfo info("Working, please wait...", this);
+    wxBusyInfo info(_T("Working, please wait..."), this);
 
 
-    for ( int i = 0; i < 30; i++ )
+    for ( int i = 0; i < 18; i++ )
     {
     {
-        wxUsleep(100);
+        //wxUsleep(100);
         wxTheApp->Yield();
     }
         wxTheApp->Yield();
     }
+
+    wxSleep(2);
+    //wxWakeUpIdle();
 }
 
 #endif // wxUSE_BUSYINFO
 }
 
 #endif // wxUSE_BUSYINFO
@@ -779,7 +822,7 @@ void MyFrame::OnFindDialog(wxFindDialogEvent& event)
     if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT )
     {
         wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
     if ( type == wxEVT_COMMAND_FIND || type == wxEVT_COMMAND_FIND_NEXT )
     {
         wxLogMessage(wxT("Find %s'%s' (flags: %s)"),
-                     type == wxEVT_COMMAND_FIND_NEXT ? _T("next ") : "",
+                     type == wxEVT_COMMAND_FIND_NEXT ? wxT("next ") : wxT(""),
                      event.GetFindString().c_str(),
                      DecodeFindDialogEventFlags(event.GetFlags()).c_str());
     }
                      event.GetFindString().c_str(),
                      DecodeFindDialogEventFlags(event.GetFlags()).c_str());
     }
@@ -787,7 +830,7 @@ void MyFrame::OnFindDialog(wxFindDialogEvent& event)
                 type == wxEVT_COMMAND_FIND_REPLACE_ALL )
     {
         wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
                 type == wxEVT_COMMAND_FIND_REPLACE_ALL )
     {
         wxLogMessage(wxT("Replace %s'%s' with '%s' (flags: %s)"),
-                     type == wxEVT_COMMAND_FIND_REPLACE_ALL ? _T("all ") : "",
+                     type == wxEVT_COMMAND_FIND_REPLACE_ALL ? _T("all ") : wxT(""),
                      event.GetFindString().c_str(),
                      event.GetReplaceString().c_str(),
                      DecodeFindDialogEventFlags(event.GetFlags()).c_str());
                      event.GetFindString().c_str(),
                      event.GetReplaceString().c_str(),
                      DecodeFindDialogEventFlags(event.GetFlags()).c_str());
@@ -796,25 +839,34 @@ void MyFrame::OnFindDialog(wxFindDialogEvent& event)
     {
         wxFindReplaceDialog *dlg = event.GetDialog();
 
     {
         wxFindReplaceDialog *dlg = event.GetDialog();
 
+        int idMenu;
         const wxChar *txt;
         if ( dlg == m_dlgFind )
         {
             txt = _T("Find");
         const wxChar *txt;
         if ( dlg == m_dlgFind )
         {
             txt = _T("Find");
+            idMenu = DIALOGS_FIND;
             m_dlgFind = NULL;
         }
         else if ( dlg == m_dlgReplace )
         {
             txt = _T("Replace");
             m_dlgFind = NULL;
         }
         else if ( dlg == m_dlgReplace )
         {
             txt = _T("Replace");
+            idMenu = DIALOGS_REPLACE;
             m_dlgReplace = NULL;
         }
         else
         {
             txt = _T("Unknown");
             m_dlgReplace = NULL;
         }
         else
         {
             txt = _T("Unknown");
+            idMenu = -1;
 
             wxFAIL_MSG( _T("unexpected event") );
         }
 
 
             wxFAIL_MSG( _T("unexpected event") );
         }
 
-        wxLogMessage(wxT("%s dialog is being closed."), txt),
+        wxLogMessage(wxT("%s dialog is being closed."), txt);
+
+        if ( idMenu != -1 )
+        {
+            GetMenuBar()->Check(idMenu, FALSE);
+        }
 
         dlg->Destroy();
     }
 
         dlg->Destroy();
     }
@@ -836,7 +888,7 @@ void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
     dc.SetFont(wxGetApp().m_canvasFont);
     dc.SetTextForeground(wxGetApp().m_canvasTextColour);
     dc.SetBackgroundMode(wxTRANSPARENT);
     dc.SetFont(wxGetApp().m_canvasFont);
     dc.SetTextForeground(wxGetApp().m_canvasTextColour);
     dc.SetBackgroundMode(wxTRANSPARENT);
-    dc.DrawText("wxWindows common dialogs test application", 10, 10);
+    dc.DrawText(_T("wxWindows common dialogs test application"), 10, 10);
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
@@ -844,7 +896,7 @@ void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
 // ----------------------------------------------------------------------------
 
 MyModelessDialog::MyModelessDialog(wxWindow *parent)
 // ----------------------------------------------------------------------------
 
 MyModelessDialog::MyModelessDialog(wxWindow *parent)
-                : wxDialog(parent, -1, wxString("Modeless dialog"))
+                : wxDialog(parent, -1, wxString(_T("Modeless dialog")))
 {
     wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
 
 {
     wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
 
@@ -885,14 +937,17 @@ void MyModelessDialog::OnClose(wxCloseEvent& event)
 // ----------------------------------------------------------------------------
 
 MyModalDialog::MyModalDialog(wxWindow *parent)
 // ----------------------------------------------------------------------------
 
 MyModalDialog::MyModalDialog(wxWindow *parent)
-             : wxDialog(parent, -1, _T("Modal dialog"))
+             : wxDialog(parent, -1, wxString(_T("Modal dialog")))
 {
     wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
 
 {
     wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
 
-    m_btnFocused = new wxButton(this, -1, _T("Default button"));
+    m_btnModal = new wxButton(this, -1, _T("&Modal dialog..."));
+    m_btnModeless = new wxButton(this, -1, _T("Mode&less dialog"));
     m_btnDelete = new wxButton(this, -1, _T("&Delete button"));
     m_btnDelete = new wxButton(this, -1, _T("&Delete button"));
+
     wxButton *btnOk = new wxButton(this, wxID_CANCEL, _T("&Close"));
     wxButton *btnOk = new wxButton(this, wxID_CANCEL, _T("&Close"));
-    sizerTop->Add(m_btnFocused, 0, wxALIGN_CENTER | wxALL, 5);
+    sizerTop->Add(m_btnModal, 0, wxALIGN_CENTER | wxALL, 5);
+    sizerTop->Add(m_btnModeless, 0, wxALIGN_CENTER | wxALL, 5);
     sizerTop->Add(m_btnDelete, 0, wxALIGN_CENTER | wxALL, 5);
     sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5);
 
     sizerTop->Add(m_btnDelete, 0, wxALIGN_CENTER | wxALL, 5);
     sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5);
 
@@ -902,25 +957,29 @@ MyModalDialog::MyModalDialog(wxWindow *parent)
     sizerTop->SetSizeHints(this);
     sizerTop->Fit(this);
 
     sizerTop->SetSizeHints(this);
     sizerTop->Fit(this);
 
-    m_btnFocused->SetFocus();
-    m_btnFocused->SetDefault();
+    m_btnModal->SetFocus();
+    m_btnModal->SetDefault();
 }
 
 void MyModalDialog::OnButton(wxCommandEvent& event)
 {
     if ( event.GetEventObject() == m_btnDelete )
     {
 }
 
 void MyModalDialog::OnButton(wxCommandEvent& event)
 {
     if ( event.GetEventObject() == m_btnDelete )
     {
-        delete m_btnFocused;
-        m_btnFocused = NULL;
+        delete m_btnModal;
+        m_btnModal = NULL;
 
         m_btnDelete->Disable();
     }
 
         m_btnDelete->Disable();
     }
-    else if ( event.GetEventObject() == m_btnFocused )
+    else if ( event.GetEventObject() == m_btnModal )
     {
         wxGetTextFromUser(_T("Dummy prompt"),
                           _T("Modal dialog called from dialog"),
                           _T(""), this);
     }
     {
         wxGetTextFromUser(_T("Dummy prompt"),
                           _T("Modal dialog called from dialog"),
                           _T(""), this);
     }
+    else if ( event.GetEventObject() == m_btnModeless )
+    {
+        (new MyModelessDialog(this))->Show();
+    }
     else
     {
         event.Skip();
     else
     {
         event.Skip();