467,145 Members | 987 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,145 developers. It's quick & easy.

Intercepting form events

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
Nov 17 '05 #1
  • viewed: 1725
Share:
2 Replies
Try

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

"Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> wrote in message
news:ue****************@TK2MSFTNGP11.phx.gbl...
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

Nov 17 '05 #2
That is e->Cancel=true ;)

"Michiel" <mi*********@RECLAMEpayvision.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Try

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

"Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> wrote in message
news:ue****************@TK2MSFTNGP11.phx.gbl...
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


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Fenix | last post: by
6 posts views Thread by Valery Polyakov | last post: by
reply views Thread by hades5k | last post: by
6 posts views Thread by Steve Murphy | last post: by
4 posts views Thread by Curious Coder | last post: by
3 posts views Thread by pamelafluente@libero.it | last post: by
reply views Thread by Gabriel Genellina | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.