Visual Basic > Forms
How to move a control on a form at runtime.
How to move a control on a form at runtime. 'Note: This has only been tested with VB 3 and VB 4-16, if you convert ' Declare these APIs and Constants Declare Sub ReleaseCapture Lib "user" () Declare Function SendMessage& Lib "user" (ByVal hWnd%, ByVal wMsg%, ByVal wParam%, lParam As Any) Const WM_SYSCOMMAND = &H112 Const SC_MOVE = &HF012 ' In this example we'll use a picture box, in the MouseDown event add: Sub Picture1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single) Dim ret% If Button = 1 Then ReleaseCapture ret = SendMessage(Picture1.hWnd, WM_SYSCOMMAND, SC_MOVE, 0) End If End Sub
Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows