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