最小化用户窗体时取消滚动

时间:2018-09-25 14:08:07

标签: excel-vba scroll office-2016

我对stackoverflow已经走了很长一段路,但是我需要结合我在stackoverflow上找到的一个主题和在另一个论坛Mouse scroll in UserForm上找到的一个主题

对于我的UserForm,我在关闭Userform时已激活(钩住了)滚轮并取消了(解钩)了滚轮。但是现在,对于我所构建的应用程序的下一次更新,同事们需要一个最小化按钮。我是通过以下主题实现的; Minimize userform and create icon on taskbar

但是现在当我最小化用户窗体时,滚动并没有被钩住(UnhookFormScroll

我确实研究了将UserForm_Layout()IsIconic (Link how that should be used, but instead I used UnhookFormScroll)结合使用的解决方案;

'The 5 lines of code beneath need to be somewhere else in the module of the 
'form
Option Explicit
Private Declare Function IsZoomed Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function IsIconic Lib "user32" _
(ByVal hWnd As Long) As Long

Private Sub UserForm_Layout()
'I have edited the code so it works for whoever passes this post in the future

    Dim hWnd as Long

    If IsIconic(hwnd) Then
        UnhookFormScroll
    End if

    If IsZoomed(hwnd) Then
        HookFormScroll Me
    End If

End Sub

但这会导致Excel / VBA无法识别变量“ hwnd”的错误

我希望有人能帮助我!

谢谢!

0 个答案:

没有答案
相关问题