Ok here's my question since reacting speed was crutial with this one I diceded to use this API to control MouseMove off of a listbox I have.
I love the acuracy and speed of it but the only problem, it will trigger the "mouse leave event" if I hover over the listbox's own vertical scrollbar.
I tried to find a spot within the code where I could tell it to trigger only if it leaves off the scrollbar area on the right of the listbox but I miserably failed!#"!
Anyone see the answer to this problem?
Thanks a bunch
VB Code:
  1. 'MODULE-------------------------------------------------------------
  2. Option Explicit
  3. Public Const TME_CANCEL = &H80000000
  4. Public Const TME_HOVER = &H1&
  5. Public Const TME_LEAVE = &H2&
  6. Public Const TME_NONCLIENT = &H10&
  7. Public Const TME_QUERY = &H40000000
  8. Public Const WM_MOUSELEAVE = &H2A3&
  9.  
  10. Public Type TRACKMOUSEEVENTTYPE
  11.     cbSize As Long
  12.     dwFlags As Long
  13.     hwndTrack As Long
  14.     dwHoverTime As Long
  15.  
  16. End Type
  17.  
  18. Public Declare Function TrackMouseEvent Lib "user32" (lpEventTrack As TRACKMOUSEEVENTTYPE) As Long
  19. Public Declare Function SetCursorPos Lib "user32.dll" (ByVal X As Long, ByVal Y As Long) As Long
  20.  
  21. Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  22. Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  23.  
  24. Public Const GWL_WNDPROC = (-4)
  25. Public PrevProc As Long
  26.  
  27. Public Sub HookForm(F As Control)
  28. PrevProc = SetWindowLong(F.hWnd, GWL_WNDPROC, AddressOf WindowProc)
  29. End Sub
  30.  
  31. Public Sub UnHookForm(F As Control)
  32. SetWindowLong F.hWnd, GWL_WNDPROC, PrevProc
  33. End Sub
  34.  
  35. Public Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  36.  
  37. If uMsg = WM_MOUSELEAVE Then
  38.     'if we receive a WM_MOUSELEAVE message, show it
  39.     'set caption back to what it was
  40.  Form1.List6.Height = 22
  41.  
  42. End If
  43.  
  44. WindowProc = CallWindowProc(PrevProc, hWnd, uMsg, wParam, lParam)
  45. End Function
  46.  
  47.  
  48. 'FORM1-----------------------------------------------------------------------
  49. Private Sub Form_Load()
  50.   HookForm List6
  51. End Sub
  52.  
  53.  
  54. Private Sub List6_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  55. Dim ET As TRACKMOUSEEVENTTYPE
  56.  
  57.     'initialize structure
  58.     ET.cbSize = Len(ET)
  59.     ET.hwndTrack = List6.hWnd
  60.     ET.dwFlags = TME_LEAVE
  61.     'start the tracking
  62.     TrackMouseEvent ET
  63.     List6.Height = 150
  64. End Sub
  65.  
  66. Private Sub Form_Unload(Cancel As Integer)
  67.   UnHookForm List6
  68. End Sub