Groups | Blog | Home
all groups > dotnet drawing api > april 2004 >

dotnet drawing api : LinearGradient Color in Window Forms (VB.NET) and Transparency


ChristosX
4/3/2004 3:56:03 PM
Hello

I filled a form with a lineargradient color (two colors) using that code

Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs
MyBase.OnPaintBackground(pevent


Dim br As New LinearGradientBrush(pevent.ClipRectangle, Color.Magenta, Color.Gold, LinearGradientMode.BackwardDiagonal
pevent.Graphics.FillRectangle(br, pevent.ClipRectangle
br.Dispose(

End Su

The problem is that:
i put several labels in the form and i want them all to be transparent, so the Background color of the form to be drawn smoothly under the labels. But it doesn't. It draws the gradient in the rectangle of each label, but i want the gradient to pass smoothly under them, full transparency.

Test it, and you will see

Any idea, please

Thanks
Christo

Bob Powell [MVP]
4/4/2004 2:39:49 AM
This is a known problem with the Windows Forms transparency model. See the
GDI+ FAQ for details on how to create truly transparent controls.

--
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

[quoted text, click to view]
the Background color of the form to be drawn smoothly under the labels. But
it doesn't. It draws the gradient in the rectangle of each label, but i
want the gradient to pass smoothly under them, full transparency.
[quoted text, click to view]

ChristosX
4/4/2004 1:46:03 PM
Thanks Mr Bob.

Will be corrected in the next Version of VS.NET?

Bob Powell [MVP]
4/5/2004 1:25:21 PM
This is fixed in Visual Studio 2005 (Whidbey)

Whether there will be an upgrade to the framework between now and the relase
of that system I cannot say.

--
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

[quoted text, click to view]

AddThis Social Bookmark Button