|
-
Aug 22nd, 2001, 09:54 AM
#1
Thread Starter
Registered User
WM_SIZE doesn't work as intended
Hello! I hope that you can halp me with my particular problem.
I need to hide the mousecurser when the window is getting maximized and to display it again when the window gets restored.
Now i do the following:
Code:
if (wParam == SIZE_MAXIMIZED) //check whether the user has maximized the window
{
memset(&devModeScreen, 0, sizeof(devModeScreen));
devModeScreen.dmSize = sizeof(devModeScreen);
devModeScreen.dmPelsWidth = screenWidth;
devModeScreen.dmPelsHeight = screenHeight;
devModeScreen.dmBitsPerPel = screenBpp;
devModeScreen.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
dwExStyle = WS_EX_APPWINDOW; //hide all topper level windows
dwStyle = WS_POPUP; //remove the window borders
ShowCursor(FALSE); //hide the cursor
fullScreen = true;
}
else
{
dwExStyle=NULL;
dwStyle = WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
ShowCursor(TRUE); //show the cursor
fullScreen = false;
}
But this code doesn't hide the cursor at all! It first hides it and then shows it up again even though i put it into the else chunk.
I've already tried to use SIZE_RESTORED instead of the else and this has the same effect. Hence i think it's always calling for the SIZE_RESTORED. But why is it doing that? I'm not restoring it at all!
(I can't imagine this is not due to a wrong if/else formulation , I simply don't get it why it does that
Last edited by Olly; Aug 22nd, 2001 at 10:59 AM.
-
Aug 22nd, 2001, 12:54 PM
#2
PowerPoster
how are the styles of you window class? Have you included CS_HREDRAW and CS_VREDRAW for the style the window class??
-
Aug 22nd, 2001, 05:10 PM
#3
Thread Starter
Registered User
yes, sure I did, It's not about that. It hides te cursor perfectly when I remove the ShowCursor(TRUE) in the else chunk for all other events.
I tried to use
if (wParam != SIZE_MAXIMIZED)
instead of the else and it didn't hide the cursor either. But when i tried it with SIZE_MINIMIZED it hid it. I tried SIZE_RESTORED but then the curser is always visible?! Why is it always going through the code for all other events? Is there something wrong using WS_SIZE?
Is there something tricky with SIZE_RESTORED?
(I need it for my OpenGl fullscreen mode)
-
Aug 22nd, 2001, 05:20 PM
#4
PowerPoster
Sorry, I am not familiar with this message but are you putting this code under the WM_SIZE message and returning 0 at the end?
-
Aug 22nd, 2001, 05:25 PM
#5
Thread Starter
Registered User
I got it in the LRESULT CALLBACK and using it in the message switch and am also returning a 0.
I tried the following, but with no success either. So I think there must be something wrong with that RESTORE thing as it doesn'T seem to catch when you are restoring a maximized window to the old state.
what i tried:
Code:
if (wParam != SIZE_RESTORED || wParam != SIZE_MINIMIZED || wParam != SIZE_MAXIMIZED) //check whether the user has maximized the window
{
dwExStyle=NULL;
dwStyle = WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
ShowCursor(TRUE); //show the cursor
fullScreen = false;
}
else //check whether the user has maximized the window
{
memset(&devModeScreen, 0, sizeof(devModeScreen));
devModeScreen.dmSize = sizeof(devModeScreen);
devModeScreen.dmPelsWidth = screenWidth;
devModeScreen.dmPelsHeight = screenHeight;
devModeScreen.dmBitsPerPel = screenBpp;
devModeScreen.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
dwExStyle = WS_EX_APPWINDOW; //hide all topper level windows
dwStyle = WS_POPUP; //remove the window borders
ShowCursor(FALSE); //hide the cursor
fullScreen = true;
}
-
Aug 23rd, 2001, 09:31 AM
#6
this is simple.
ShowCursor increments/decrements a counter. If the counter falls below 1, the cursor is hidden. Since the counter starts at 1 and the usual initial WM_SIZE message (after creation) is a RESTORE message, the counter is incremented to 2, and after maximizing is still one, thus the cursor remains visible. The question is how to prevent ShowCursor to be called only the first time. You COULD use a BOOL bFirstCall, but it is rather inefficient, so if one comes up with a better idea don't hesitate to post it.
All the buzzt
CornedBee
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|