- : 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;
-
- file_menu->Append(Minimal_Delete, "&Delete", "Delete config file");
- file_menu->AppendSeparator();
- file_menu->Append(Minimal_About, "&About", "About this sample");
- file_menu->AppendSeparator();
- file_menu->Append(Minimal_Quit, "E&xit", "Exit the program");
- wxMenuBar *menu_bar = new wxMenuBar;
- menu_bar->Append(file_menu, "&File");
- SetMenuBar(menu_bar);
-
- CreateStatusBar();
-
- // child controls
- wxPanel *panel = new wxPanel(this);
- (void)new wxStaticText(panel, -1, "These controls remember their values!",
- wxPoint(10, 10), wxSize(300, 20));
- m_text = new wxTextCtrl(panel, -1, "", wxPoint(10, 40), wxSize(300, 20));
- m_check = new wxCheckBox(panel, -1, "show welcome message box at startup",
- wxPoint(10, 70), wxSize(300, 20));
-
- // restore the control's values from the config
-
- // NB: in this program, the config object is already created at this moment
- // because we had called Get() from MyApp::OnInit(). However, if you later
- // change the code and don't create it before this line, it won't break
- // anything - unlike if you manually create wxConfig object with Create()
- // or in any other way (then you must be sure to create it before using it!).
- wxConfigBase *pConfig = wxConfigBase::Get();
-
- // we could write Read("/Controls/Text") as well, it's just to show SetPath()
- pConfig->SetPath("/Controls");
-
- m_text->SetValue(pConfig->Read("Text", ""));
- m_check->SetValue(pConfig->Read("Check", 1l) != 0);
-
- // SetPath() understands ".."
- pConfig->SetPath("../MainFrame");
-
- // restore frame position and size
- int x = pConfig->Read("x", 50),
- y = pConfig->Read("y", 50),
- w = pConfig->Read("w", 350),
- h = pConfig->Read("h", 200);
- Move(x, y);
- SetClientSize(w, h);
-}
-
-void MyFrame::OnCloseWindow(wxCloseEvent& event)