Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Strylinys

Mouse Cursor??

This topic is 6534 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I change the mouse cursor in my program? I don''t want to use the windows default, I want to use one I made... It could either be used as arrow.cur (original filename) or IDC_POINTER (resource definition), whichever works better. I really have no clue how to do this, so any help would be great. Thanks. S.

Share this post


Link to post
Share on other sites
Advertisement
Are you using Direct Draw? If so give me an e-mail and I will give you some nifty code that uses a bitmap as a cursor and clips is according to the screen size (for a full screen app). I had the same problem you did, so I decided to use Direct Draw (partially since I was already).


Share this post


Link to post
Share on other sites
I am not using DirectDraw currently, but I did plan on learning it in the future... If it''s nothing major that will alter my program with lines and lines and lines of code, then I would appreciate the solution.
S.

Share this post


Link to post
Share on other sites
BTW. There will be built in cursor support in DirectX 8, which uses hardware acceleration (if available) to draw the cursor.

-Jussi

Share this post


Link to post
Share on other sites
If I recall correctly, you must use the function LoadCursor() but instead of supplying it with the default, you must give the ID of your cursor. Ideally, you would have to create a cursor, store it in a resource file and define its ID in the header file.

If you are using MSVC, you could create and add the cursor straight into your project.

Taking before giving is only logical.

Share this post


Link to post
Share on other sites
you can set the cursor while registering your windowclass

eg:

wc.hCursor=LoadCursor(NULL, IDC_ARROW); //default cursor

or

wc.hCursor=LoadCursor(hInstance, MAKEINTRESOURCE(IDC_CURSOR1));
// for a resource cursor

when you are trying to change the cursor dynamically you can specify a cursor handle and use LoadCursor() and SetCursor()

eg:

HCURSOR g_hCursor;
g_hCursor = LoadCursor(hInstance, MAKEINTRESOURCE(IDC_CURSOR1));
SetCursor(g_hCursor);

the problem here is that when you move the cursor, windows will redraw the default windowclass cursor

you could store the cursor handle in a global variable and use SetCursor(g_hCursor) every time you intercept a WM_SETCURSOR message

Share this post


Link to post
Share on other sites
I''ll go with kris vanhoof.

But if you want to change cursor at run-time, you must define cursor=NULL when you register the class. I mean in the WNDCLASS: wc.hCursor = NULL;

Now you have catch the WM_SETCURSOR, and use the SetCursor() function to change it. (like kris said)


But if you''re only using 1 cursor type, you only have to define it when registering your window class.

Share this post


Link to post
Share on other sites
Ack! Hmm... It did help me get the cursor on the screen, however, the cursor flickers. When I set the cursor to a default windows cursor it doesn''t flicker... Anyone know how to fix that one?
S.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!