🔒 Locked
How do I avoid mouse pointer flicker?
Advertisement
Original Post
I'm afraid that won't do it either. The problem is that you need to see the mouse cursor to manipulate the program's window. When the cursor is hidden it's hidden whenever it's on top of the program's window, making it difficult for the user to move, maximize, minimize, or close the window.
[edited by - chronos on September 27, 2002 3:31:19 PM]
[edited by - chronos on September 27, 2002 3:31:19 PM]
The solution isn''t a very pretty one... I''ll try to point you in the right direction:
Ok, you''ll need to use the _trackmouseevent function to inform Windows that you want to be notified when the mouse leaves the client area of your window. Like this:
Then you''ll need to have message handlers for the WM_MOUSELEAVE and WM_MOUSEMOVE events which keep track of the status of the mouse. Something like this:
That''s the basic idea. You may also want to add additional checks for when your program loses the window focus and re-enable the Windows mouse cursor and set mouse_in_client false.
Any questions more than welcome. I try my best.
- Air
- Hour 13 Studios
Ok, you''ll need to use the _trackmouseevent function to inform Windows that you want to be notified when the mouse leaves the client area of your window. Like this:
void Set_MouseLeaveEvent(HWND hwnd)
{
TRACKMOUSEEVENT tevt;
CLEAR_STRUCT(tevt);
tevt.cbSize = sizeof(TRACKMOUSEEVENT);
tevt.dwFlags = TME_LEAVE;
tevt.hwndTrack = hwnd;
_TrackMouseEvent(&tevt);
}
Then you''ll need to have message handlers for the WM_MOUSELEAVE and WM_MOUSEMOVE events which keep track of the status of the mouse. Something like this:
static mouse_in_client = FALSE;
case WM_MOUSELEAVE:
// In windowed mode, we show the Windows mouse and hide ours!
while(ShowCursor(TRUE) < 0);
mouse_in_client = FALSE;
// [Disable your custom mouse cursor here]
// [...]
break;
case WM_MOUSEMOVE:
if(!mousewenthome)
{
while(ShowCursor(FALSE) > -1);
Set_MouseLeaveEvent();
mouse_in_client = TRUE;
// [Enable your custom-rendered mouse cursor here]
// [...]
}
break;
That''s the basic idea. You may also want to add additional checks for when your program loses the window focus and re-enable the Windows mouse cursor and set mouse_in_client false.
Any questions more than welcome. I try my best.
- Air
- Hour 13 Studios
Thanks Air. It''s not an ideal solution by any means, but at least it''s one way to fix the problem.
It''s a shame that I can''t find a way to keep the cursor visible. I wonder how programs like the Direct3D demos manage to draw to a windowed app without causing the mouse pointer to flicker. Surely there''s an answer to the mystery.
It''s a shame that I can''t find a way to keep the cursor visible. I wonder how programs like the Direct3D demos manage to draw to a windowed app without causing the mouse pointer to flicker. Surely there''s an answer to the mystery.
I''m confused too as to why you would be getting flicker. Usually the mouse cursor these days is a hardware device-- that is, the video card renders the cursor and subsequently it ensures the cursor is always on top and always visible. I know some older video cards have problems with color mouse cursors (the ATI Rage 128 comes to mind), and simply don''t support them in hardware. On those cards any program which uses a redefined Windows mouse cursor will have flickering problems because Windows must render it manually and without the assistence of VR-wait timing that you can utilize in a fullscreen mode.
But that''s the only reason I''m aware of that would cause flicker.
- Air
But that''s the only reason I''m aware of that would cause flicker.
- Air
Well, I''m having the same problem. I have some double-buffered OpenGL windows, and the cursor flickers terribly when I put it over them. I''m rendering a mouse pointer at the moment, but I would like a WorldCraft style mouse pointer, where it uses Windows'' mouse point, rather than drawing it''s own. There must be a solution to this flickering?
Movie Quote of the Week:
"You''ve been eating retard sandwiches again."
- Birdman, Beautiful Girls.
Try http://uk.geocities.com/mentalmantle. Seriously. It''s brilliant.
And I just completely redesigned it so it looks even better.
DarkVertex Beta 0.8 available soon!
Movie Quote of the Week:
"You''ve been eating retard sandwiches again."
- Birdman, Beautiful Girls.
Try http://uk.geocities.com/mentalmantle. Seriously. It''s brilliant.
And I just completely redesigned it so it looks even better.
DarkVertex Beta 0.8 available soon!
I've noticed that the flickering happens when the display is set to 24bpp (in Display Properties - Settings), but not when it's set to 16bpp. It turns out that 16bpp modes on my computer are hardware accelerated and 24bpp modes are not. Direct3D apps don't cause the mouse to flicker at all, regardless of the bit depth (16bpp or 24bpp) and rasterizer (software or HAL).
I'm still hoping for a solution, but thanks to all of you for trying.
[edited by - chronos on September 28, 2002 5:50:25 PM]
I'm still hoping for a solution, but thanks to all of you for trying.
[edited by - chronos on September 28, 2002 5:50:25 PM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement