PDA

View Full Version : Cursor won't hide!



09-10-2003, 08:43 AM
Hello!

My problem is funny and rather simple. It goes like this... When I am debugging my application the mouse pointer hides when I start my program. After building a realase version and running it the cursor IS visible. Have you ever noticed something like that? I used mainly NeHe Tutorials to create a window. I tried ShowCursor(false). Any hints?

Thanx

1234!
09-10-2003, 09:07 AM
I assume you are talking about Win32.

When you lookup the spec for ShowCursor() you will find this:

ShowCursor:

The ShowCursor function displays or hides the cursor.

int ShowCursor(BOOL bShow// cursor visibility);

Parameters:

bShow
[in] Specifies whether the internal display counter is to be incremented or decremented. If bShow is TRUE, the display count is incremented by one. If bShow is FALSE, the display count is decremented by one.

Return Values:

The return value specifies the new display counter.

Remarks:

This function sets an internal display counter that determines whether the cursor should be displayed. The cursor is displayed only if the display count is greater than or equal to 0. If a mouse is installed, the initial display count is 0. If no mouse is installed, the display count is –1.


So check the result from the call, I bed it's greater then zero.

Leyder Dylan
09-10-2003, 01:19 PM
That's it ... lol

09-11-2003, 04:45 AM
Well thanx but I know how to use it. I noticed that the cursor is visible if I am moving the mouse while program is setting up. If I try to run it by keyboard the cursor isn't visible. Funny thing, isn't it? http://www.opengl.org/discussion_boards/ubb/smile.gif

1234!
09-11-2003, 06:49 PM
The question isnt how to use it, but to understand how it works.

And frankly, you dont seem to understand how it works.

09-12-2003, 01:39 AM
Ok but how would you explain that the cursor isn't visible when I run the program from a compiler but it IS when I am executing the exe file form my OS (Win98)? http://www.opengl.org/discussion_boards/ubb/smile.gif

zeckensack
09-12-2003, 03:39 AM
This code solved all my cursor problems:



int the_win32api_sucks=ShowCursor(false);
while (the_win32api_sucks>=0) the_win32api_sucks=ShowCursor(false);

1234!
09-12-2003, 01:25 PM
The reason why you see different results is explained in the manual for the function.

Either do what Zeckensack said, or you could use SetCursor(NULL) to set the cursor to a blank cursor while it is in your client area (read the manual for that function as it has some drawbacks too).

Anyway this is a OpenGL forum after all.

09-13-2003, 02:28 AM
Thanks guys! http://www.opengl.org/discussion_boards/ubb/smile.gif

PS. I suppose you can be a bit more polite 1234!

Jan
09-13-2003, 07:47 AM
SetClassLong(hWnd, GCL_HCURSOR, (LONG) LoadCursor (NULL, IDC_ARROW));
SetCursor (LoadCursor (NULL, IDC_ARROW));

This forces, that you get the desired cursor. Do this once, and you donīt have to bother anymore.
This code will give you the standard cursor, but if you use a NULL somewhere instead, than your cursor should get hidden, if i remember it right.

Jan.

1234!
09-13-2003, 12:18 PM
Originally posted by [---]:
PS. I suppose you can be a bit more polite 1234!

Yeah I suppose I could but that would break my granddad's heart... http://www.opengl.org/discussion_boards/ubb/wink.gif

If you want to use SetCursor(NULL) make sure the windows class cursor is also set to NULL, otherwise Windows will restore the cursor to the one registered in the window class as soon as you move the mouse.

In case you use the MFC use this:




SetClassLong(GetSafeHwnd(), GCL_HCURSOR, NULL);
SetCursor(NULL);


If you dont use MFC you have to replace the GetSafeHwnd() call with your HWND handle.

The drawback using this approach is, that as soon as the mouse leaves your window the old cursor gets restored by the system and will also become visible in your window again.

I would use Zeckensack's approach if I where you.

Now was that polite enough?

09-14-2003, 01:41 AM
Yeah. That was very nice. Thank you. http://www.opengl.org/discussion_boards/ubb/smile.gif

09-15-2003, 04:14 AM
Ehh... http://www.opengl.org/discussion_boards/ubb/smile.gif I've tried what you suggested but it seems that problem isn't about the mouse really. Pointer is still visible - but if I click a mouse button it disappears. Sorry for my stupid questions. I think it is something rather simple to solve and I really appreciate your help. http://www.opengl.org/discussion_boards/ubb/smile.gif

Thanks