473,396 Members | 1,773 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,396 software developers and data experts.

Control creation and OnPaint

Hi all,

I'm creating a control derived from System.Windows.Forms.Control
I override the OnPaint() function
The control takes place on a form with a background image.
Because I've some problems to draw properly my control, I decided to test it
with a OnPaint() function which does *absolutely nothing*. And I'm very
surprised : I don't understand why the control seems to draw itself !? I get
a rectangle filled with the background color of the window... Why ? The
OnPaint function does absolutely nothing...

Am I missing something ?

Thanks in Advance.

(And sorry for my poor englih)

Dave

*****************************************

peace of code :

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
}

With VB.Net, I think it's omething like this :

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
End Sub

--> You see, the OnPaint function does absolutely nothing ;-)
Nov 16 '05 #1
1 2174
I answered your question over in the Drawing group.

--
Bob Powell [MVP]
Visual C#, System.Drawing

All you ever wanted to know about ListView custom drawing is in Well Formed.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Dave" <xx**@yyyy.zz> wrote in message
news:40*********************@news.free.fr...
Hi all,

I'm creating a control derived from System.Windows.Forms.Control
I override the OnPaint() function
The control takes place on a form with a background image.
Because I've some problems to draw properly my control, I decided to test it with a OnPaint() function which does *absolutely nothing*. And I'm very
surprised : I don't understand why the control seems to draw itself !? I get a rectangle filled with the background color of the window... Why ? The
OnPaint function does absolutely nothing...

Am I missing something ?

Thanks in Advance.

(And sorry for my poor englih)

Dave

*****************************************

peace of code :

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
}

With VB.Net, I think it's omething like this :

Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
End Sub

--> You see, the OnPaint function does absolutely nothing ;-)

Nov 16 '05 #2

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...
1
by: Dave | last post by:
Hi all, I'm creating a control derived from System.Windows.Forms.Control I override the OnPaint() function The control takes place on a form with a background image. Because I've some problems...
4
by: | last post by:
Please, help. I created my contol, ButtonX, which subclasses System.Forms.Windows.Button class. I am doing my own paiting, by overriding OnPaint and OnPaintBackground (without calling base...
3
by: pacemkr | last post by:
Is it possible to force a control to paint to a Graphics object (or Device Context, or a bitmap, anywhere aside from the form) that I provide. I am writing a windows form class that supports...
0
by: Sam Barham | last post by:
I have a ListView control, for which I have overwritten the WndProc method to gain access to the WM_PAINT message and generate my own OnPaint and OnPaintBackground messages, in order to colour the...
20
by: BB | last post by:
Hello all, I am trying to override OnPaint in a custom textbox control (so I can drawstring a caption, etc.). In the code below, I get the "painting the form" message as expected, but not the...
5
by: Brian Henry | last post by:
Hello, I want to make a control that has a scrollable Gantt type display (not really one but will look similar to one) this is going to be custom drawn (i already have the drawing procedure...
3
by: James Ramaley | last post by:
I have created a VB.NET User Control which inherits from TextBox. I have a general question regarding how functionality should be overwritten: I can either write a method which handles an event:...
4
by: RSH | last post by:
How do I go about overriding a Control's OnPaint Method? I would like to prevent a control's color from changing when it is disabled. I have overridden the Form's OnPaint Method but I need to...
5
tranc3d
by: tranc3d | last post by:
I want to understand the mechanism behind the painting of a control: what are the functions (handlers) involved and when they are called. I have a custom control based on a Panel. I think 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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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,...

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.