0 Replies - 1343 Views - Last Post: 02 May 2010 - 08:14 AM Rate Topic: -----

#1 No0Vad   User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 35
  • Joined: 18-February 10

VisualStyleRenderer and Paint problem

Posted 02 May 2010 - 08:14 AM

I have a UserControl with 2 labels and picturebox added. I use a VisualStyleRenderer to draw the background on my UserControl.

How I define my renderer
VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.ToolBar.Button.Hot);


and usage in the Paint method
renderer.DrawBackground(e.Graphics, e.ClipRectangle);


Works fine, except my labels still have the Control background color. I changed it to Transparent, and it sort of work. The labels use the same Painting code as the my UserControl which give me this unwanted result.
Posted Image

I have tried to draw the background to a Bitmap instead and use as a background image instead
Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
HoverBackground = new Bitmap(this.Width, this.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

Graphics g = Graphics.FromImage(HoverBackground);
g.FillRectangle(Brushes.White, rect);

renderer.DrawBackground(g, rect);
g.Dispose();


but the image is almost completely black, there are some shades of gray.
Posted Image

Is there a way to fix it? Or do i have to draw the text directly instead of using labels?

Is This A Good Question/Topic? 0
  • +

Page 1 of 1