]>
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"
28 #error Sorry, this sample is only appropriate under Windows.
31 #include "wx/resource.h"
38 MyFrame
*frame
= NULL
;
42 // Testing of ressources
47 bool MyApp::OnInit(void)
49 // Create the main frame window
50 frame
= new MyFrame(NULL
, -1, _T("wxWindows Native Dialog Sample"), wxPoint(0, 0), wxSize(300, 250));
52 // Give it a status line
53 frame
->CreateStatusBar(2);
56 wxMenu
*file_menu
= new wxMenu
;
58 file_menu
->Append(RESOURCE_TEST1
, _T("&Dialog box test"), _T("Test dialog box resource"));
59 file_menu
->Append(RESOURCE_QUIT
, _T("E&xit"), _T("Quit program"));
61 wxMenuBar
*menu_bar
= new wxMenuBar
;
63 menu_bar
->Append(file_menu
, _T("&File"));
65 // Associate the menu bar with the frame
66 frame
->SetMenuBar(menu_bar
);
69 frame
->panel
= new wxWindow(frame
, -1, wxPoint(0, 0), wxSize(400, 400), 0, _T("MyMainFrame"));
72 // Return the main frame window
78 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
79 EVT_MENU(RESOURCE_QUIT
, MyFrame::OnQuit
)
80 EVT_MENU(RESOURCE_TEST1
, MyFrame::OnTest1
)
83 // Define my frame constructor
84 MyFrame::MyFrame(wxWindow
*parent
, const wxWindowID id
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
):
85 wxFrame(parent
, id
, title
, pos
, size
)
90 void MyFrame::OnQuit(wxCommandEvent
& event
)
95 void MyFrame::OnTest1(wxCommandEvent
& event
)
97 MyDialog
*dialog
= new MyDialog
;
98 if (dialog
->LoadNativeDialog(this, _T("dialog1")))
101 wxTextCtrl *text = (wxTextCtrl *)wxFindWindowByName("multitext3", dialog);
103 text->SetValue("wxWindows resource demo");
105 dialog
->SetModal(TRUE
);
111 BEGIN_EVENT_TABLE(MyDialog
, wxDialog
)
112 EVT_BUTTON(wxID_OK
, MyDialog::OnOk
)
113 EVT_BUTTON(wxID_CANCEL
, MyDialog::OnCancel
)
117 void MyDialog::OnOk(wxCommandEvent
& event
)
122 void MyDialog::OnCancel(wxCommandEvent
& event
)
124 EndModal(wxID_CANCEL
);