Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TrackMouseEvent

Status
Not open for further replies.

mattKnight

Programmer
Joined
May 10, 2002
Messages
6,239
Location
GB
I am trying to use the TrackMouseEvent to initiate WM_NCMOUSEHOVER messages.

Here is the code that I am using to set up the mouse tracking.

If I comment out the TME_NONCLIENT constant, I capture the WM_MOUSEHOVER messages in the message handler and reading back the tracking information into the second udt gives sensible values. However, if I include the TME_NONCLIENT constant in the dwFlags member, I get no messages (either WM_MOUSEHOVER, WM_NCMOUSEHOVER and (if requested) WM_MOUSELEAVE). I also get 0 in the read back UDT.

I am using Windows 2000 and VB6 sp5
Code:
'API Declarations

Public Type udtTrackMouseEvent
    cbSize As Long
    dwFlags As Long
    hwndTrack As Long
    dwHoverTime As Long
End Type

 Public Declare Function TrackMouseEvent Lib "comctl32" Alias "_TrackMouseEvent" (lpEventTrack As udtTrackMouseEvent) As Long

Code:
Private Sub InitMouseTrack(hForm As Long)
Dim udtSetTME As udtTrackMouseEvent, udtReadTME As udtTrackMouseEvent

With udtSetTME
    .cbSize = Len(udtSetTME)
    .dwFlags = TME_HOVER '+ TME_NONCLIENT
    .dwHoverTime = HOVER_DEFAULT
    .hwndTrack = hForm
End With

Debug.Print "Setting TrackMouseEvent "; TrackMouseEvent(udtSetTME)

With udtReadTME
    .cbSize = Len(udtReadTME)
    .dwFlags = TME_QUERY
End With

Debug.Print "Querying TrackMouseEvent "; TrackMouseEvent(udtReadTME)

Debug.Print "Flags "; udtReadTME.dwFlags
Debug.Print "Hover "; udtReadTME.dwHoverTime
Debug.Print "hWnd "; udtReadTME.hwndTrack



End Sub

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Solved it!

For the TrackMouseEventCall to work with the TME_NONCLIENT flag, the call needs to be made whilst the mouse cursor is in[/b a Non client area of the screen! Thats where I was going wrong!

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top