none
Fenster ohne Rahmen verschieben?! RRS feed

  • Frage

  • Hallo,
    ich habe eine Form (Form1) und die hat keinen Rahmen (FormBorderStyle: None).
    Ich möchte das Fenster aber trotzdem verschieben können. Ich weiß das es geht, nur nicht, wie
    Freitag, 21. November 2008 13:58

Antworten

  • OK ich habs gelöst. Das stand auf ner anderen Seite und funzt auch gut:

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

        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
    Freitag, 21. November 2008 17:14