VB freely drag the code of the control

xiaoxiao2021-03-06  19

& nbsp The principle is simple, and the principle of dragging no title window is the same, send a message Duttondown to CAPTION when the mousedown event is sent. This principle can be used as long as it is inherited from the form, the code is as follows:

Option expedition

Private Declare Function SendMessage LIB "User32" Alias ​​"SendMessagea" (Byval Hwnd As Long, Byval WParam As Long, LParam As Any) As long

Private Declare Function ReleaseCapture LIB "User32" () AS Long

Private const wm_nclbuttondown = & ha1

Private const htcaption = 2

Private submmand1_mousedown (Button as Integer, Shift As Integer, x as single, y as single)

ReleaseCapture

SendMessage Command1.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0

End Sub

转载请注明原文地址:https://www.9cbs.com/read-42450.html

New Post(0)