473,395 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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
2 1883
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fenix | last post by:
I want intercept the call to a object method or object property . Its plausible ? Are there any event fired when i invoke a object method or property ?
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
6
by: Valery Polyakov | last post by:
I am drawing lines with a semi-transparent color (alpha=100). When these lines intercept, the color becomes more intense. Is there a way to avoid this, so that I would get the same intensity of...
0
by: hades5k | last post by:
Hi, I need to intercept mouse click events outside my applications. What I want to do is pretty simple. If I click on the Quick Launch toolbar an icon (let say IExplorer), I want to intercept the...
1
by: MCzajk | last post by:
Is there a way to intercept event, when user logs on/off to the system inside windows service? Thx for any tip, MCzajk
6
by: Steve Murphy | last post by:
I have a default button on a form, but when a certain textbox has focus, I want to intercept Enter key events and perform a different action. Is there an easy way to do this, or should I just check...
4
by: Curious Coder | last post by:
I have been tasked with a project that I do not think can be accomplished. Our company has an application that runs as an unmanaged ActiveX control on user desktops. It is designed to work with...
3
by: pamelafluente | last post by:
I am new to asp.net. I have an asp page with a submit button which sends out some information. Instead of having IIS to respond and deal with this information, I would like to have a .NET...
0
by: Gabriel Genellina | last post by:
En Thu, 18 Sep 2008 19:24:26 -0300, Robert Dailey <rcdailey@gmail.com> escribió: Why don't you try it yourself? You may replace builtins.print with your own function too. It's not exactly the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.