I have a borderless form that has a transparent background. I only wanted
the color that paints the background with to be transparent and not the
controls on the form or the center square that I paint in the center. The
problem I am having is when I pass another window
in front of it or drag the window, it doesn’t repaint with the transparent
background. It just shows the drag or gets darker and eventual it will
because a solid color again.
This is my code that I am using:
Private Sub DoubleBuffering_Paint(ByVal sender As Object, _
ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics '= e.Graphics
Dim Dw As Bitmap
Dw = New Bitmap(Me.Width, Me.Height, e.Graphics)
g = Graphics.FromImage(Dw)
g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
DrawRoundedForm(0, _
0, _
Me.Width, _
Me.Height, _
18, _
Me.Region)
'filling the main background
Dim cl As New SolidBrush(Color.FromArgb(125, Color.Black))
g.FillRectangle(cl, New RectangleF(0, 0, Me.Width, Me.Height))
cl.Dispose()
Dim c2 As New SolidBrush(Color.WhiteSmoke)
g.FillRectangle(c2, New RectangleF(15, 15, Me.Width - 30, Me.Height
- 30))
c2.Dispose()
e.Graphics.DrawImageUnscaled(Dw, 0, 0)
g.Dispose()
End Sub
Protected Overrides Sub OnPaintBackground(ByVal pevent As
System.Windows.Forms.PaintEventArgs)
'prevents flickering on background redraw, does not redraw the
background
'MyBase.OnPaintBackground(pevent)
End Sub
Any body have any ideas?
Can I paint what is behind it on the window then draw the transparat color
on top and make it run smoothly when I drag the window?
I am using .net 2.0 vs 2005