473,770 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.P aintEventArgs 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 2227
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******** *************@n ews.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.P aintEventArgs 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
6200
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 OnPaint . The recangle draws correct when i press the mouse, but when i release the mouse the background is not restored What should i do in the Onpaint to make sure the background (the form) is restored correctly ? This problem already keeps...
1
264
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 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...
4
5677
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 class's OnPaint & OnPaintBackground). My button has a shape of rectangle with rounded corners and is filled with gradient brush, where user specifies the gradient colors. The dilema I have now is how to paint the button when it's disabled (Enabled =...
3
8998
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 full alpha blending. Basically I'm trying to make a layered window that supports controls. In order to do that I need to redirect painting of the controls to a memory DC (which is then sent to the layered window). All this asuming that I figured out...
0
2182
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 columns of the listview to my liking. When a row of the listview is selected, some controls are displayed on that row of the listview (so sort of like a property list thingy). In order to get the controls (specifically buttons) to display how I...
20
2574
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 "painting the control". It also has no effect to explicitly call txtTest.Invalidate or txtTest.Refresh. Am I missing something simple here? Any push in the right direction is appreciated.
5
2160
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 completed for the overriden onpaint event) but the problem is this can be a very long scrollable viewport (part that scrolls inside the control) while the control will be relatively 800x600 in size)... i tried to do this with a panel scrolling inside...
3
1408
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: function MyControl_Enter(...) handles MyControl.Enter or I can overwrite the relevant virtual method:
4
4681
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 do it at the control level. Thanks, Ron
5
6859
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 functions involved for this examples are: OnPaint handler in Panel class, OnPaint handler in CustomPanel class and OnPaint event handler of the CustomPanel in the main form (from de designer). 1.OnPaint of Panel Class (what does this do and when is...
0
9617
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
10254
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
10099
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
9904
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8929
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
7451
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
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.