]>
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
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
24 #error Sorry, this sample is only appropriate under Windows.
27 #ifndef wxHAS_IMAGES_IN_RESOURCES
28 #include "../sample.xpm"
40 bool MyApp::OnInit(void)
42 if ( !wxApp::OnInit() )
45 // Create the main frame window
46 MyFrame
*frame
= new MyFrame(NULL
, wxID_ANY
, wxT("wxWidgets Native Dialog Sample"), wxPoint(0, 0), wxSize(300, 250));
49 // Give it a status line
50 frame
->CreateStatusBar(2);
51 #endif // wxUSE_STATUSBAR
54 wxMenu
*file_menu
= new wxMenu
;
56 file_menu
->Append(RESOURCE_TEST1
, wxT("&Dialog box test"), wxT("Test dialog box resource"));
57 file_menu
->Append(RESOURCE_QUIT
, wxT("E&xit"), wxT("Quit program"));
59 wxMenuBar
*menu_bar
= new wxMenuBar
;
61 menu_bar
->Append(file_menu
, wxT("&File"));
63 // Associate the menu bar with the frame
64 frame
->SetMenuBar(menu_bar
);
67 frame
->panel
= new wxWindow(frame
, wxID_ANY
, wxPoint(0, 0), wxSize(400, 400), 0, wxT("MyMainFrame"));
73 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
74 EVT_MENU(RESOURCE_QUIT
, MyFrame::OnQuit
)
75 EVT_MENU(RESOURCE_TEST1
, MyFrame::OnTest1
)
78 // Define my frame constructor
79 MyFrame::MyFrame(wxWindow
*parent
, const wxWindowID id
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
):
80 wxFrame(parent
, id
, title
, pos
, size
)
82 SetIcon(wxICON(sample
));
87 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
92 void MyFrame::OnTest1(wxCommandEvent
& WXUNUSED(event
))
94 #if ( defined(__WXPM__) || defined(__WXMSW__) ) && !defined(__WXUNIVERSAL__)
96 if (dialog
.LoadNativeDialog(this, wxT("dialog1")))
101 wxMessageBox(wxT("No native dialog support"),wxT("Platform limitation"));
105 BEGIN_EVENT_TABLE(MyDialog
, wxDialog
)
106 EVT_BUTTON(wxID_OK
, MyDialog::OnOk
)
107 EVT_BUTTON(wxID_CANCEL
, MyDialog::OnCancel
)
111 void MyDialog::OnOk(wxCommandEvent
& WXUNUSED(event
))
116 void MyDialog::OnCancel(wxCommandEvent
& WXUNUSED(event
))
118 EndModal(wxID_CANCEL
);