Form ohne Borderstyle verschieben

  • VB6

Es gibt 5 Antworten in diesem Thema. Der letzte Beitrag () ist von -([m3rLiN])-.

    Du musst ein Label erstellen und diesen Code einfügen:

    Dim Dragging As Boolean
    Dim DragX As Long
    Dim DragY As Long

    Private Sub lblTitle_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 And Dragging = True Then
    If Me.Left <> X And Me.Top <> Y Then
    Me.Move Me.Left + X - DragX, Me.Top + Y - DragY
    End If
    End If
    End Sub

    Private Sub lblTitle_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then Dragging = False
    End Sub

    Private Sub lblTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
    Dragging = True
    DragX = X
    DragY = Y
    End If
    End Sub

    Nun kannst du die Form verschieben wenn du auf das Label klickst.
    Oder so:

    Private Declare Function ReleaseCapture Lib "user32" () As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

    Private Const WM_NCLBUTTONDOWN = &HA1
    Private Const HTCAPTION = 2

    Public Function MoveWindow(hwnd As Long) As Long
    ReleaseCapture
    SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
    End Function

    Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MoveWindow hwnd
    End Sub