]>
git.saurik.com Git - wxWidgets.git/blob - samples/nativdlg/nativdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Native Windows dialog sample
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/resource.h"
34 MyFrame
*frame
= NULL
;
38 // Testing of ressources
43 bool MyApp::OnInit(void)
45 // Create the main frame window
46 frame
= new MyFrame(NULL
, -1, "wxWindows Native Dialog Sample", wxPoint(0, 0), wxSize(300, 250));
48 // Give it a status line
49 frame
->CreateStatusBar(2);
52 wxMenu
*file_menu
= new wxMenu
;
54 file_menu
->Append(RESOURCE_TEST1
, "&Dialog box test", "Test dialog box resource");
55 file_menu
->Append(RESOURCE_QUIT
, "E&xit", "Quit program");
57 wxMenuBar
*menu_bar
= new wxMenuBar
;
59 menu_bar
->Append(file_menu
, "&File");
61 // Associate the menu bar with the frame
62 frame
->SetMenuBar(menu_bar
);
65 frame
->panel
= new wxWindow(frame
, -1, wxPoint(0, 0), wxSize(400, 400), 0, "MyMainFrame");
68 // Return the main frame window
74 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
75 EVT_MENU(RESOURCE_QUIT
, MyFrame::OnQuit
)
76 EVT_MENU(RESOURCE_TEST1
, MyFrame::OnTest1
)
79 // Define my frame constructor
80 MyFrame::MyFrame(wxWindow
*parent
, const wxWindowID id
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
):
81 wxFrame(parent
, id
, title
, pos
, size
)
86 void MyFrame::OnQuit(wxCommandEvent
& event
)
91 void MyFrame::OnTest1(wxCommandEvent
& event
)
93 MyDialog
*dialog
= new MyDialog
;
94 if (dialog
->LoadNativeDialog(this, "dialog1"))
97 wxTextCtrl *text = (wxTextCtrl *)wxFindWindowByName("multitext3", dialog);
99 text->SetValue("wxWindows resource demo");
101 dialog
->SetModal(TRUE
);
107 bool MyFrame::OnClose(void)
114 BEGIN_EVENT_TABLE(MyDialog
, wxDialog
)
115 EVT_BUTTON(wxID_OK
, MyDialog::OnOk
)
116 EVT_BUTTON(wxID_CANCEL
, MyDialog::OnCancel
)
120 void MyDialog::OnOk(wxCommandEvent
& event
)
125 void MyDialog::OnCancel(wxCommandEvent
& event
)
127 EndModal(wxID_CANCEL
);