473,385 Members | 1,693 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,385 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 2170
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
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...

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.