]>
git.saurik.com Git - wxWidgets.git/blob - samples/nativdlg/nativdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/nativdlg/nativdlg.cpp
3 // Purpose: Native Windows dialog sample
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx/wx.h".
12 #include "wx/wxprec.h"
23 #error Sorry, this sample is only appropriate under Windows.
26 #ifndef wxHAS_IMAGES_IN_RESOURCES
27 #include "../sample.xpm"
39 bool MyApp::OnInit(void)
41 if ( !wxApp::OnInit() )
44 // Create the main frame window
45 MyFrame
*frame
= new MyFrame(NULL
, wxID_ANY
, wxT("wxWidgets Native Dialog Sample"), wxPoint(0, 0), wxSize(300, 250));
48 // Give it a status line
49 frame
->CreateStatusBar(2);
50 #endif // wxUSE_STATUSBAR
53 wxMenu
*file_menu
= new wxMenu
;
55 file_menu
->Append(RESOURCE_TEST1
, wxT("&Dialog box test"), wxT("Test dialog box resource"));
56 file_menu
->Append(RESOURCE_QUIT
, wxT("E&xit"), wxT("Quit program"));
58 wxMenuBar
*menu_bar
= new wxMenuBar
;
60 menu_bar
->Append(file_menu
, wxT("&File"));
62 // Associate the menu bar with the frame
63 frame
->SetMenuBar(menu_bar
);
66 frame
->panel
= new wxWindow(frame
, wxID_ANY
, wxPoint(0, 0), wxSize(400, 400), 0, wxT("MyMainFrame"));
72 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
73 EVT_MENU(RESOURCE_QUIT
, MyFrame::OnQuit
)
74 EVT_MENU(RESOURCE_TEST1
, MyFrame::OnTest1
)
77 // Define my frame constructor
78 MyFrame::MyFrame(wxWindow
*parent
, const wxWindowID id
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
):
79 wxFrame(parent
, id
, title
, pos
, size
)
81 SetIcon(wxICON(sample
));
86 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
91 void MyFrame::OnTest1(wxCommandEvent
& WXUNUSED(event
))
93 #if ( defined(__WXPM__) || defined(__WXMSW__) ) && !defined(__WXUNIVERSAL__)
95 if (dialog
.LoadNativeDialog(this, wxT("dialog1")))
100 wxMessageBox(wxT("No native dialog support"),wxT("Platform limitation"));
104 BEGIN_EVENT_TABLE(MyDialog
, wxDialog
)
105 EVT_BUTTON(wxID_OK
, MyDialog::OnOk
)
106 EVT_BUTTON(wxID_CANCEL
, MyDialog::OnCancel
)
110 void MyDialog::OnOk(wxCommandEvent
& WXUNUSED(event
))
115 void MyDialog::OnCancel(wxCommandEvent
& WXUNUSED(event
))
117 EndModal(wxID_CANCEL
);