Is it valid to take over the OnClose event of a form ?

Stef,

Stef Mientki wrote:

hello,

although the code below works very well,
I'm not sure if this a valid construct.
Or maybe it's valid but it might be bad code practice (although I don't know why ;-).

On some event (not exactly determined, so for the moment I've taken Right Mouse Click),
I generate a completely new frame (not modal), like this.
Now I want to know when the frame is closed, to perform reloading of some of my own properties,
so I take over the OnClose event.

def OnRightDown ( self, event ):
     self.frame = Scintilla_Editor ( self, self.filename )
     self.frame.Show(True)
     self.frame.Bind ( wx.EVT_CLOSE, self.OnTest )

And here I define in the main form, the Onclose of my created child frame.
The first 2 lines are copied from the OnClose event of the child frame.
def OnTest ( self, event ) :
     self.frame.STC.SaveFile ( self.frame.filename )
     self.frame.Destroy ()
     ... now here my own updating comes

I think this is perfectly fine, but I think you should add the event.Skip() to your close handling so the standard code for closing is done after your special handling is finished.

Werner