1998-05-20 10:21:00 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-10-27 12:01:45 -04:00
|
|
|
// Name: samples/nativdlg/nativdlg.cpp
|
1998-05-20 10:21:00 -04:00
|
|
|
// Purpose: Native Windows dialog sample
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 04/01/98
|
|
|
|
// RCS-ID: $Id$
|
2003-03-17 06:55:54 -05:00
|
|
|
// Copyright: (c) Julian Smart
|
2002-03-17 09:16:03 -05:00
|
|
|
// Licence: wxWindows license
|
1998-05-20 10:21:00 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
1999-02-04 06:14:41 -05:00
|
|
|
#ifndef __WXMSW__
|
|
|
|
#error Sorry, this sample is only appropriate under Windows.
|
|
|
|
#endif
|
|
|
|
|
1998-05-20 10:21:00 -04:00
|
|
|
#include <ctype.h>
|
|
|
|
#include "nativdlg.h"
|
|
|
|
#include "resource.h"
|
|
|
|
|
|
|
|
IMPLEMENT_APP(MyApp)
|
|
|
|
|
|
|
|
bool MyApp::OnInit(void)
|
|
|
|
{
|
2007-02-03 19:34:18 -05:00
|
|
|
if ( !wxApp::OnInit() )
|
|
|
|
return false;
|
|
|
|
|
1998-05-20 10:21:00 -04:00
|
|
|
// Create the main frame window
|
2004-05-25 07:20:37 -04:00
|
|
|
MyFrame *frame = new MyFrame(NULL, wxID_ANY, _T("wxWidgets Native Dialog Sample"), wxPoint(0, 0), wxSize(300, 250));
|
1998-05-20 10:21:00 -04:00
|
|
|
|
2004-07-19 11:36:01 -04:00
|
|
|
#if wxUSE_STATUSBAR
|
1998-05-20 10:21:00 -04:00
|
|
|
// Give it a status line
|
|
|
|
frame->CreateStatusBar(2);
|
2004-07-19 11:36:01 -04:00
|
|
|
#endif // wxUSE_STATUSBAR
|
1998-05-20 10:21:00 -04:00
|
|
|
|
|
|
|
// Make a menubar
|
|
|
|
wxMenu *file_menu = new wxMenu;
|
|
|
|
|
2002-12-15 12:25:36 -05:00
|
|
|
file_menu->Append(RESOURCE_TEST1, _T("&Dialog box test"), _T("Test dialog box resource"));
|
|
|
|
file_menu->Append(RESOURCE_QUIT, _T("E&xit"), _T("Quit program"));
|
1998-05-20 10:21:00 -04:00
|
|
|
|
|
|
|
wxMenuBar *menu_bar = new wxMenuBar;
|
|
|
|
|
2002-12-15 12:25:36 -05:00
|
|
|
menu_bar->Append(file_menu, _T("&File"));
|
1998-05-20 10:21:00 -04:00
|
|
|
|
|
|
|
// Associate the menu bar with the frame
|
|
|
|
frame->SetMenuBar(menu_bar);
|
|
|
|
|
|
|
|
// Make a panel
|
2004-02-07 10:34:13 -05:00
|
|
|
frame->panel = new wxWindow(frame, wxID_ANY, wxPoint(0, 0), wxSize(400, 400), 0, _T("MyMainFrame"));
|
|
|
|
frame->Show(true);
|
1998-05-20 10:21:00 -04:00
|
|
|
|
|
|
|
// Return the main frame window
|
|
|
|
SetTopWindow(frame);
|
|
|
|
|
2004-02-07 10:34:13 -05:00
|
|
|
return true;
|
1998-05-20 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
2002-03-17 09:16:03 -05:00
|
|
|
EVT_MENU(RESOURCE_QUIT, MyFrame::OnQuit)
|
|
|
|
EVT_MENU(RESOURCE_TEST1, MyFrame::OnTest1)
|
1998-05-20 10:21:00 -04:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
// Define my frame constructor
|
|
|
|
MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size):
|
|
|
|
wxFrame(parent, id, title, pos, size)
|
|
|
|
{
|
|
|
|
panel = NULL;
|
|
|
|
}
|
|
|
|
|
2004-02-07 10:34:13 -05:00
|
|
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
1998-05-20 10:21:00 -04:00
|
|
|
{
|
2004-02-07 10:34:13 -05:00
|
|
|
Close(true);
|
1998-05-20 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2004-02-07 10:34:13 -05:00
|
|
|
void MyFrame::OnTest1(wxCommandEvent& WXUNUSED(event))
|
1998-05-20 10:21:00 -04:00
|
|
|
{
|
2005-10-27 12:01:45 -04:00
|
|
|
#if ( defined(__WXPM__) || defined(__WXMSW__) ) && !defined(__WXUNIVERSAL__)
|
2004-07-13 09:13:29 -04:00
|
|
|
MyDialog dialog;
|
|
|
|
if (dialog.LoadNativeDialog(this, _T("dialog1")))
|
|
|
|
{
|
|
|
|
dialog.ShowModal();
|
|
|
|
}
|
2004-02-07 10:34:13 -05:00
|
|
|
#else
|
2004-07-13 09:13:29 -04:00
|
|
|
wxMessageBox(_T("No native dialog support"),_T("Platform limitation"));
|
2004-02-07 10:34:13 -05:00
|
|
|
#endif
|
1998-05-20 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
|
2002-03-17 09:16:03 -05:00
|
|
|
EVT_BUTTON(wxID_OK, MyDialog::OnOk)
|
|
|
|
EVT_BUTTON(wxID_CANCEL, MyDialog::OnCancel)
|
1998-05-20 10:21:00 -04:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2004-02-07 10:34:13 -05:00
|
|
|
void MyDialog::OnOk(wxCommandEvent& WXUNUSED(event))
|
1998-05-20 10:21:00 -04:00
|
|
|
{
|
|
|
|
EndModal(wxID_OK);
|
|
|
|
}
|
|
|
|
|
2004-02-07 10:34:13 -05:00
|
|
|
void MyDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
1998-05-20 10:21:00 -04:00
|
|
|
{
|
|
|
|
EndModal(wxID_CANCEL);
|
|
|
|
}
|