]> git.saurik.com Git - wxWidgets.git/blob - samples/nativdlg/nativdlg.cpp
Unicode compilation fix
[wxWidgets.git] / samples / nativdlg / nativdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: nativdlg.cpp
3 // Purpose: Native Windows dialog sample
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/wx.h"
25 #endif
26
27 #ifndef __WXMSW__
28 #error Sorry, this sample is only appropriate under Windows.
29 #endif
30
31 #include <ctype.h>
32 #include "nativdlg.h"
33 #include "resource.h"
34
35 IMPLEMENT_APP(MyApp)
36
37 bool MyApp::OnInit(void)
38 {
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));
41
42 #if wxUSE_STATUSBAR
43 // Give it a status line
44 frame->CreateStatusBar(2);
45 #endif // wxUSE_STATUSBAR
46
47 // Make a menubar
48 wxMenu *file_menu = new wxMenu;
49
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"));
52
53 wxMenuBar *menu_bar = new wxMenuBar;
54
55 menu_bar->Append(file_menu, _T("&File"));
56
57 // Associate the menu bar with the frame
58 frame->SetMenuBar(menu_bar);
59
60 // Make a panel
61 frame->panel = new wxWindow(frame, wxID_ANY, wxPoint(0, 0), wxSize(400, 400), 0, _T("MyMainFrame"));
62 frame->Show(true);
63
64 // Return the main frame window
65 SetTopWindow(frame);
66
67 return true;
68 }
69
70 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
71 EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit)
72 EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1)
73 END_EVENT_TABLE()
74
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)
78 {
79 panel = NULL;
80 }
81
82 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
83 {
84 Close(true);
85 }
86
87 void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
88 {
89 #if ( defined(__WXOS2__) || defined(__WXMSW__) ) && !defined(__WXUNIVERSAL__)
90 MyDialog dialog;
91 if (dialog.LoadNativeDialog(this, _T("dialog1")))
92 {
93 dialog.ShowModal();
94 }
95 #else
96 wxMessageBox(_T("No native dialog support"),_T("Platform limitation"));
97 #endif
98 }
99
100 BEGIN_EVENT_TABLE(MyDialog, wxDialog)
101 EVT_BUTTON(wxID_OK, MyDialog::OnOk)
102 EVT_BUTTON(wxID_CANCEL, MyDialog::OnCancel)
103 END_EVENT_TABLE()
104
105
106 void MyDialog::OnOk(wxCommandEvent& WXUNUSED(event))
107 {
108 EndModal(wxID_OK);
109 }
110
111 void MyDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
112 {
113 EndModal(wxID_CANCEL);
114 }
115
116