in reply to Re^2: wxPreviewFrame error on closing
in thread wxPreviewFrame error on closing

The first thing I noticed was that wxPreviewFrame::OnCloseWindow isn't wrapped for wxPerl

It doesn't make sense to wrap it

http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk/src/common/prntbase.cpp

IMPLEMENT_CLASS(wxPreviewFrame, wxFrame) BEGIN_EVENT_TABLE(wxPreviewFrame, wxFrame) EVT_CLOSE(wxPreviewFrame::OnCloseWindow) END_EVENT_TABLE() ... void wxPreviewFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) { if (m_windowDisabler) delete m_windowDisabler; // Need to delete the printout and the print preview wxPrintout *printout = m_printPreview->GetPrintout(); if (printout) { delete printout; m_printPreview->SetPrintout(NULL); m_printPreview->SetCanvas(NULL); m_printPreview->SetFrame(NULL); } delete m_printPreview; Destroy(); }
It Seems to work, but the main frame, to which it is returned, is disabled (in my version of the code). Can I just enable it, or is that too easy?

You could do that, but as you can see above the wxWindowDisabler is deleted, which re-enables the previously disabled windows, so it should work already :)

Replies are listed 'Best First'.
Re^4: wxPreviewFrame error on closing
by Steve_BZ (Chaplain) on Sep 09, 2010 at 18:16 UTC

    Hi Anon,

    Well then, is it possible that one of the wrappings (maybe the one I did on RichTextPrintout) is not passing the event on to wxPrintout or whatever it's equivalent is? Because when I manually capture EVT_CLOSE and handle it, it's as near as I can get to the correct processing.

    Alternatively, I could mimic the above c-processing, but I'd need a couple of hints:

    1. How to access windowDisabler since I don't know its Hash-name or address-pointer within the parent object.
    2. I'm not sure what the difference between delete and Destroy() is. I guess delete is remove an element from a Hash and then Destroy() is remove the object. In Perl, wouldn't the deletes be automatic if you just Destroy()ed the object?

    So in that case all I have to do is to delete/Destroy() the windowDisabler as well.

    Regards

    Steve

      ..is not passing the event on to wxPrintout or whatever it's equivalent is?

      Not likely

      How to access ...

      Probably $self->SUPER::OnCloseWindow($event) or add a

      void DeleteWindowDisabler (){ if (m_windowDisabler) delete m_windowDisabler; }
      then call $self->DeleteWindowDisabler(); but like I said, it should work already :)

      I'm not sure what the difference between

      delete is delete (or undef), Destroy is the destructor, it gets called after the object goes out of scope or is deleted