Results 1 to 1 of 1

Thread: Not Receiving WM_MOUSEHOVER

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,708

    Not Receiving WM_MOUSEHOVER

    I have a subclassed textbox that I wish to detect the hover event on. However I am not receiving this message.

    Code:
    Private Declare Function TRACKMOUSEEVENT Lib "user32" Alias "TrackMouseEvent" (lpEventTrack As TRACKMOUSEEVENT) As Boolean
    Private Type TRACKMOUSEEVENT
        cbSize As Long
        dwFlags As Long
        hwndTrack As Long
        dwHoverTime As Long
    End Type
    Private Const TME_HOVER As Long = &H1
    Private Const TME_LEAVE As Long = &H2
    Private Const TME_QUERY As Long = &H40000000
    Private Const TME_CANCEL As Long = &H80000000
    Private Const HOVER_DEFAULT As Long = &HFFFFFFFF
    
    Public Sub TrackHover(hWnd As Long)
    
    Dim tme As TRACKMOUSEEVENT
    
    tme.cbSize = Len(tme)
    tme.dwFlags = TME_HOVER
    tme.dwHoverTime = HOVER_DEFAULT
    tme.hwndTrack = hWnd
    
    Call TRACKMOUSEEVENT(tme)
    
    End Sub
    
    Public Function ECWndProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    
       Select Case uMsg
          Case WM_MOUSEHOVER
            TrackHover hWnd
            Debug.Print "Received WM_MOUSEHOVER"
        Case WM_CONTEXTMENU
            Debug.Print "Received WM_CONTEXTMENU"
          Case WM_DESTROY
            Call CallWindowProc(GetProp(hWnd, OLDWNDPROC), hWnd, uMsg, wParam, lParam)
            Call UnSubClass(hWnd)
            Exit Function
       End Select
       
          ECWndProc = CallWindowProc(GetProp(hWnd, OLDWNDPROC), hWnd, uMsg, wParam, lParam)
    
    End Function
    [Form.Load]
    Call Subclass(Text20.hwnd, AddressOf ECWndProc)
    TrackHover Text20.hwnd
    I don't see where the problem is. Not even getting an initial message, nevermind subsequent ones. It is subclassed correctly; tested with that WM_CONTEXTMENU. I also tried _TrackMouseEvent in comctl32. Any ideas??

    Edit: Well, now things are really infuriating: when I change it to tme.dwFlags = TME_HOVER Or TME_LEAVE, I successfully receive WM_MOUSELEAVE, but still not WM_MOUSEHOVER.
    Edit2: Disregard the previous edit, I receive WM_MOUSELEAVE even without TME_LEAVE being set.
    Last edited by fafalone; Feb 19th, 2012 at 10:36 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width