473,405 Members | 2,141 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,405 software developers and data experts.

PaintEventHandler

Following is a method of the Control class defined in
System.Windows.Forms

protected virtual void OnPaint(PaintEventArgs e)
{
if (this.CanRaiseEvents)
{
PaintEventHandler handler = (PaintEventHandler)
base.Events[EventPaint];
if (handler != null)
{
handler(this, e);
}
}
}

Paint EventHandler is a delegate defined as;

public delegate void PaintEventHandler(object sender, PaintEventArgs
e);
Where can I find the code for the above mentioned method :
PaintEventHandler?

Thanks, Shilpi

May 15 '07 #1
4 5485
Shilpi,

That's the thing, you can't. PaintEventHandler is a delegate, which
allows you to assign a method with the same signature to it, pass it around,
and have that method called somewhere else.

The primary use is for events, which is what you are looking at here.

That being said, there really is no code, just a structure that says
that methods with similar signatures can be assigned to it, to be called at
that or another time.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<sh************@gmail.comwrote in message
news:11**********************@e51g2000hsg.googlegr oups.com...
Following is a method of the Control class defined in
System.Windows.Forms

protected virtual void OnPaint(PaintEventArgs e)
{
if (this.CanRaiseEvents)
{
PaintEventHandler handler = (PaintEventHandler)
base.Events[EventPaint];
if (handler != null)
{
handler(this, e);
}
}
}

Paint EventHandler is a delegate defined as;

public delegate void PaintEventHandler(object sender, PaintEventArgs
e);
Where can I find the code for the above mentioned method :
PaintEventHandler?

Thanks, Shilpi
May 15 '07 #2
On May 15, 9:41 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Shilpi,

That's the thing, you can't. PaintEventHandler is a delegate, which
allows you to assign a method with the same signature to it, pass it around,
and have that method called somewhere else.

The primary use is for events, which is what you are looking at here.

That being said, there really is no code, just a structure that says
that methods with similar signatures can be assigned to it, to be called at
that or another time.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

<shilpichaud...@gmail.comwrote in message

news:11**********************@e51g2000hsg.googlegr oups.com...
Following is a method of the Control class defined in
System.Windows.Forms
protected virtual void OnPaint(PaintEventArgs e)
{
if (this.CanRaiseEvents)
{
PaintEventHandler handler = (PaintEventHandler)
base.Events[EventPaint];
if (handler != null)
{
handler(this, e);
}
}
}
Paint EventHandler is a delegate defined as;
public delegate void PaintEventHandler(object sender, PaintEventArgs
e);
Where can I find the code for the above mentioned method :
PaintEventHandler?
Thanks, Shilpi- Hide quoted text -

- Show quoted text -
So what happens when OnPaint is called?

May 15 '07 #3
On May 15, 9:41 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Shilpi,

That's the thing, you can't. PaintEventHandler is a delegate, which
allows you to assign a method with the same signature to it, pass it around,
and have that method called somewhere else.

The primary use is for events, which is what you are looking at here.

That being said, there really is no code, just a structure that says
that methods with similar signatures can be assigned to it, to be called at
that or another time.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

<shilpichaud...@gmail.comwrote in message

news:11**********************@e51g2000hsg.googlegr oups.com...
Following is a method of the Control class defined in
System.Windows.Forms
protected virtual void OnPaint(PaintEventArgs e)
{
if (this.CanRaiseEvents)
{
PaintEventHandler handler = (PaintEventHandler)
base.Events[EventPaint];
if (handler != null)
{
handler(this, e);
}
}
}
Paint EventHandler is a delegate defined as;
public delegate void PaintEventHandler(object sender, PaintEventArgs
e);
Where can I find the code for the above mentioned method :
PaintEventHandler?
Thanks, Shilpi- Hide quoted text -

- Show quoted text -
and also if you could suggest an alternative to my problem:
I have controls within a group that get clipped according to the size
of the groupbox, I don't want them to be clipped -

May 15 '07 #4
On Tue, 15 May 2007 09:13:09 -0700, <sh************@gmail.comwrote:
So what happens when OnPaint is called?
At run time, all the delegates attached to the handler at the time it was
copied to the local "handler" variable will be executed. Depending on
your code, you could do a search for code that adds itself to the Paint
event for the class, but the only truly reliable way to know what would be
executed is to break at that point in code and see what delegates have
been attached to the event.
May 15 '07 #5

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

Similar topics

11
by: Sagaert Johan | last post by:
I have made a custom control that draws a rectangle when the mouse is down, and does nothing when the mouse is up. I set/reset a flag in MouseDown/Mouse up and use this to do the drawing in the...
5
by: JackS | last post by:
I am trying to use GDI32 bitblt to write a bitmap to a control's window, but all I get is an empty rectangle of some rop-dependent color. In short, I use the following logic in a paint event handler:...
5
by: Brian | last post by:
Hello all.. Am working on an Air Hockey game... have an table loaded into a picture box. The borders of the table are slightly slanted. Am using hit testing lines with GDI+ to manipulate the...
5
by: vooose | last post by:
Consider a UserControl TopCont that contains two other UserControls, CompA and CompB. Somewhere in the constructor of TopCont we have CompA.Paint += new PaintEventHandler(compA_Paint);...
6
by: juli | last post by:
I declared: public delegate void PaintEventHandler(object objSender,PaintEventArgs pea); and this.Paint+=new PaintEventHandler(MyPaintHandler); and the: static void MyPaintHandler(object...
6
by: Rodrigo Ferreira | last post by:
How can i draw a line inside a button?
1
by: Robert W. | last post by:
In my Winforms app I'm trying to get an image's background to appear transparent on a form that has a gradient background. So I added a PictureBox and then attempted to add a custom paint command...
0
by: Marcelo | last post by:
Greetings! I am developping a multiple forms Windows Forms application in Visual Studio C++ .NET 2003 and I need to make graphics in a group box. In order to do this I use: void...
14
by: raylopez99 | last post by:
KeyDown won't work KeyPress fails KeyDown not seen inspired by a poster here:http://tinyurl.com/62d97l I found some interesting stuff, which I reproduce below for newbies like me. The main...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.