需要有关 Access 中的 Mousemove 事件的帮助 VBA

Need Help on Mousemove event in Access VBA

我正在为我的数据库创建一个侧面菜单,它在按钮上使用 mousemove 事件。当鼠标指针悬停在按钮上时,它会改变背景颜色、前景色和背景样式。我使用了以下代码:

Private Sub ProductBtn_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Me.ProductBtn.BackStyle = 1
Me.ProductBtn.BackColor = RGB(164, 213, 226)
Me.ProductBtn.ForeColor = RGB(0, 114, 188)

End Sub

(注:Button的背面样式设置为透明)

当我尝试按下按钮时发生了以下情况....

问题是当我将鼠标指针移到按钮上时,它不会恢复正常或重置为默认值(如第一张图片)。我该怎么做?请帮助。

像这个例子一样使用HoverColorHoverForeColor

Public Sub StyleCommandButtons(ByRef frm As Form)

' Apply a style to all non-transparent command buttons on a form.
' 2014-10-10. Gustav Brock, Cactus Data ApS, CPH.
' Version 1.0.0
' License: MIT.

' Requires:
'   Module:
'       ModernThemeColours

' Typical usage:
'
'   Private Sub Form_Load()
'       Call StyleCommandButtons(Me)
'   End Sub

    Dim ctl                 As Control
    
    For Each ctl In frm.Controls
        If ctl.ControlType = acCommandButton Then
            If ctl.Transparent = True Then
                ' Leave transparent buttons untouched.
            Else
                ctl.Height = 454
                ctl.UseTheme = True
                If ctl.Default = True Then
                    ctl.BackColor = wpThemeColor.Cobalt
                Else
                    ctl.BackColor = ctl.Parent.Section(ctl.Section).BackColor
                End If
                ctl.HoverForeColor = ctl.BackColor
                ctl.HoverColor = wpThemeColor.White
                ctl.PressedColor = wpThemeColor.Darken
                ctl.BorderWidth = 2
                ctl.BorderStyle = 1
                ctl.BorderColor = wpThemeColor.White
                ctl.ForeColor = wpThemeColor.White
                ctl.FontName = "Segoe UI"
                ctl.FontSize = 11
                ctl.FontBold = True
                ctl.FontItalic = False
            End If
        End If
    Next
    
    Set ctl = Nothing

End Sub

另外:VBA.ModernBox