Drag Controls and Forms


This code were sent to me by 'noname' and has not been tested yet.

[Declarations]
Declare Sub ReleaseCapture Lib "user32" () Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_SYSCOMMAND = &H112
Const SC_MOVE = &HF012

Private Sub Thing_MouseDown()
ReleaseCapture
SendMessage Thing.hwnd, WM_SYSCOMMAND, SC_MOVE, 0
End Sub

Note, you must replace "Thing" with the control you want to move. Useful for making a makeshift titlebar for a form, or making "Sub Forms" This code only works with Windows 95 and NT 4.0


Mail to Daniel Wiman <daniel@wimania.com>
Online since June 1996, updated 980524
<- The VB home
<- Daniels homepage