VB中好像有一个控件具有标题栏的功能,请问是哪个?
用两个API函数
Public Declare Function ReleaseCapture Lib "user32" () As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
这是我的一个程序的代码:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
ReleaseCapture '释放鼠标
SendMessage Form1.hWnd, &HA1, 2, 0&
Option Explicit
Private isMouseDown As Boolean
Private mouseX As Integer
Private mouseY As Integer
Private currX As Integer
Private currY As Integer
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
isMouseDown = True
mouseX = X
mouseY = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If isMouseDown Then
currX = Me.Left - mouseX + X
currY = Me.Top - mouseY + Y
Me.Move currX, currY
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
isMouseDown = False
End Sub