+ wxMenu *menuFile = new wxMenu;
+ menuFile->Append(DebugRpt_Quit, _T("E&xit\tAlt-X"));
+
+ wxMenu *menuReport = new wxMenu;
+ menuReport->Append(DebugRpt_Crash, _T("Report for &crash\tCtrl-C"),
+ _T("Provoke a crash inside the program and create report for it"));
+ menuReport->Append(DebugRpt_Current, _T("Report for c&urrent context\tCtrl-U"),
+ _T("Create report for the current program context"));
+ menuReport->Append(DebugRpt_Paint, _T("Report for &paint handler\tCtrl-P"),
+ _T("Provoke a repeatable crash in wxEVT_PAINT handler"));
+ menuReport->AppendSeparator();
+ menuReport->AppendCheckItem(DebugRpt_Upload, _T("Up&load debug report"),
+ _T("You need to configure a web server accepting debug report uploads to use this function"));
+
+ wxMenu *menuHelp = new wxMenu;
+ menuHelp->Append(DebugRpt_About, _T("&About...\tF1"));
+
+ wxMenuBar *mbar = new wxMenuBar();
+ mbar->Append(menuFile, _T("&File"));
+ mbar->Append(menuReport, _T("&Report"));
+ mbar->Append(menuHelp, _T("&Help"));
+ SetMenuBar(mbar);
+
+ CreateStatusBar();
+
+ Show();
+}
+
+void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
+{
+ Close(true);
+}
+
+void MyFrame::OnReportForCrash(wxCommandEvent& WXUNUSED(event))
+{
+ // this call is going to crash
+ foo(32);
+ foo(17);
+}
+
+void MyFrame::OnReportForCurrent(wxCommandEvent& WXUNUSED(event))
+{
+ // example of manually generated report, this could be also
+ // used in wxApp::OnAssert()
+ wxGetApp().GenerateReport(wxDebugReport::Context_Current);
+}
+
+void MyFrame::OnReportPaint(wxCommandEvent& WXUNUSED(event))
+{
+ // this will result in a crash in OnPaint()
+ m_numLines = 0;
+
+ // ensure it's called immediately
+ Refresh();
+}
+
+void MyFrame::OnReportUpload(wxCommandEvent& event)
+{
+ wxGetApp().UploadReport(event.IsChecked());
+}
+
+void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
+{
+ wxMessageBox
+ (
+ _T("wxDebugReport sample\n(c) 2005 Vadim Zeitlin <vadim@wxwindows.org>"),
+ _T("wxWidgets Debug Report Sample"),
+ wxOK | wxICON_INFORMATION,
+ this
+ );
+}
+
+void MyFrame::OnPaint(wxPaintEvent& WXUNUSED(event))
+{
+ wxPaintDC dc(this);
+ const wxSize size = GetClientSize();
+ for ( wxCoord x = 0; x < size.x; x += size.x/m_numLines )
+ dc.DrawLine(x, 0, x, size.y);
+}
+
+// ----------------------------------------------------------------------------
+// MyApp
+// ----------------------------------------------------------------------------
+
+MyApp::MyApp()
+{
+ // user needs to explicitely enable this
+ m_uploadReport = false;
+
+ // call this to tell the library to call our OnFatalException()
+ wxHandleFatalExceptions();
+}
+
+bool MyApp::OnInit()
+{
+ if ( !wxApp::OnInit() )
+ return false;
+
+ new MyFrame;
+
+ return true;
+}
+
+void MyApp::OnFatalException()
+{
+ GenerateReport(wxDebugReport::Context_Exception);
+}
+
+void MyApp::GenerateReport(wxDebugReport::Context ctx)
+{
+ wxDebugReportCompress *report = m_uploadReport ? new MyDebugReport
+ : new wxDebugReportCompress;
+
+ // add all standard files: currently this means just a minidump and an
+ // XML file with system info and stack trace
+ report->AddAll(ctx);
+
+ // you can also call report->AddFile(...) with your own log files, files
+ // created using wxRegKey::Export() and so on, here we just add a test
+ // file containing the date of the crash
+ wxFileName fn(report->GetDirectory(), _T("timestamp.my"));
+ wxFFile file(fn.GetFullPath(), _T("w"));
+ if ( file.IsOpened() )