]> git.saurik.com Git - wxWidgets.git/blame - samples/nativdlg/nativdlg.cpp
OnTabEndDrag() didn't handle NULL src_tabs case correctly but it seems that this...
[wxWidgets.git] / samples / nativdlg / nativdlg.cpp
CommitLineData
bbf1f0e5 1/////////////////////////////////////////////////////////////////////////////
cb7d7375 2// Name: samples/nativdlg/nativdlg.cpp
bbf1f0e5
KB
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
bbf1f0e5
KB
12// For compilers that support precompilation, includes "wx/wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16#pragma hdrstop
17#endif
18
19#ifndef WX_PRECOMP
20#include "wx/wx.h"
21#endif
22
acbd13a3
JS
23#ifndef __WXMSW__
24#error Sorry, this sample is only appropriate under Windows.
25#endif
26
bbf1f0e5
KB
27#include <ctype.h>
28#include "nativdlg.h"
29#include "resource.h"
30
bbf1f0e5
KB
31IMPLEMENT_APP(MyApp)
32
bbf1f0e5
KB
33bool MyApp::OnInit(void)
34{
45e6e6f8
VZ
35 if ( !wxApp::OnInit() )
36 return false;
37
bbf1f0e5 38 // Create the main frame window
be5a51fb 39 MyFrame *frame = new MyFrame(NULL, wxID_ANY, _T("wxWidgets Native Dialog Sample"), wxPoint(0, 0), wxSize(300, 250));
bbf1f0e5 40
8520f137 41#if wxUSE_STATUSBAR
bbf1f0e5
KB
42 // Give it a status line
43 frame->CreateStatusBar(2);
8520f137 44#endif // wxUSE_STATUSBAR
bbf1f0e5
KB
45
46 // Make a menubar
47 wxMenu *file_menu = new wxMenu;
48
600683ca
MB
49 file_menu->Append(RESOURCE_TEST1, _T("&Dialog box test"), _T("Test dialog box resource"));
50 file_menu->Append(RESOURCE_QUIT, _T("E&xit"), _T("Quit program"));
bbf1f0e5
KB
51
52 wxMenuBar *menu_bar = new wxMenuBar;
53
600683ca 54 menu_bar->Append(file_menu, _T("&File"));
bbf1f0e5
KB
55
56 // Associate the menu bar with the frame
57 frame->SetMenuBar(menu_bar);
58
59 // Make a panel
1e79049d
VZ
60 frame->panel = new wxWindow(frame, wxID_ANY, wxPoint(0, 0), wxSize(400, 400), 0, _T("MyMainFrame"));
61 frame->Show(true);
bbf1f0e5
KB
62
63 // Return the main frame window
64 SetTopWindow(frame);
65
1e79049d 66 return true;
bbf1f0e5
KB
67}
68
69BEGIN_EVENT_TABLE(MyFrame, wxFrame)
2f6c54eb
VZ
70 EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit)
71 EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1)
bbf1f0e5
KB
72END_EVENT_TABLE()
73
74// Define my frame constructor
75MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size):
76 wxFrame(parent, id, title, pos, size)
77{
78 panel = NULL;
79}
80
1e79049d 81void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
bbf1f0e5 82{
1e79049d 83 Close(true);
bbf1f0e5
KB
84}
85
1e79049d 86void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
bbf1f0e5 87{
cb7d7375 88#if ( defined(__WXPM__) || defined(__WXMSW__) ) && !defined(__WXUNIVERSAL__)
a61fea41
WS
89 MyDialog dialog;
90 if (dialog.LoadNativeDialog(this, _T("dialog1")))
91 {
92 dialog.ShowModal();
93 }
1e79049d 94#else
a61fea41 95 wxMessageBox(_T("No native dialog support"),_T("Platform limitation"));
1e79049d 96#endif
bbf1f0e5
KB
97}
98
bbf1f0e5 99BEGIN_EVENT_TABLE(MyDialog, wxDialog)
2f6c54eb
VZ
100 EVT_BUTTON(wxID_OK, MyDialog::OnOk)
101 EVT_BUTTON(wxID_CANCEL, MyDialog::OnCancel)
bbf1f0e5
KB
102END_EVENT_TABLE()
103
104
1e79049d 105void MyDialog::OnOk(wxCommandEvent& WXUNUSED(event))
bbf1f0e5
KB
106{
107 EndModal(wxID_OK);
108}
109
1e79049d 110void MyDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
bbf1f0e5
KB
111{
112 EndModal(wxID_CANCEL);
113}