]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/config/conftest.cpp
Work on streams of all sorts. More to come.
[wxWidgets.git] / samples / config / conftest.cpp
index 3d0b4b5217b26ce6704157fceffa7506ab849a2f..fe26c3b968a200a14721c7c9ec8538d4a393d9e1 100644 (file)
@@ -2,7 +2,7 @@
 // Name:        conftest.cpp
 // Purpose:     demo of wxConfig and related classes
 // Author:      Vadim Zeitlin
-// Modified by: 
+// Modified by:
 // Created:     03.08.98
 // RCS-ID:      $Id$
 // Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
@@ -41,12 +41,12 @@ class MyFrame: public wxFrame
 public:
   MyFrame();
   virtual ~MyFrame();
-    
+
   // callbacks
   void OnQuit(wxCommandEvent& event);
   void OnAbout(wxCommandEvent& event);
   void OnDelete(wxCommandEvent& event);
-  bool OnClose() { return TRUE; }
+  void OnCloseWindow(wxCloseEvent& event);
 
 private:
   wxTextCtrl *m_text;
@@ -69,6 +69,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
   EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
   EVT_MENU(Minimal_About, MyFrame::OnAbout)
   EVT_MENU(Minimal_Delete, MyFrame::OnDelete)
+  EVT_CLOSE(MyFrame::OnCloseWindow)
 END_EVENT_TABLE()
 
 // ============================================================================
@@ -140,6 +141,12 @@ int MyApp::OnExit()
 MyFrame::MyFrame()
        : wxFrame((wxFrame *) NULL, -1, "wxConfig Demo")
 {
+  // submenu
+  wxMenu *sub_menu = new wxMenu( wxMENU_TEAROFF );
+  sub_menu->Append(Minimal_About, "&About", "About this sample");
+  sub_menu->Append(Minimal_About, "&About", "About this sample");
+  sub_menu->Append(Minimal_About, "&About", "About this sample");
+
   // menu
   wxMenu *file_menu = new wxMenu;
 
@@ -189,6 +196,11 @@ MyFrame::MyFrame()
   SetClientSize(w, h);
 }
 
+void MyFrame::OnCloseWindow(wxCloseEvent& event)
+{
+    this->Destroy();
+}
+
 void MyFrame::OnQuit(wxCommandEvent&)
 {
   Close(TRUE);
@@ -202,14 +214,16 @@ void MyFrame::OnAbout(wxCommandEvent&)
 
 void MyFrame::OnDelete(wxCommandEvent&)
 {
-  if ( wxConfigBase::Get()->DeleteAll() ) {
-    wxLogMessage("Config file/registry key successfully deleted.");
-
-    delete wxConfigBase::Set((wxConfigBase *) NULL);
-    wxConfigBase::DontCreateOnDemand();
-  }
-  else
-    wxLogError("Deleting config file/registry key failed.");
+    if ( wxConfigBase::Get()->DeleteAll() ) {
+        wxLogMessage("Config file/registry key successfully deleted.");
+
+        delete wxConfigBase::Set((wxConfigBase *) NULL);
+        wxConfigBase::DontCreateOnDemand();
+    }
+    else
+    {
+        wxLogError("Deleting config file/registry key failed.");
+    }
 }
 
 MyFrame::~MyFrame()