Mouseover (and MouseLeave) for a form

Started by Robert Eaton, February 11, 2011, 04:48:01 PM

Previous topic - Next topic

Robert Eaton

I'm trying to track when the mouse enters and leaves a form (I'm essentially trying to do a flyout form that parks mostly off screen.)

I found an example that uses the TrackMouseEvent API, and that works fine EXCEPT the WM_MouseLeave message also fires whenever the  mouse passes over any controls on the form.
Do I have to somehow track the mouse for every control or is there any easier way?

Any ideas?

Thanks,
Bob



Function FRMMAIN_CUSTOM ( _
                        hWndForm      As Dword, _  ' handle of Form
                        wMsg          As Long,  _  ' type of message
                        wParam        As Dword, _  ' first message parameter
                        lParam        As Long   _  ' second message parameter
                        ) As Long

   Local trackMouseC As TrackMouseEventAPI
   
   Select Case As Long wmsg
      Case %WM_MOUSEMOVE
         trackMouseC.cbSize = SizeOf(trackMouseC)
         trackMouseC.dwFlags = %TME_LEAVE
         trackMouseC.hwndTrack = HWND_FRMMAIN
         TrackMouseEvent(trackMouseC)
         FF_Control_SetText( HWND_FRMMAIN, "Mouse In" )
         
      Case %WM_MOUSELEAVE
         FF_Control_SetText( HWND_FRMMAIN, "Mouse Out" )         
           
  End Select



End Function

Robert Eaton

Nevermind.

Looks like a better approach will be to use GetCursorPos.