Veränderte Form flimmert beim bewegen

headpainter

Grünschnabel
Hallo,

ich möchte gern in meinen Projekten Forms benutzen, die nicht einfach nur eine eckicge Form haben.
Dazu habe ich einen Path erstellt und die Region der Form auf den Path gesetzt.
Jetzt habe ich allerdings das Problem, das wenn ich die veränderte Form über den Bildschirm bewege, flackert die Form unerträglich. Wenn ich die Region wieder entferne kann ich die Form absolut flimmerfrei bewegen.

Hier mein VB Code

Code:
Public Class Form1

    Private CurrentPosition As New System.Drawing.Point
    Private MouseButton As System.Windows.Forms.MouseButtons = Nothing

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                           Handles MyBase.Load
        Dim Path As New System.Drawing.Drawing2D.GraphicsPath
        
        Path.AddEllipse(0, 0, 200, 200)
        Path.AddEllipse(75, 75, 50, 50)
        Path.CloseAllFigures()
        Me.Region = New Region(Path)
     
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
                                Handles Button1.Click
        Me.Close()

    End Sub

    

    Private Overloads Sub OnMouseDown(ByVal Sender As System.Object, _
                    ByVal e As System.Windows.Forms.MouseEventArgs) _
                    Handles MyBase.MouseDown

        MyClass.MouseButton = e.Button()
        With MyClass.CurrentPosition
            .X = e.X()
            .Y = e.Y()
        End With

    End Sub

    Private Overloads Sub OnMouseMove(ByVal Sender As System.Object, _
                                        ByVal e As System.Windows.Forms.MouseEventArgs) _
                                        Handles MyBase.MouseMove

        Select Case MouseButton
            Case Is = Windows.Forms.MouseButtons.Left


                MyClass.Top = Windows.Forms.Cursor.Position.Y() - MyClass.CurrentPosition.Y()
                MyClass.Left = Windows.Forms.Cursor.Position.X() - MyClass.CurrentPosition.X()


            Case Is = Nothing

                Exit Sub
        End Select
    End Sub

    Private Overloads Sub OnMouseUp(ByVal Sender As System.Object, _
                                    ByVal e As System.Windows.Forms.MouseEventArgs) _
                                    Handles MyBase.MouseUp
        MyClass.MouseButton = Nothing
    End Sub
End Class

Was muß ich ändern, bzw einfügen?
 
Zurück