]> git.saurik.com Git - wxWidgets.git/blame - samples/nativdlg/nativdlg.cpp
wxSplash sample code, sample image, bake and make files.
[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
bbf1f0e5
KB
35IMPLEMENT_APP(MyApp)
36
37// Testing of ressources
38MyApp::MyApp()
39{
40}
41
42bool MyApp::OnInit(void)
43{
44 // Create the main frame window
be5a51fb 45 MyFrame *frame = new MyFrame(NULL, wxID_ANY, _T("wxWidgets Native Dialog Sample"), wxPoint(0, 0), wxSize(300, 250));
bbf1f0e5 46
8520f137 47#if wxUSE_STATUSBAR
bbf1f0e5
KB
48 // Give it a status line
49 frame->CreateStatusBar(2);
8520f137 50#endif // wxUSE_STATUSBAR
bbf1f0e5
KB
51
52 // Make a menubar
53 wxMenu *file_menu = new wxMenu;
54
600683ca
MB
55 file_menu->Append(RESOURCE_TEST1, _T("&Dialog box test"), _T("Test dialog box resource"));
56 file_menu->Append(RESOURCE_QUIT, _T("E&xit"), _T("Quit program"));
bbf1f0e5
KB
57
58 wxMenuBar *menu_bar = new wxMenuBar;
59
600683ca 60 menu_bar->Append(file_menu, _T("&File"));
bbf1f0e5
KB
61
62 // Associate the menu bar with the frame
63 frame->SetMenuBar(menu_bar);
64
65 // Make a panel
1e79049d
VZ
66 frame->panel = new wxWindow(frame, wxID_ANY, wxPoint(0, 0), wxSize(400, 400), 0, _T("MyMainFrame"));
67 frame->Show(true);
bbf1f0e5
KB
68
69 // Return the main frame window
70 SetTopWindow(frame);
71
1e79049d 72 return true;
bbf1f0e5
KB
73}
74
75BEGIN_EVENT_TABLE(MyFrame, wxFrame)
2f6c54eb
VZ
76 EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit)
77 EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1)
bbf1f0e5
KB
78END_EVENT_TABLE()
79
80// Define my frame constructor
81MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size):
82 wxFrame(parent, id, title, pos, size)
83{
84 panel = NULL;
85}
86
1e79049d 87void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
bbf1f0e5 88{
1e79049d 89 Close(true);
bbf1f0e5
KB
90}
91
1e79049d 92void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
bbf1f0e5 93{
1e79049d 94#if ( defined(__WXOS2__) || defined(__WXMSW__) ) && !defined(__WXUNIVERSAL__)
a61fea41
WS
95 MyDialog dialog;
96 if (dialog.LoadNativeDialog(this, _T("dialog1")))
97 {
98 dialog.ShowModal();
99 }
1e79049d 100#else
a61fea41 101 wxMessageBox(_T("No native dialog support"),_T("Platform limitation"));
1e79049d 102#endif
bbf1f0e5
KB
103}
104
bbf1f0e5 105BEGIN_EVENT_TABLE(MyDialog, wxDialog)
2f6c54eb
VZ
106 EVT_BUTTON(wxID_OK, MyDialog::OnOk)
107 EVT_BUTTON(wxID_CANCEL, MyDialog::OnCancel)
bbf1f0e5
KB
108END_EVENT_TABLE()
109
110
1e79049d 111void MyDialog::OnOk(wxCommandEvent& WXUNUSED(event))
bbf1f0e5
KB
112{
113 EndModal(wxID_OK);
114}
115
1e79049d 116void MyDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
bbf1f0e5
KB
117{
118 EndModal(wxID_CANCEL);
119}
120
121