]>
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
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.
37 bool MyApp::OnInit(void)
39 // Create the main frame window
40 MyFrame
*frame
= new MyFrame(NULL
, wxID_ANY
, _T("wxWidgets Native Dialog Sample"), wxPoint(0, 0), wxSize(300, 250));
43 // Give it a status line
44 frame
->CreateStatusBar(2);
45 #endif // wxUSE_STATUSBAR
48 wxMenu
*file_menu
= new wxMenu
;
50 file_menu
->Append(RESOURCE_TEST1
, _T("&Dialog box test"), _T("Test dialog box resource"));
51 file_menu
->Append(RESOURCE_QUIT
, _T("E&xit"), _T("Quit program"));
53 wxMenuBar
*menu_bar
= new wxMenuBar
;
55 menu_bar
->Append(file_menu
, _T("&File"));
57 // Associate the menu bar with the frame
58 frame
->SetMenuBar(menu_bar
);
61 frame
->panel
= new wxWindow(frame
, wxID_ANY
, wxPoint(0, 0), wxSize(400, 400), 0, _T("MyMainFrame"));
64 // Return the main frame window
70 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
71 EVT_MENU(RESOURCE_QUIT
, MyFrame::OnQuit
)
72 EVT_MENU(RESOURCE_TEST1
, MyFrame::OnTest1
)
75 // Define my frame constructor
76 MyFrame::MyFrame(wxWindow
*parent
, const wxWindowID id
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
):
77 wxFrame(parent
, id
, title
, pos
, size
)
82 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
87 void MyFrame::OnTest1(wxCommandEvent
& WXUNUSED(event
))
89 #if ( defined(__WXOS2__) || defined(__WXMSW__) ) && !defined(__WXUNIVERSAL__)
91 if (dialog
.LoadNativeDialog(this, _T("dialog1")))
96 wxMessageBox(_T("No native dialog support"),_T("Platform limitation"));
100 BEGIN_EVENT_TABLE(MyDialog
, wxDialog
)
101 EVT_BUTTON(wxID_OK
, MyDialog::OnOk
)
102 EVT_BUTTON(wxID_CANCEL
, MyDialog::OnCancel
)
106 void MyDialog::OnOk(wxCommandEvent
& WXUNUSED(event
))
111 void MyDialog::OnCancel(wxCommandEvent
& WXUNUSED(event
))
113 EndModal(wxID_CANCEL
);