Teen Programmers Unite  
 

 

Return to forum top

Directx and C - Dynamic Cursors

Posted by trill [send private reply] at July 02, 2002, 12:42:17 AM

Does anyone have an idea about how to dynamically change the cursor in a win32 and directx windowed application? I want the cursor to change to a hand when moved over certain areas of the game. I tried
"wincl.hCursor = LoadCursor(hThisInstance,MAKEINTRESOURCE(IDC_CURSOR_HAND)); " and updated the window, but it did not work.

Note: I know I can use bitmaps for this, but it's not that smooth in a windowed app. (Atleast the way I do it.)

Thanks.

Posted by metamorphic [send private reply] at July 02, 2002, 06:40:49 AM

off topic: I thought it was always best to use c++ with direct X?

Posted by trill [send private reply] at July 02, 2002, 06:52:16 AM

I would say it's a matter of personal choice. For larger projects though,it is definitely wiser to use C++ . I'm working on a small game currently, so there is no real need for the overhead of classes.

Posted by CodeRed [send private reply] at July 02, 2002, 11:19:34 AM

I have used different cursors, but never changed them dynamically in the program

Posted by CViper [send private reply] at July 02, 2002, 12:47:34 PM

Use SetCursor( hCursor );

Posted by trill [send private reply] at July 02, 2002, 04:18:54 PM

CViper:

Thanks alot. It worked like a charm.

For anyone else interseted, here's the code:
HCURSOR hHand;

In winmain, load your normal cursor.
Then, hHand = LoadCursor(hThisInstance,MAKEINTRESOURCE(IDC_CURSOR_HAND));

In my mousemove routine,I just called SetCursor(hHand);
It will automatically switch back to your default cursor after you leave the mousemove routine.

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.