473,840 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Call to Base-Class Does Not Succeed

Documentation suggests that I should make a call to the base-class method
for some methods. When I try to do so for the class below, I get wrong
results. What is the correct way to make a call to the base class for an
event like this?
//class Form
class Form:System.Win dows.Forms.Form
{

//constructor
Form()
{
MouseEnter+=OnM ouseEnter;
}
//OnMouseEnter
void OnMouseEnter(Sy stem.Object a,System.EventA rgs b)
{
base.OnMouseEnt er(b);
}
//Main
[System.STAThrea d]
static void Main()
{
System.Windows. Forms.Applicati on.Run(new Form());
}
}


Nov 21 '06 #1
1 1476
Martijn Mulder wrote:
Documentation suggests that I should make a call to the base-class method
for some methods. When I try to do so for the class below, I get wrong
results. What is the correct way to make a call to the base class for an
event like this?
//class Form
class Form:System.Win dows.Forms.Form
{

//constructor
Form()
{
MouseEnter+=OnM ouseEnter;
}
//OnMouseEnter
void OnMouseEnter(Sy stem.Object a,System.EventA rgs b)
{
base.OnMouseEnt er(b);
}
//Main
[System.STAThrea d]
static void Main()
{
System.Windows. Forms.Applicati on.Run(new Form());
}
}
If you are handling this throug events as you are, then there is no need to
call the base class as that has already happened by the time you get to your
event handler. If instead of using event handlers you had overriden the
OnMouseEnter method of the base class, then in your override you would want
to make sure you called the base. That would like similar to as follows:

//class Form
class Form:System.Win dows.Forms.Form
{

//constructor
Form()
{
}

//OnMouseEnter
protected override void OnMouseEnter(Sy stem.EventArgs b)
{
base.OnMouseEnt er(b);
}

//Main
[System.STAThrea d]
static void Main()
{
System.Windows. Forms.Applicati on.Run(new Form());
}
}

--
Tom Porterfield

Nov 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
21350
by: Paul | last post by:
public class A { public A () { // here I would like to call the second version of _ctor, how to accomplish this ? } public A (int a, int b, int c) {
3
1542
by: John A. Prejean | last post by:
This one has me stumped. I have a base form I am trying to wrap up, but I have one problem. In two functions I am opening a "record detail" form. I would like to keep the code in the base form and pass info to the form telling it which from to actually open. Any ideas how to do this? Here is an example of what I had in mind if the text isn't clear enough... Base Form Function EditRecord() Dim frmRecord as New Form()
6
2121
by: Radith Silva | last post by:
Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCalculate.Click If txtName.Text <> "" Then If txtUnits.Text <> "" Then If optOne.Checked Or optTwo.Checked Or optThree.Checked Or optFour.Checked Then 'Data fine Else MessageBox.Show("Please choos an option button") End If
4
13162
by: AI Man | last post by:
Greetings, I have been searching the web and Access relentlessly trying to find a way to call an Access macro from a different Access data base. Example - The form button gets clicked and the first macro executes. Then a second macro is selected from a closed data base so that the query in the second database can run. Alternatively open the second data base and call the macro. In other words I need to use several Access databases and...
3
1819
by: xtrigger303 | last post by:
Hi to all, a newbie question. Is it possible to avoid the virtual mechanism with pointers to members syntax the same way it's done with an explicit call ( obj.Base::Func() )? It would be useful for something I'm doing... check out the trivial program down here... Thanks in advance, Francesco #include <iostream>
6
2720
by: active | last post by:
In Protected Overrides Sub OnDrawItem should I call MyBase.OnDrawItem(e) at the top or bottom of the sub? What might happen if I don't call it?
11
14782
by: Fabio | last post by:
Hi all There is a way to exec a function asynchronously? I need to exec a function that is too slow but for me can be executed in the background... there is no way??? Thanks
0
1269
by: noel.whelan | last post by:
I've been working through the zend gdata client lib example for google base: http://code.google.com/apis/base/samples/php/php-sample-zend.html. I've installed the zend framework version 1.0.2 for this purpose. The first issue I experience is when I copy google's example code, which includes the line: Zend_Loader::loadClass('Zend_Feed_EntryAtom');
2
1618
by: Mosfet | last post by:
Hi, I am currently writing a graphical control(a list control) that can display a picture followed by some text and to do so I first calculate an item height and then I really draw. I was wondering if it would be a good idea to merge the two methods(calculating and drawing) knowing that when calculating we actually simulate a drawing. Basically my control is called the first time to calculate the height of an Item (MeasureItem) and...
4
1661
by: smrah1 | last post by:
Hi we have like below code: namespace ConsoleApplication1 { class Program { static void Main(string args) {
0
9856
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9698
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10916
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10598
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9436
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7836
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4071
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.