运用本段代码可以使任意控件像窗体标题栏一样具有拖动窗体的功能。
先在模块中加入以下代码:
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
Public Sub DoDrag(TheForm As Form)
If TheForm.WindowState vbMaximized Then
ReleaseCapture
SendMessage TheForm.hwnd, &HA1, 2, 0&
End If
End Sub
用法:
DoDrag Me '可以当标题栏拖动
End Sub
其中的Label1是控件名,可以替换成其他控件。
转载请保留链接:https://ilovetile.sijie.wang/45/ 感谢您对版权的尊重