Closed paule32 closed 7 months ago
That's because the cmClose
command is also handled by TWindow::eventHandle
. So, in this case, you should check for the cmClose
command before calling TWindow::eventHandle
.
However, you must take into account that the close()
method destroys the current object, so you must make sure that you do not interact with it after calling close()
: do not call clearEvent
nor TWindow::handleEvent
if you called close()
. For example:
void handleEvent(TEvent & event ){
// Handle cmClose first to override the handling in TWindow.
if (event.what == evCommand && event.message.command == cmClose)
{
messageBox("blaa blaa",mfInformation|mfOKButton);
clearEvent(event);
close();
// Don't do anything after close().
return;
}
TWindow::handleEvent( event );
// Handle other events...
}
Or even better, override the close
method:
void close() override {
messageBox("blaa blaa",mfInformation|mfOKButton);
TWindow::close();
}
Then you won't have to do anything special in your handleEvent
.
Thank You. This was a great Solution !
Hello, I have a TDialog, but I can not trace the "Close" Action, when I click the left top Corner, to close the TDialog. I have add flags, but the handleEvent Event-Handler shows me not the MessageBox.
How can I make Action's when Windows/Dialogs are closed ?