是否可以使用Windows API更改VBA用户窗体标题栏的颜色。请注意,我只对更改特定用户窗体标题栏的颜色感兴趣,而不是在系统范围内更改它们。谢谢!
纯娱乐;
用户表格:
Private gHWND As Long
Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 1 Then HandleDragMove gHWND
End Sub
Private Sub UserForm_Initialize()
gHWND = Setup(Me)
End Sub
Private Sub UserForm_Click()
Unload Me
End Sub
*。低
Option Explicit
Private Const WM_NCLBUTTONDOWN = &HA1&
Private Const HTCAPTION = 2&
Private Const GWL_STYLE = (-16)
Private Const WS_BORDER = &H800000
Private Const WS_DLGFRAME = &H400000
Private Const WS_CAPTION = WS_BORDER Or WS_DLGFRAME
Private Declare Sub ReleaseCapture Lib "User32" ()
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
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal HWND As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal HWND As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Function Setup(objForm As Object) As Long
Setup = FindWindow("ThunderDFrame", objForm.Caption)
SetWindowLong Setup, GWL_STYLE, GetWindowLong(Setup, GWL_STYLE) And Not WS_CAPTION
End Function
Public Sub HandleDragMove(HWND As Long)
Call ReleaseCapture
Call SendMessage(HWND, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End Sub
(64位Office需要mod)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句