]> git.saurik.com Git - wxWidgets.git/blame - samples/nativdlg/nativdlg.cpp
added wxGetTopLevelParent()
[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$
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
38MyFrame *frame = NULL;
39
40IMPLEMENT_APP(MyApp)
41
42// Testing of ressources
43MyApp::MyApp()
44{
45}
46
47bool MyApp::OnInit(void)
48{
49 // Create the main frame window
50 frame = new MyFrame(NULL, -1, "wxWindows Native Dialog Sample", wxPoint(0, 0), wxSize(300, 250));
51
52 // Give it a status line
53 frame->CreateStatusBar(2);
54
55 // Make a menubar
56 wxMenu *file_menu = new wxMenu;
57
58 file_menu->Append(RESOURCE_TEST1, "&Dialog box test", "Test dialog box resource");
59 file_menu->Append(RESOURCE_QUIT, "E&xit", "Quit program");
60
61 wxMenuBar *menu_bar = new wxMenuBar;
62
63 menu_bar->Append(file_menu, "&File");
64
65 // Associate the menu bar with the frame
66 frame->SetMenuBar(menu_bar);
67
68 // Make a panel
69 frame->panel = new wxWindow(frame, -1, wxPoint(0, 0), wxSize(400, 400), 0, "MyMainFrame");
70 frame->Show(TRUE);
71
72 // Return the main frame window
73 SetTopWindow(frame);
74
75 return TRUE;
76}
77
78BEGIN_EVENT_TABLE(MyFrame, wxFrame)
2f6c54eb
VZ
79 EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit)
80 EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1)
bbf1f0e5
KB
81END_EVENT_TABLE()
82
83// Define my frame constructor
84MyFrame::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
90void MyFrame::OnQuit(wxCommandEvent& event)
91{
2f6c54eb 92 Close(TRUE);
bbf1f0e5
KB
93}
94
95void MyFrame::OnTest1(wxCommandEvent& event)
96{
97 MyDialog *dialog = new MyDialog;
44c4a334 98 if (dialog->LoadNativeDialog(this, "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 111BEGIN_EVENT_TABLE(MyDialog, wxDialog)
2f6c54eb
VZ
112 EVT_BUTTON(wxID_OK, MyDialog::OnOk)
113 EVT_BUTTON(wxID_CANCEL, MyDialog::OnCancel)
bbf1f0e5
KB
114END_EVENT_TABLE()
115
116
117void MyDialog::OnOk(wxCommandEvent& event)
118{
119 EndModal(wxID_OK);
120}
121
122void MyDialog::OnCancel(wxCommandEvent& event)
123{
124 EndModal(wxID_CANCEL);
125}
126
127