Private Declare Sub ReleaseCapture Lib "user32" () Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Public Sub FormDrag(TheForm As Form) ReleaseCapture Call SendMessage(TheForm.hwnd, &HA1, 2, 0&) End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbLeftButton Then FormDrag Me End If End Sub
Eller hvis du vil gørere det ved at trykke på en "Picture1"
Dim IX, IY, FX, FY As Integer
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) IX = X: IY = Y FX = Me.Left: FY = Me.Top End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then Me.Move FX + (X - IX), FY + (Y - IY) FX = Me.Left: FY = Me.Top End If End Sub
Public Const LP_HT_CAPTION = 2 Public Const WM_NCLBUTTONDOWN = &HA1
Public Declare Function ReleaseCapture Lib "user32" () As Long Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Any) As Long '-- End --'
I picture1 (et pivturebox):--------------
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, _ X As Single, Y As Single) Dim retVal As Long ' Release the capture retVal = ReleaseCapture ' Send a message to Form1 saying we clicked it's Caption ' so that it will move around. retVal = SendMessage(Form1.hwnd, WM_NCLBUTTONDOWN, _ LP_HT_CAPTION, ByVal 0&) End Sub '-- End --'
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.