Hallo.
Ich habe vor, eine eigene Form zu programmieren.
Jetzt habe ich jedoch ein Problem: an den Ecken ist die Form schwarz,
obwohl ich die Hintergrundfarbe auf Transparent setze.
Code:
Kann mir jemand sagen, wie ich das hinbekomme?
Ich habe vor, eine eigene Form zu programmieren.
Jetzt habe ich jedoch ein Problem: an den Ecken ist die Form schwarz,
obwohl ich die Hintergrundfarbe auf Transparent setze.
Code:
VB.NET-Quellcode
- Public Class StudioForm : Inherits Form
- Private EdgeTopLeft, EdgeTopRight, EdgeBottomLeft, EdgeBottomRight, FormBgCol As Bitmap
- Public Sub New()
- Me.Size = New Size(107, 95)
- Me.DoubleBuffered = True
- Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
- Me.SetStyle(ControlStyles.FixedHeight, True)
- Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
- Me.SetStyle(ControlStyles.ResizeRedraw, True)
- Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
- Me.BackColor = Color.Transparent
- EdgeTopLeft = My.Resources.StudioFormEdgeTopLeft
- EdgeTopRight = My.Resources.StudioFormEdgeTopRight
- EdgeBottomLeft = My.Resources.StudioFormEdgeBottomLeft
- EdgeBottomRight = My.Resources.StudioFormEdgeBottomRight
- FormBgCol = My.Resources.StudioFormBg
- End Sub
- Public Sub Redraw(ausgabe As Graphics)
- If Me.Width < 107 Then Me.Width = 107
- If Me.Height < 95 Then Me.Height = 95
- Dim gr As Graphics = ausgabe
- gr.Clear(Me.BackColor)
- gr.DrawImage(EdgeTopLeft, New Point(0, 0))
- gr.DrawImage(EdgeTopRight, New Point(Me.Width - EdgeTopRight.Width - 10, 0))
- gr.DrawImage(EdgeBottomLeft, New Point(0, Me.Height - EdgeBottomLeft.Height - 14))
- gr.DrawImage(EdgeBottomRight, New Point(Me.Width - EdgeBottomRight.Width - 10, Me.Height - EdgeBottomRight.Height - 14))
- Dim z1 As Brush = New SolidBrush(Color.FromArgb(0, 85, 120))
- Dim xcoor As Integer = EdgeTopLeft.Width + 10
- Dim vertrectsiz As Size = New Size(Me.Width - EdgeBottomLeft.Width - EdgeBottomRight.Width - 20, EdgeBottomLeft.Height + 15)
- gr.FillRectangle(z1, New Rectangle(New Point(xcoor, 0), vertrectsiz))
- gr.FillRectangle(z1, New Rectangle(New Point(xcoor, Me.Height - EdgeBottomLeft.Height - 14), vertrectsiz))
- gr.FillRectangle(z1, New Rectangle(New Point(0, EdgeTopLeft.Height), New Size(Me.Width, Me.Height - EdgeTopLeft.Height - EdgeTopRight.Height)))
- End Sub
- Protected Overrides Sub OnPaint(pevent As System.Windows.Forms.PaintEventArgs)
- Redraw(pevent.Graphics)
- End Sub
- End Class
Kann mir jemand sagen, wie ich das hinbekomme?