]>
Commit | Line | Data |
---|---|---|
bbf1f0e5 KB |
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 and Markus Holzem | |
2f6c54eb | 9 | // Licence: wxWindows license |
bbf1f0e5 KB |
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 | ||
acbd13a3 JS |
27 | #ifndef __WXMSW__ |
28 | #error Sorry, this sample is only appropriate under Windows. | |
29 | #endif | |
30 | ||
bbf1f0e5 KB |
31 | #include "wx/resource.h" |
32 | ||
33 | #include <ctype.h> | |
34 | #include "nativdlg.h" | |
35 | #include "resource.h" | |
36 | ||
37 | // Declare two frames | |
38 | MyFrame *frame = NULL; | |
39 | ||
40 | IMPLEMENT_APP(MyApp) | |
41 | ||
42 | // Testing of ressources | |
43 | MyApp::MyApp() | |
44 | { | |
45 | } | |
46 | ||
47 | bool MyApp::OnInit(void) | |
48 | { | |
49 | // Create the main frame window | |
600683ca | 50 | frame = new MyFrame(NULL, -1, _T("wxWindows Native Dialog Sample"), wxPoint(0, 0), wxSize(300, 250)); |
bbf1f0e5 KB |
51 | |
52 | // Give it a status line | |
53 | frame->CreateStatusBar(2); | |
54 | ||
55 | // Make a menubar | |
56 | wxMenu *file_menu = new wxMenu; | |
57 | ||
600683ca MB |
58 | file_menu->Append(RESOURCE_TEST1, _T("&Dialog box test"), _T("Test dialog box resource")); |
59 | file_menu->Append(RESOURCE_QUIT, _T("E&xit"), _T("Quit program")); | |
bbf1f0e5 KB |
60 | |
61 | wxMenuBar *menu_bar = new wxMenuBar; | |
62 | ||
600683ca | 63 | menu_bar->Append(file_menu, _T("&File")); |
bbf1f0e5 KB |
64 | |
65 | // Associate the menu bar with the frame | |
66 | frame->SetMenuBar(menu_bar); | |
67 | ||
68 | // Make a panel | |
600683ca | 69 | frame->panel = new wxWindow(frame, -1, wxPoint(0, 0), wxSize(400, 400), 0, _T("MyMainFrame")); |
bbf1f0e5 KB |
70 | frame->Show(TRUE); |
71 | ||
72 | // Return the main frame window | |
73 | SetTopWindow(frame); | |
74 | ||
75 | return TRUE; | |
76 | } | |
77 | ||
78 | BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |
2f6c54eb VZ |
79 | EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit) |
80 | EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1) | |
bbf1f0e5 KB |
81 | END_EVENT_TABLE() |
82 | ||
83 | // Define my frame constructor | |
84 | MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size): | |
85 | wxFrame(parent, id, title, pos, size) | |
86 | { | |
87 | panel = NULL; | |
88 | } | |
89 | ||
90 | void MyFrame::OnQuit(wxCommandEvent& event) | |
91 | { | |
2f6c54eb | 92 | Close(TRUE); |
bbf1f0e5 KB |
93 | } |
94 | ||
95 | void MyFrame::OnTest1(wxCommandEvent& event) | |
96 | { | |
97 | MyDialog *dialog = new MyDialog; | |
600683ca | 98 | if (dialog->LoadNativeDialog(this, _T("dialog1"))) |
bbf1f0e5 KB |
99 | { |
100 | /* | |
101 | wxTextCtrl *text = (wxTextCtrl *)wxFindWindowByName("multitext3", dialog); | |
102 | if (text) | |
103 | text->SetValue("wxWindows resource demo"); | |
104 | */ | |
105 | dialog->SetModal(TRUE); | |
106 | dialog->ShowModal(); | |
107 | } | |
108 | dialog->Close(TRUE); | |
109 | } | |
110 | ||
bbf1f0e5 | 111 | BEGIN_EVENT_TABLE(MyDialog, wxDialog) |
2f6c54eb VZ |
112 | EVT_BUTTON(wxID_OK, MyDialog::OnOk) |
113 | EVT_BUTTON(wxID_CANCEL, MyDialog::OnCancel) | |
bbf1f0e5 KB |
114 | END_EVENT_TABLE() |
115 | ||
116 | ||
117 | void MyDialog::OnOk(wxCommandEvent& event) | |
118 | { | |
119 | EndModal(wxID_OK); | |
120 | } | |
121 | ||
122 | void MyDialog::OnCancel(wxCommandEvent& event) | |
123 | { | |
124 | EndModal(wxID_CANCEL); | |
125 | } | |
126 | ||
127 |