ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¦p¦óÅýComboBox¥i¥H¥Î·Æ¹«ºu°Ê?

[µo°Ý] ¦p¦óÅýComboBox¥i¥H¥Î·Æ¹«ºu°Ê?

§ÚªºComboBox¸ÌÁ`¦@¦³¦h¹F45­Ó¿ï¶µ
¦p¦ó¨Ï¥Î·Æ¹«ºu°Ê¨Ó¨Ó¿ï¾Ü¿ï³æ¤¤¨ä¥L¿ï¶µ?

¦^´_ 1# acdx

¦³ªþ¥ó¶Ü¡H
ss

TOP

combox.zip (14.22 KB)
ªþ¥ó¦p¤W

TOP

¦^´_ 3# acdx
¸Õ¸Õ¬Ý¡I
combox.rar (17.71 KB)

TOP

¦^´_ 3# acdx
ªí³æ->UserForm1
  1. Private Sub UserForm_Activate()   
  2.     ComboBox1.Value = "150"
  3.     ComboBox1.List = Array("150", "200", "250", "300", "350", "400", "450", "500", "510", "570", "630", _
  4.         "700", "770", "840", "920", "1000", "1080", "1170", "1270", "1370", "1480", "1600", "1720", "1850", "2000", _
  5.         "2150", "2320", "2500", "2700", "2900", "3150", "3400", "3700", "4000", "4400", "4800", "5300", "5800", _
  6.         "6400", "7000", "7700", "8500", "9500", "10500", "12000", "13500")
  7. End Sub

  8. Sub ComboBox1_DropButton()
  9.     'Store the first TopIndex Value
  10.     intTopIndex = ComboBox1.TopIndex
  11.     Hook_Mouse
  12. End Sub

  13. Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
  14.     UnHook_Mouse
  15. End Sub
½Æ»s¥N½X

TOP

¦^´_ 4# c_c_lai
¼Ò²Õ->Module1¡G
  1. Option Explicit

  2. Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
  3.         (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

  4. Declare Function GetForegroundWindow Lib "user32" () As Long

  5. Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
  6.         (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long)

  7. Declare Function SetWindowsHookEx Lib _
  8.         "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, _
  9.         ByVal hmod As Long, ByVal dwThreadId As Long) As Long

  10. Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, _
  11.         ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long

  12. Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long

  13. Type POINTAPI
  14.     X As Long
  15.     Y As Long
  16. End Type

  17. Type MSLLHOOKSTRUCT 'Will Hold the lParam struct Data
  18.     pt As POINTAPI
  19.     mouseData As Long ' Holds Forward\Bacward flag
  20.     flags As Long
  21.     time As Long
  22.     dwExtraInfo As Long
  23. End Type

  24. Const HC_ACTION = 0
  25. Const WH_MOUSE_LL = 14
  26. Const WM_MOUSEWHEEL = &H20A

  27. Dim hhkLowLevelMouse, lngInitialColor As Long
  28. Dim udtlParamStuct As MSLLHOOKSTRUCT
  29. Public intTopIndex As Integer

  30. Private Sub Auto_open()
  31.     UserForm1.ComboBox1_DropButton
  32.     UserForm1.Show
  33. End Sub

  34. '  ==========================================================================
  35. '  \\Copy the Data from lParam of the Hook Procedure argument to our Struct
  36. Function GetHookStruct(ByVal lParam As Long) As MSLLHOOKSTRUCT
  37.    CopyMemory VarPtr(udtlParamStuct), lParam, LenB(udtlParamStuct)
  38.    GetHookStruct = udtlParamStuct
  39. End Function

  40. '  ===========================================================================
  41. Function LowLevelMouseProc _
  42.         (ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  43.     '  Avoid XL crashing if RunTime error occurs due to Mouse fast movement
  44.     On Error Resume Next

  45.     If (nCode = HC_ACTION) Then
  46.         If wParam = WM_MOUSEWHEEL Then
  47.                 '\\ Don't process Default WM_MOUSEWHEEL Window message
  48.                 LowLevelMouseProc = True
  49.                 '  \\ Change this to your userform name
  50.                 With UserForm1.ComboBox1
  51.                 '  \\ if rolling forward increase Top index by 1 to cause an Up Scroll
  52.                 If GetHookStruct(lParam).mouseData > 0 Then
  53.                     .TopIndex = intTopIndex - 1
  54.                     '  \\ Store new TopIndex value
  55.                     intTopIndex = .TopIndex
  56.                 Else '  \\ if rolling backward decrease Top index by 1 to cause _
  57.                     '  \\a Down Scroll
  58.                     .TopIndex = intTopIndex + 1
  59.                     '  \\ Store new TopIndex value
  60.                     intTopIndex = .TopIndex
  61.                 End If
  62.            End With
  63.         End If
  64.         Exit Function
  65.     End If

  66.     LowLevelMouseProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
  67. End Function

  68. '  =======================================================================
  69. Sub Hook_Mouse()
  70.     hhkLowLevelMouse = SetWindowsHookEx _
  71.         (WH_MOUSE_LL, AddressOf LowLevelMouseProc, Application.Hinstance, 0)
  72. End Sub

  73. '  ========================================================================
  74. Sub UnHook_Mouse()
  75.     If hhkLowLevelMouse <> 0 Then UnhookWindowsHookEx hhkLowLevelMouse
  76. End Sub
½Æ»s¥N½X

TOP

¦^´_ 3# acdx
¼Ò²Õ¸Ì¦A¥[¤W¡G
  1. Private Sub Auto_Close()
  2.     UnHook_Mouse
  3. End Sub
½Æ»s¥N½X
©óÂ÷¶}®É¦P®ÉÃö³¬ Hook¡C

TOP

¦^´_ 6# c_c_lai
¬°¦ó·|»Ý­n
Private Sub Auto_open()
UserForm1.ComboBox1_DropButton
UserForm1.Show
End Sub
§Ú¤£»Ý­n¦Û°Ê¶}±Òªí³æ ¬O­n§â¥¦®³±¼¶Ü?

TOP

¦^´_ 8# acdx
¨º¥u¬O­n´£¥Ü§A¡A¦b¨Ï¥Î¶}±Ò UserForm1«e­n¥ý°õ¦æ
Hook ªº°Ê§@¦Ó¤w¡A¦P®É¤]¬°¤FÅý§A¥´¶}Àɮ׮ɡA«K©ó
Æ[¹î¨ì Mouse Wheel ªº¹B¥Î¡C

TOP

¦^´_ 8# acdx
½Ð°Ñ¦Ò¡G
Mouse wheel scroll in a combobox on userform

TOP

        ÀR«ä¦Û¦b : ¡i¬O§_µo´§¤F¨}¯à¡H¡j¤H¶¡¹Ø©R¦]¬°µu¼È¡A¤~§óÅã±o¬Ã¶Q¡CÃø±o¨Ó¤@½ë¤H¶¡¡AÀ³°Ý¬O§_¬°¤H¶¡µo´§¤F¦Û¤vªº¨}¯à¡A¦Ó¤£­n¤@¨ý¨Dªø¹Ø¡C
ªð¦^¦Cªí ¤W¤@¥DÃD