added a test to check how exception handling works with Win32 SEH; corrected copyright
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31222 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: except.cpp
|
// Name: samples/except/except.cpp
|
||||||
// Purpose: Except wxWidgets sample
|
// Purpose: shows how C++ exceptions can be used in wxWidgets
|
||||||
// Author: Julian Smart
|
// Author: Vadim Zeitlin
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: 04/01/98
|
// Created: 2003-09-17
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart
|
// Copyright: (c) 2003-2005 Vadim Zeitlin
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -24,6 +24,10 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !wxUSE_EXCEPTIONS
|
||||||
|
#error "This sample only works with wxUSE_EXCEPTIONS == 1"
|
||||||
|
#endif // !wxUSE_EXCEPTIONS
|
||||||
|
|
||||||
// for all others, include the necessary headers (this file is usually all you
|
// for all others, include the necessary headers (this file is usually all you
|
||||||
// need because it includes almost all "standard" wxWidgets headers)
|
// need because it includes almost all "standard" wxWidgets headers)
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
@@ -107,6 +111,7 @@ public:
|
|||||||
// event handlers
|
// event handlers
|
||||||
void OnThrowInt(wxCommandEvent& event);
|
void OnThrowInt(wxCommandEvent& event);
|
||||||
void OnThrowObject(wxCommandEvent& event);
|
void OnThrowObject(wxCommandEvent& event);
|
||||||
|
void OnCrash(wxCommandEvent& event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
@@ -134,6 +139,7 @@ enum
|
|||||||
// control ids
|
// control ids
|
||||||
Except_ThrowInt = 100,
|
Except_ThrowInt = 100,
|
||||||
Except_ThrowObject,
|
Except_ThrowObject,
|
||||||
|
Except_Crash,
|
||||||
|
|
||||||
// menu items
|
// menu items
|
||||||
Except_ThrowString = 200,
|
Except_ThrowString = 200,
|
||||||
@@ -160,6 +166,7 @@ END_EVENT_TABLE()
|
|||||||
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
|
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
|
||||||
EVT_BUTTON(Except_ThrowInt, MyDialog::OnThrowInt)
|
EVT_BUTTON(Except_ThrowInt, MyDialog::OnThrowInt)
|
||||||
EVT_BUTTON(Except_ThrowObject, MyDialog::OnThrowObject)
|
EVT_BUTTON(Except_ThrowObject, MyDialog::OnThrowObject)
|
||||||
|
EVT_BUTTON(Except_Crash, MyDialog::OnCrash)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
// Create a new application object: this macro will allow wxWidgets to create
|
// Create a new application object: this macro will allow wxWidgets to create
|
||||||
@@ -311,6 +318,8 @@ MyDialog::MyDialog(wxFrame *parent)
|
|||||||
0, wxCENTRE | wxALL, 5);
|
0, wxCENTRE | wxALL, 5);
|
||||||
sizerTop->Add(new wxButton(this, Except_ThrowObject, _T("Throw &object")),
|
sizerTop->Add(new wxButton(this, Except_ThrowObject, _T("Throw &object")),
|
||||||
0, wxCENTRE | wxALL, 5);
|
0, wxCENTRE | wxALL, 5);
|
||||||
|
sizerTop->Add(new wxButton(this, Except_Crash, _T("&Crash")),
|
||||||
|
0, wxCENTRE | wxALL, 5);
|
||||||
sizerTop->Add(new wxButton(this, wxID_CANCEL, _T("&Cancel")),
|
sizerTop->Add(new wxButton(this, wxID_CANCEL, _T("&Cancel")),
|
||||||
0, wxCENTRE | wxALL, 5);
|
0, wxCENTRE | wxALL, 5);
|
||||||
|
|
||||||
@@ -328,3 +337,9 @@ void MyDialog::OnThrowObject(wxCommandEvent& WXUNUSED(event))
|
|||||||
throw MyException(_T("Exception thrown from the dialog"));
|
throw MyException(_T("Exception thrown from the dialog"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyDialog::OnCrash(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
char *p = 0;
|
||||||
|
strcpy(p, "Let's crash");
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user