Intercepting form events

S

Steve McLellan

Hi all,

I'm trying to override Form events (for example OnClosing or OnClose) with
the intention of preventing the base class function from happening. My
functions are getting called but so are the base class ones, which isn't
what I want (for example, I was hoping an empty OnClose event would make
closing the form impossible). Two questions: 1) Is this the right way to do
this, or should I be detaching event handlers? and 2) Any reason why I'm
getting this behaviour?

Some brief code:

public __gc class WmSizeFixerApplicationForm : public
System::Windows::Forms::Form
{
// .... gubbins to initialise everything omitted
protected: void OnClosing( System::ComponentModel::CancelEventArgs *e )
{
// do nothing
}
protected: void OnClosed()
{
// do nothing
}
};

Thanks!

Steve
 
M

Michiel

Try

protected: void OnClosing( System::ComponentModel::CancelEventArgs *e )
{
e.Cancel=true;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top