X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0be4095abb8ef117e63e1db7f9d80831353a9e7c..0e74909dd1a16f3d50cf954fdfe13541f9c23f38:/samples/config/conftest.cpp diff --git a/samples/config/conftest.cpp b/samples/config/conftest.cpp index b44a5b33c4..0dbc6cd148 100644 --- a/samples/config/conftest.cpp +++ b/samples/config/conftest.cpp @@ -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 @@ -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() // ============================================================================ @@ -127,7 +128,7 @@ int MyApp::OnExit() // clean up: Set() returns the active config object as Get() does, but unlike // Get() it doesn't try to create one if there is none (definitely not what // we want here!) - delete wxConfigBase::Set(NULL); + delete wxConfigBase::Set((wxConfigBase *) NULL); return 0; } @@ -138,8 +139,14 @@ int MyApp::OnExit() // main frame ctor MyFrame::MyFrame() - : wxFrame(NULL, -1, "wxConfig Demo") + : wxFrame((wxFrame *) NULL, -1, "wxConfig Demo") { + // submenu + wxMenu *sub_menu = new wxMenu( wxEmptyString, 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); @@ -196,20 +208,22 @@ void MyFrame::OnQuit(wxCommandEvent&) void MyFrame::OnAbout(wxCommandEvent&) { - wxMessageBox("wxConfig demo\n© Vadim Zeitlin 1998", "About", + wxMessageBox(_T("wxConfig demo\n© Vadim Zeitlin 1998"), _T("About"), wxICON_INFORMATION | wxOK); } void MyFrame::OnDelete(wxCommandEvent&) { - if ( wxConfigBase::Get()->DeleteAll() ) { - wxLogMessage("Config file/registry key successfully deleted."); - - delete wxConfigBase::Set(NULL); - wxConfigBase::DontCreateOnDemand(); - } - else - wxLogError("Deleting config file/registry key failed."); + if ( wxConfigBase::Get()->DeleteAll() ) { + wxLogMessage(_T("Config file/registry key successfully deleted.")); + + delete wxConfigBase::Set((wxConfigBase *) NULL); + wxConfigBase::DontCreateOnDemand(); + } + else + { + wxLogError(_T("Deleting config file/registry key failed.")); + } } MyFrame::~MyFrame() @@ -225,8 +239,8 @@ MyFrame::~MyFrame() int x, y, w, h; GetClientSize(&w, &h); GetPosition(&x, &y); - pConfig->Write("/MainFrame/x", x); - pConfig->Write("/MainFrame/y", y); - pConfig->Write("/MainFrame/w", w); - pConfig->Write("/MainFrame/h", h); + pConfig->Write("/MainFrame/x", (long) x); + pConfig->Write("/MainFrame/y", (long) y); + pConfig->Write("/MainFrame/w", (long) w); + pConfig->Write("/MainFrame/h", (long) h); }