VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Move and resize forms by MouseDown on any object on form.

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

Rate Move and resize forms by MouseDown on any object on form.



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/

Download this snippet    Add to My Saved Code

Move and resize forms by MouseDown on any object on form. Comments

No comments have been posted about Move and resize forms by MouseDown on any object on form.. Why not be the first to post a comment about Move and resize forms by MouseDown on any object on form..

Post your comment

Subject:
Message:
0/1000 characters