• 0

C++: Mouse Hover Function?


Question

3 answers to this question

Recommended Posts

  • 0

C++ doesn't include the notion of a mouse. It would be easier if you told us the platform you are working on.

For Windows, it would look something like this:

BOOL bIsFirstMouseMove = FALSE;

WndProc(......)
switch(msg)
{
   case WM_MOUSEMOVE:
      if(bIsFirstMouseMove)
      {
           TRACKMOUSEVENT tme = {......};
           TrackMouseEvent(&tme);
           OnMouseEnter(); // your handler
           bIsFirstMouseMove = FALSE;
       }
   break;
  
  case WM_MOUSELEAVE:
       OnMouseLeave(); // your handler
       bIsFirstMouseMove = TRUE;
  break;
}

  • 0

C++ what? Borland VCL, MFC, WinAPI or an API on some other platform?

There are Windows Messages WM_MOUSEMOVE (you should also be able to use WM_MOUSEHOVER) and WM_MOUSELEAVE you can respond to to detect when the mouse enters and leaves the client area of a Window (control).

edit: yea, just like the post above

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Apart from a few very specific hiccups, Windows 11 has been good for me. Rock solid and stable. Unpopular opinion, I know, but it's mine.
    • No. Windows 8 had little to no spywhare, is actually faster than 7 but it has the dreaded start screen, nothing that you could not fix with start8. Windows ME crashed often, but was shotlived and replaced by XP, which is a much better windows in itself.
    • Windows 8 was uninspiring but it was fine / worked. It was just overshadowed by how great Windows 7 was. Windows ME seem to be just unstable for most people - I was using Windows 2000, which was far superior. The two best versions are Windows 7 and 2000
    • I don't think ME was that bad. The stability issues were mostly caused by drivers. This was when the switch from vxd to wdm was happening. The other complaint was not being able to shut down into DOS anymore which was silly with XP right around the corner.
    • As much as I hated Windows 8, although I never used it personally on any of my own machines, I think Windows Me was hands down the worst OS from MS. I have Windows 11 on 2 unsupported machines and haven't had any issues and I actually kind of like it. Still hate how slow Windows updates are though.
  • Recent Achievements

    • Rookie
      +ChiefOfNeo went up a rank
      Rookie
    • One Month Later
      Tom Schmidt earned a badge
      One Month Later
    • Week One Done
      Tom Schmidt earned a badge
      Week One Done
    • One Year In
      Tom Schmidt earned a badge
      One Year In
    • One Month Later
      JimErn earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      453
    2. 2
      +Edouard
      176
    3. 3
      PsYcHoKiLLa
      122
    4. 4
      Michael Scrip
      81
    5. 5
      Xenon
      75
  • Tell a friend

    Love Neowin? Tell a friend!