by Jaap (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 7th December 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Move and resize forms by MouseDown on any object on form.
API Declarations
Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Public HTCAPTION As Long
Public Const WM_NCLBUTTONDOWN = &HA1 ' Window messages
Create a form and insert the following code in the <object>_mousedown() subroutine:
The object can be anything. Example: create a form with a button with (default) Name: Command1
Insert the code:
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' HTCAPTION: 2 - move window
' 10 - left resize
' 11 - right resize
' 12 - top
' 13 - left / top
' 14 - right / top
' 15 - bottom
' 16 - left / bottom
' 17 - right / bottom
HTCAPTION = 2 ' move form by clicking on object, holding the mousebutton down and moving mouse
ReleaseCapture
SendMessage Form1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
End Sub
Play with the value of HTCAPTION for different effects.
Have fun!
I used this for a remote winamp app.
Check out: http://www.dubb.org/