Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. rollover buttons & WM_MOUSEMOVE & stuff

rollover buttons & WM_MOUSEMOVE & stuff

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelptutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tre K Renegade
    wrote on last edited by
    #1

    Hi, Anyone have any suggestions on how to solve the following prob? The interface of my app is built out of several different child windows and one of those contains a small coloured square. When you move the mouse over it some text is displayed. The problem is that when you move the mouse out of the square AND out of the child window too fast the text doesn't disappear, because the WM_MOUSEMOVE message doesn't fire fast enough. I suppose I could solve it by letting the rollover trigger a timer loop that keeps checking whether the mouse is still over the square, but that seems like a difficult solution. Perhaps there is a more graceful solution; like an event that fires when the mouse leaves the child window or something? Thanks, ren

    J H 2 Replies Last reply
    0
    • T Tre K Renegade

      Hi, Anyone have any suggestions on how to solve the following prob? The interface of my app is built out of several different child windows and one of those contains a small coloured square. When you move the mouse over it some text is displayed. The problem is that when you move the mouse out of the square AND out of the child window too fast the text doesn't disappear, because the WM_MOUSEMOVE message doesn't fire fast enough. I suppose I could solve it by letting the rollover trigger a timer loop that keeps checking whether the mouse is still over the square, but that seems like a difficult solution. Perhaps there is a more graceful solution; like an event that fires when the mouse leaves the child window or something? Thanks, ren

      J Offline
      J Offline
      JohnMcL
      wrote on last edited by
      #2

      perhaps WM_MOUSELEAVE could do this

      1 Reply Last reply
      0
      • T Tre K Renegade

        Hi, Anyone have any suggestions on how to solve the following prob? The interface of my app is built out of several different child windows and one of those contains a small coloured square. When you move the mouse over it some text is displayed. The problem is that when you move the mouse out of the square AND out of the child window too fast the text doesn't disappear, because the WM_MOUSEMOVE message doesn't fire fast enough. I suppose I could solve it by letting the rollover trigger a timer loop that keeps checking whether the mouse is still over the square, but that seems like a difficult solution. Perhaps there is a more graceful solution; like an event that fires when the mouse leaves the child window or something? Thanks, ren

        H Offline
        H Offline
        HENDRIK R
        wrote on last edited by
        #3

        Perhaps calling TrackMouseEvent helps. Then you're notified about the mouse entering or leaving your window, and you're able to react properly on WM_MOUSELEAVE.

        J T 2 Replies Last reply
        0
        • H HENDRIK R

          Perhaps calling TrackMouseEvent helps. Then you're notified about the mouse entering or leaving your window, and you're able to react properly on WM_MOUSELEAVE.

          J Offline
          J Offline
          Jonathan Darka
          wrote on last edited by
          #4

          If you want to do it using a timer, here is an example. // Header UINT m_uiTimerId; // CPP file m_uiTimerId = 100; // Or whatever value you want // In your message handler case WM_MOUSEMOVE : { if(!bHovering) { SetTimer(hThisWnd, m_uiTimerId, 100, NULL); bHovering = true; } } return 0; case WM_TIMER : // Timer { POINT obPoint; memset(&obPoint, 0, sizeof(POINT)); GetCursorPos(&obPoint); ScreenToClient(hThisWnd, &obPoint); RECT obRect; GetClientRect(hThisWnd, &obRect); if(!PtInRect(&obRect, obPoint)) // Is the mouse still over our control { bHovering = false; KillTimer(hThisWnd, m_uiTimerId); obRect.bottom += 10; InvalidateRect(hThisWnd, &obRect, TRUE); } } break; // Let this fall through regards, Dark Angel www.sfxangel.com

          1 Reply Last reply
          0
          • H HENDRIK R

            Perhaps calling TrackMouseEvent helps. Then you're notified about the mouse entering or leaving your window, and you're able to react properly on WM_MOUSELEAVE.

            T Offline
            T Offline
            Tre K Renegade
            wrote on last edited by
            #5

            Thanks. This was exactly the type of solution I was looking for. Just a note though: I had to use _TrackMouseEvent instead of TrackMouseEvent. Apparently the regular TrackMouseEvent is not supported on all Windows platforms (mine is XP and the compiler threw an 'undeclared identifier'). But you can still use _TrackMouseEvent; it just calls TrackMouseEvent if it is defined and emulates it if not. Thanks again.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups