rollover buttons & WM_MOUSEMOVE & stuff
-
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
-
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
-
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
-
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.
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
-
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.
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.