Mouse Cursor??
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.
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).
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. ![](smile.gif)
S.
![](smile.gif)
S.
i know bugger all about the win32 api but maybe
LoadCursor(NULL, IDC_POINTER );
LoadCursor(NULL, IDC_POINTER );
BTW. There will be built in cursor support in DirectX 8, which uses hardware acceleration (if available) to draw the cursor.
-Jussi
-Jussi
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.
If you are using MSVC, you could create and add the cursor straight into your project.
Taking before giving is only logical.
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
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
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.
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.
![](http://www.baskuenen.myweb.nl/images/title.jpg)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement