]> git.saurik.com Git - wxWidgets.git/blame - samples/nativdlg/nativdlg.cpp
Added wxStringBufferLength: works like wxStringBuffer, except
[wxWidgets.git] / samples / nativdlg / nativdlg.cpp
CommitLineData
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$
6aa89a22 8// Copyright: (c) Julian Smart
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 <ctype.h>
32#include "nativdlg.h"
33#include "resource.h"
34
35// Declare two frames
36MyFrame *frame = NULL;
37
38IMPLEMENT_APP(MyApp)
39
40// Testing of ressources
41MyApp::MyApp()
42{
43}
44
45bool MyApp::OnInit(void)
46{
47 // Create the main frame window
600683ca 48 frame = new MyFrame(NULL, -1, _T("wxWindows Native Dialog Sample"), wxPoint(0, 0), wxSize(300, 250));
bbf1f0e5
KB
49
50 // Give it a status line
51 frame->CreateStatusBar(2);
52
53 // Make a menubar
54 wxMenu *file_menu = new wxMenu;
55
600683ca
MB
56 file_menu->Append(RESOURCE_TEST1, _T("&Dialog box test"), _T("Test dialog box resource"));
57 file_menu->Append(RESOURCE_QUIT, _T("E&xit"), _T("Quit program"));
bbf1f0e5
KB
58
59 wxMenuBar *menu_bar = new wxMenuBar;
60
600683ca 61 menu_bar->Append(file_menu, _T("&File"));
bbf1f0e5
KB
62
63 // Associate the menu bar with the frame
64 frame->SetMenuBar(menu_bar);
65
66 // Make a panel
600683ca 67 frame->panel = new wxWindow(frame, -1, wxPoint(0, 0), wxSize(400, 400), 0, _T("MyMainFrame"));
bbf1f0e5
KB
68 frame->Show(TRUE);
69
70 // Return the main frame window
71 SetTopWindow(frame);
72
73 return TRUE;
74}
75
76BEGIN_EVENT_TABLE(MyFrame, wxFrame)
2f6c54eb
VZ
77 EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit)
78 EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1)
bbf1f0e5
KB
79END_EVENT_TABLE()
80
81// Define my frame constructor
82MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size):
83 wxFrame(parent, id, title, pos, size)
84{
85 panel = NULL;
86}
87
88void MyFrame::OnQuit(wxCommandEvent& event)
89{
2f6c54eb 90 Close(TRUE);
bbf1f0e5
KB
91}
92
93void MyFrame::OnTest1(wxCommandEvent& event)
94{
95 MyDialog *dialog = new MyDialog;
600683ca 96 if (dialog->LoadNativeDialog(this, _T("dialog1")))
bbf1f0e5 97 {
bbf1f0e5
KB
98 dialog->SetModal(TRUE);
99 dialog->ShowModal();
100 }
101 dialog->Close(TRUE);
102}
103
bbf1f0e5 104BEGIN_EVENT_TABLE(MyDialog, wxDialog)
2f6c54eb
VZ
105 EVT_BUTTON(wxID_OK, MyDialog::OnOk)
106 EVT_BUTTON(wxID_CANCEL, MyDialog::OnCancel)
bbf1f0e5
KB
107END_EVENT_TABLE()
108
109
110void MyDialog::OnOk(wxCommandEvent& event)
111{
112 EndModal(wxID_OK);
113}
114
115void MyDialog::OnCancel(wxCommandEvent& event)
116{
117 EndModal(wxID_CANCEL);
118}
119
120