Tác giả: Trần Đại Nghĩa
Mô tả: Di chuyển Picture trong khi Runtime
Mã: Chọn hết
- Private Declare Function ReleaseCapture Lib "user32" () As Long
- Private 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_NCLBUTTONDOWN = &HA1
- Const HTCAPTION = 2
-
- Private Sub Form_Load()
- Picture1.AutoRedraw = True
- Picture1.Print "Click here to move me!"
- Me.AutoRedraw = True
- Me.Print "Click here to move me!"
- End Sub
-
- Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
- ReleaseCapture
- SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
- End Sub
-
- Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
- ReleaseCapture
- SendMessage Picture1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
- End Sub