]> git.saurik.com Git - wxWidgets.git/blob - samples/nativdlg/nativdlg.cpp
fix sizing of extra control
[wxWidgets.git] / samples / nativdlg / nativdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/nativdlg/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 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/wx.h"
21 #endif
22
23 #ifndef __WXMSW__
24 #error Sorry, this sample is only appropriate under Windows.
25 #endif
26
27 #include <ctype.h>
28 #include "nativdlg.h"
29 #include "resource.h"
30
31 IMPLEMENT_APP(MyApp)
32
33 bool MyApp::OnInit(void)
34 {
35 if ( !wxApp::OnInit() )
36 return false;
37
38 // Create the main frame window
39 MyFrame *frame = new MyFrame(NULL, wxID_ANY, _T("wxWidgets Native Dialog Sample"), wxPoint(0, 0), wxSize(300, 250));
40
41 #if wxUSE_STATUSBAR
42 // Give it a status line
43 frame->CreateStatusBar(2);
44 #endif // wxUSE_STATUSBAR
45
46 // Make a menubar
47 wxMenu *file_menu = new wxMenu;
48
49 file_menu->Append(RESOURCE_TEST1, _T("&Dialog box test"), _T("Test dialog box resource"));
50 file_menu->Append(RESOURCE_QUIT, _T("E&xit"), _T("Quit program"));
51
52 wxMenuBar *menu_bar = new wxMenuBar;
53
54 menu_bar->Append(file_menu, _T("&File"));
55
56 // Associate the menu bar with the frame
57 frame->SetMenuBar(menu_bar);
58
59 // Make a panel
60 frame->panel = new wxWindow(frame, wxID_ANY, wxPoint(0, 0), wxSize(400, 400), 0, _T("MyMainFrame"));
61 frame->Show(true);
62
63 // Return the main frame window
64 SetTopWindow(frame);
65
66 return true;
67 }
68
69 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
70 EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit)
71 EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1)
72 END_EVENT_TABLE()
73
74 // Define my frame constructor
75 MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size):
76 wxFrame(parent, id, title, pos, size)
77 {
78 panel = NULL;
79 }
80
81 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
82 {
83 Close(true);
84 }
85
86 void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
87 {
88 #if ( defined(__WXPM__) || defined(__WXMSW__) ) && !defined(__WXUNIVERSAL__)
89 MyDialog dialog;
90 if (dialog.LoadNativeDialog(this, _T("dialog1")))
91 {
92 dialog.ShowModal();
93 }
94 #else
95 wxMessageBox(_T("No native dialog support"),_T("Platform limitation"));
96 #endif
97 }
98
99 BEGIN_EVENT_TABLE(MyDialog, wxDialog)
100 EVT_BUTTON(wxID_OK, MyDialog::OnOk)
101 EVT_BUTTON(wxID_CANCEL, MyDialog::OnCancel)
102 END_EVENT_TABLE()
103
104
105 void MyDialog::OnOk(wxCommandEvent& WXUNUSED(event))
106 {
107 EndModal(wxID_OK);
108 }
109
110 void MyDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
111 {
112 EndModal(wxID_CANCEL);
113 }