473,624 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem on LinearGradientB rush

Hello

I found an abnormal behaviour on LinearGradientB rush (or FillRectangle).
This code

Public Class PanelPanel
Inherits System.Windows. Forms.Panel
Protected Overrides Sub OnPaint(ByVal e As System.Windows. Forms.PaintEven tArgs)
Dim rect As System.Drawing. Rectangle = New System.Drawing. Rectangle(10, 10, Me.Width - 20, Me.Height - 20)
Dim gradientBrush As System.Drawing. Drawing2D.Linea rGradientBrush
gradientBrush = New System.Drawing. Drawing2D.Linea rGradientBrush( rect, _
System.Drawing. Color.Gray, _
System.Drawing. Color.FloralWhi te, _
System.Drawing. Drawing2D.Linea rGradientMode.V ertical)
e.Graphics.Fill Rectangle(gradi entBrush, rect)
End Sub
End Class

generates a control with an rectangle drawn inside.
The problem is that an unusual line (colored Color.FloralWhi te) appears on the top edge of the rectangle. This line
should not be there.
If LinearGradientM ode id other than Vertical the problem persists, but it is less visible (only a small colored pixel is
visible).

Please note that the anomaly appears only with some rectangle sizes. Example:
if rect={X=10,Y=10 ,Width=304,Heig ht=208} 'equivalent to a Me.Size=New Size(324,228) - Anomaly visible
if rect={X=10,Y=10 ,Width=304,Heig ht=216} 'Correct, anomaly not visible

Could someone PLEASE try to reproduce the problem (just copy code as is) and confirm that is an error and then reason
with me??

Thank you!.

Carlo

(MCP)
Nov 21 '05 #1
4 3136
Carlo,

I am not seeing the problem on my laptop. However I see you did
not set the resizeredraw style to the control. It is possible the problem
is caused by the control not completely redrawing itself.

Public Class PanelPanel
Inherits System.Windows. Forms.Panel
Protected Overrides Sub OnPaint(ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim rect As System.Drawing. Rectangle = New
System.Drawing. Rectangle(10, 10, Me.Width - 20, Me.Height - 20)
Dim gradientBrush As System.Drawing. Drawing2D.Linea rGradientBrush
gradientBrush = New
System.Drawing. Drawing2D.Linea rGradientBrush( rect, _
System.Drawing. Color.Gray, _
System.Drawing. Color.FloralWhi te,
_
System.Drawing. Drawing2D.Linea rGradientMode.V ertical)
e.Graphics.Fill Rectangle(gradi entBrush, rect)
End Sub

Public Sub New()
Me.SetStyle(Con trolStyles.Resi zeRedraw, True)
End Sub
End Class

Ken
--------------------------
"Carlo, MCP" <ca******@gmail .com> wrote in message
news:43******** *************@n ews.tiscali.it. ..
Hello

I found an abnormal behaviour on LinearGradientB rush (or FillRectangle).
This code

Public Class PanelPanel
Inherits System.Windows. Forms.Panel
Protected Overrides Sub OnPaint(ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim rect As System.Drawing. Rectangle = New
System.Drawing. Rectangle(10, 10, Me.Width - 20, Me.Height - 20)
Dim gradientBrush As System.Drawing. Drawing2D.Linea rGradientBrush
gradientBrush = New
System.Drawing. Drawing2D.Linea rGradientBrush( rect, _
System.Drawing. Color.Gray, _

System.Drawing. Color.FloralWhi te, _

System.Drawing. Drawing2D.Linea rGradientMode.V ertical)
e.Graphics.Fill Rectangle(gradi entBrush, rect)
End Sub
End Class

generates a control with an rectangle drawn inside.
The problem is that an unusual line (colored Color.FloralWhi te) appears on
the top edge of the rectangle. This line should not be there.
If LinearGradientM ode id other than Vertical the problem persists, but it
is less visible (only a small colored pixel is visible).

Please note that the anomaly appears only with some rectangle sizes.
Example:
if rect={X=10,Y=10 ,Width=304,Heig ht=208} 'equivalent to a Me.Size=New
Size(324,228) - Anomaly visible
if rect={X=10,Y=10 ,Width=304,Heig ht=216} 'Correct, anomaly not visible

Could someone PLEASE try to reproduce the problem (just copy code as is)
and confirm that is an error and then reason with me??

Thank you!.

Carlo

(MCP)

Nov 21 '05 #2
Hi Ken

on the original control (where the problem materialized the first time), ResizeRedraw is correctly set to True. I've
post a minimalist version of the original control. However, I also tested this reduced version, and it has the problem
yet.
Please, note that I used a screen magnifier to identify the problem. I believe it's very hard to see on a laptop screen.
Thank you for the help,
Carlo
"Ken Tucker [MVP]" <vb***@bellsout h.net> ha scritto nel messaggio news:ut******** ******@TK2MSFTN GP12.phx.gbl...
Carlo,

I am not seeing the problem on my laptop. However I see you did not set the resizeredraw style to the
control. It is possible the problem is caused by the control not completely redrawing itself.

Public Class PanelPanel
Inherits System.Windows. Forms.Panel
Protected Overrides Sub OnPaint(ByVal e As System.Windows. Forms.PaintEven tArgs)
Dim rect As System.Drawing. Rectangle = New System.Drawing. Rectangle(10, 10, Me.Width - 20, Me.Height - 20)
Dim gradientBrush As System.Drawing. Drawing2D.Linea rGradientBrush
gradientBrush = New System.Drawing. Drawing2D.Linea rGradientBrush( rect, _
System.Drawing. Color.Gray, _
System.Drawing. Color.FloralWhi te, _
System.Drawing. Drawing2D.Linea rGradientMode.V ertical)
e.Graphics.Fill Rectangle(gradi entBrush, rect)
End Sub

Public Sub New()
Me.SetStyle(Con trolStyles.Resi zeRedraw, True)
End Sub
End Class

Ken
--------------------------
"Carlo, MCP" <ca******@gmail .com> wrote in message news:43******** *************@n ews.tiscali.it. ..
Hello

I found an abnormal behaviour on LinearGradientB rush (or FillRectangle).
This code

Public Class PanelPanel
Inherits System.Windows. Forms.Panel
Protected Overrides Sub OnPaint(ByVal e As System.Windows. Forms.PaintEven tArgs)
Dim rect As System.Drawing. Rectangle = New System.Drawing. Rectangle(10, 10, Me.Width - 20, Me.Height - 20)
Dim gradientBrush As System.Drawing. Drawing2D.Linea rGradientBrush
gradientBrush = New System.Drawing. Drawing2D.Linea rGradientBrush( rect, _
System.Drawing. Color.Gray, _

System.Drawing. Color.FloralWhi te, _

System.Drawing. Drawing2D.Linea rGradientMode.V ertical)
e.Graphics.Fill Rectangle(gradi entBrush, rect)
End Sub
End Class

generates a control with an rectangle drawn inside.
The problem is that an unusual line (colored Color.FloralWhi te) appears on the top edge of the rectangle. This line
should not be there.
If LinearGradientM ode id other than Vertical the problem persists, but it is less visible (only a small colored pixel
is visible).

Please note that the anomaly appears only with some rectangle sizes. Example:
if rect={X=10,Y=10 ,Width=304,Heig ht=208} 'equivalent to a Me.Size=New Size(324,228) - Anomaly visible
if rect={X=10,Y=10 ,Width=304,Heig ht=216} 'Correct, anomaly not visible

Could someone PLEASE try to reproduce the problem (just copy code as is) and confirm that is an error and then reason
with me??

Thank you!.

Carlo

(MCP)


Nov 21 '05 #3
Hi,

I can see it with the screen magnifier.

Ken
-------------
"Carlo, MCP" <ca************ @gmail.com> wrote in message
news:Oj******** ******@TK2MSFTN GP12.phx.gbl...
Hi Ken

on the original control (where the problem materialized the first time),
ResizeRedraw is correctly set to True. I've post a minimalist version of
the original control. However, I also tested this reduced version, and it
has the problem yet.
Please, note that I used a screen magnifier to identify the problem. I
believe it's very hard to see on a laptop screen.
Thank you for the help,
Carlo
"Ken Tucker [MVP]" <vb***@bellsout h.net> ha scritto nel messaggio
news:ut******** ******@TK2MSFTN GP12.phx.gbl...
Carlo,

I am not seeing the problem on my laptop. However I see you
did not set the resizeredraw style to the control. It is possible the
problem is caused by the control not completely redrawing itself.

Public Class PanelPanel
Inherits System.Windows. Forms.Panel
Protected Overrides Sub OnPaint(ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim rect As System.Drawing. Rectangle = New
System.Drawing. Rectangle(10, 10, Me.Width - 20, Me.Height - 20)
Dim gradientBrush As System.Drawing. Drawing2D.Linea rGradientBrush
gradientBrush = New
System.Drawing. Drawing2D.Linea rGradientBrush( rect, _
System.Drawing. Color.Gray,
_

System.Drawing. Color.FloralWhi te, _

System.Drawing. Drawing2D.Linea rGradientMode.V ertical)
e.Graphics.Fill Rectangle(gradi entBrush, rect)
End Sub

Public Sub New()
Me.SetStyle(Con trolStyles.Resi zeRedraw, True)
End Sub
End Class

Ken
--------------------------
"Carlo, MCP" <ca******@gmail .com> wrote in message
news:43******** *************@n ews.tiscali.it. ..
Hello

I found an abnormal behaviour on LinearGradientB rush (or FillRectangle).
This code

Public Class PanelPanel
Inherits System.Windows. Forms.Panel
Protected Overrides Sub OnPaint(ByVal e As
System.Windows. Forms.PaintEven tArgs)
Dim rect As System.Drawing. Rectangle = New
System.Drawing. Rectangle(10, 10, Me.Width - 20, Me.Height - 20)
Dim gradientBrush As System.Drawing. Drawing2D.Linea rGradientBrush
gradientBrush = New
System.Drawing. Drawing2D.Linea rGradientBrush( rect, _
System.Drawing. Color.Gray,
_

System.Drawing. Color.FloralWhi te, _

System.Drawing. Drawing2D.Linea rGradientMode.V ertical)
e.Graphics.Fill Rectangle(gradi entBrush, rect)
End Sub
End Class

generates a control with an rectangle drawn inside.
The problem is that an unusual line (colored Color.FloralWhi te) appears
on the top edge of the rectangle. This line should not be there.
If LinearGradientM ode id other than Vertical the problem persists, but
it is less visible (only a small colored pixel is visible).

Please note that the anomaly appears only with some rectangle sizes.
Example:
if rect={X=10,Y=10 ,Width=304,Heig ht=208} 'equivalent to a Me.Size=New
Size(324,228) - Anomaly visible
if rect={X=10,Y=10 ,Width=304,Heig ht=216} 'Correct, anomaly not visible

Could someone PLEASE try to reproduce the problem (just copy code as is)
and confirm that is an error and then reason with me??

Thank you!.

Carlo

(MCP)



Nov 21 '05 #4
Ok. Reproducing the problem on your IDE means realizing that I not become crazy and this is a good step ahead!

Any ideas?

Carlo

"Ken Tucker [MVP]" <vb***@bellsout h.net> ha scritto nel messaggio news:uR******** ******@TK2MSFTN GP15.phx.gbl...
Hi,

I can see it with the screen magnifier.

Ken
-------------
"Carlo, MCP" <ca************ @gmail.com> wrote in message news:Oj******** ******@TK2MSFTN GP12.phx.gbl...
Hi Ken

on the original control (where the problem materialized the first time), ResizeRedraw is correctly set to True. I've
post a minimalist version of the original control. However, I also tested this reduced version, and it has the
problem yet.
Please, note that I used a screen magnifier to identify the problem. I believe it's very hard to see on a laptop
screen.
Thank you for the help,
Carlo
"Ken Tucker [MVP]" <vb***@bellsout h.net> ha scritto nel messaggio news:ut******** ******@TK2MSFTN GP12.phx.gbl...
Carlo,

I am not seeing the problem on my laptop. However I see you did not set the resizeredraw style to the
control. It is possible the problem is caused by the control not completely redrawing itself.

Public Class PanelPanel
Inherits System.Windows. Forms.Panel
Protected Overrides Sub OnPaint(ByVal e As System.Windows. Forms.PaintEven tArgs)
Dim rect As System.Drawing. Rectangle = New System.Drawing. Rectangle(10, 10, Me.Width - 20, Me.Height - 20)
Dim gradientBrush As System.Drawing. Drawing2D.Linea rGradientBrush
gradientBrush = New System.Drawing. Drawing2D.Linea rGradientBrush( rect, _
System.Drawing. Color.Gray, _

System.Drawing. Color.FloralWhi te, _

System.Drawing. Drawing2D.Linea rGradientMode.V ertical)
e.Graphics.Fill Rectangle(gradi entBrush, rect)
End Sub

Public Sub New()
Me.SetStyle(Con trolStyles.Resi zeRedraw, True)
End Sub
End Class

Ken
--------------------------
"Carlo, MCP" <ca******@gmail .com> wrote in message news:43******** *************@n ews.tiscali.it. ..
Hello

I found an abnormal behaviour on LinearGradientB rush (or FillRectangle).
This code

Public Class PanelPanel
Inherits System.Windows. Forms.Panel
Protected Overrides Sub OnPaint(ByVal e As System.Windows. Forms.PaintEven tArgs)
Dim rect As System.Drawing. Rectangle = New System.Drawing. Rectangle(10, 10, Me.Width - 20, Me.Height - 20)
Dim gradientBrush As System.Drawing. Drawing2D.Linea rGradientBrush
gradientBrush = New System.Drawing. Drawing2D.Linea rGradientBrush( rect, _
System.Drawing. Color.Gray, _

System.Drawing. Color.FloralWhi te, _

System.Drawing. Drawing2D.Linea rGradientMode.V ertical)
e.Graphics.Fill Rectangle(gradi entBrush, rect)
End Sub
End Class

generates a control with an rectangle drawn inside.
The problem is that an unusual line (colored Color.FloralWhi te) appears on the top edge of the rectangle. This line
should not be there.
If LinearGradientM ode id other than Vertical the problem persists, but it is less visible (only a small colored
pixel is visible).

Please note that the anomaly appears only with some rectangle sizes. Example:
if rect={X=10,Y=10 ,Width=304,Heig ht=208} 'equivalent to a Me.Size=New Size(324,228) - Anomaly visible
if rect={X=10,Y=10 ,Width=304,Heig ht=216} 'Correct, anomaly not visible

Could someone PLEASE try to reproduce the problem (just copy code as is) and confirm that is an error and then
reason with me??

Thank you!.

Carlo

(MCP)



Nov 21 '05 #5

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

Similar topics

117
7172
by: Peter Olcott | last post by:
www.halting-problem.com
28
5199
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass(); .... and then call the virtual method, why is it that the base class's method is called instead of the overridden method? How do I fix this if I don't know at runtime what the child class is? I'm using Activator.CreateInstance() to load the...
4
2144
by: steve bull | last post by:
I have created a UserControl and added it to my toolbox. It appears in the toolbox with the icon I created for it. The problem is that when I drag the control onto a form no code is generated. If I manually add the code for creating the control to the form everything works fine. I have created other controls w/o problems and cannot see anything I am doing different in this case. Does anyone have any idea what I could be doing wrong? ...
1
8230
by: Kenneth Siewers Møller | last post by:
Hi there I have a custom label control (GradientLabel) which enherits from Label and basically just paints the background of a label in a gradient. In my code I have the following for the overidden OnResize event: protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics;
1
2459
by: DigitalMythic | last post by:
Just to set the scene, I have a listbox in an application which im working on. The List box will have owner drawn items in it when it has items. To start with the listbox is empty. What Im trying to do is have it so that when the listbox is empty, the background is gradient filled with a message for the user in the middle. See code below: if (lstRecoveryItems.Items.Count == 0) //{
8
6500
by: _DD | last post by:
It seems that there is some odd interaction with LinearGradientBrush that depends on positioning. A simple test: --------- Rectangle Square = new Rectangle(.....); in Paint: LinearGradientBrush ShadeBrush = new LinearGradientBrush(
5
5139
by: cblackburn | last post by:
Hi all, I am in the situation where I have a GraphicsPath that I want to draw onto a System.Drawing.Graphics. I want the line to be coloured in a gradient from one end to the other. I have tried to implement this using a LinearGradientBrush but that does not follow the path of the line, it simply creates a one directional gradient and the line is rendered ontop of that. Does anyone have a suggestion about how to go about implementing this...
2
6581
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click in the child datagrid and then go to the combobox and choose another vendor. When the new vendor is loaded nothing shows in the datagrid but the itemsource shows the info is there. Know if I click on the child cell and then click back on the...
7
8875
by: prpradip | last post by:
I have used ListView in my Form. I have set OwnerDraw = true. And I have the DrawItem Function as private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e) { if (e.Item.Checked) ControlPaint.DrawCheckBox(e.Graphics, 0, e.Bounds.Top + 1, 15, 15, ButtonState.Flat | ButtonState.Checked); else ...
0
8231
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
8672
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
8471
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...
1
6107
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
5561
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();...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2603
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
1474
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.