Error C2664 when trying to change from built-in IDC_WAIT to custom cursor

I am trying to change the cursor when the user must wait from the built-in IDC_WAIT to a custom cursor file.

I added redcross.cur as a resource called IDC_REDCROSS to my VC 6.0 project,
and changed
    hOldCursor = SetCursor (LoadCursor ((HINSTANCE)NULL, IDC_WAIT));
to
    hOldCursor = SetCursor (LoadCursor ((HINSTANCE)NULL, IDC_REDCROSS));

However when I try to build, I get an error on that last line of code that reads:
error C2664: 'LoadCursorA' : cannot convert parameter 2 from 'const int' to 'const char *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

Please advise me on how to remedy this. Thank you!
davidbermancomAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AlexFMConnect With a Mentor Commented:
hOldCursor = SetCursor (LoadCursor ((HINSTANCE)NULL, MAKEINTRESOURCE(IDC_REDCROSS)));
0
 
davidbermancomAuthor Commented:
Thank you. However I have tried that, and I either get no cursor or the same cursor I had before. I've yet to see my IDC_REDCROSS appear.
0
 
jkrCommented:
>>However I have tried that, and I either get no cursor or the same cursor I had before

You'll need to check the return value of 'LoadCursor()':

HCURSOR  hCursor = LoadCursor ((HINSTANCE)NULL, MAKEINTRESOURCE(IDC_REDCROSS));

if ( NULL == hCursor) {

    DWORD dwError = GetLastError();
    // report error
}

hOldCursor = SetCursor(hCursor);
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
davidbermancomAuthor Commented:
Thank you. I replaced my line of code with the six lines of code above. I am still getting no cursor or the normal pointer cursor. Am I correct that your intention was that I could now retrieve some diagnostic information that would help solve the problem, and if so, how should I do that?
0
 
jkrCommented:
Well, you could use

if ( NULL == hCursor) {

    DWORD dwError = GetLastError();
    char buf[255];
    wsprintf(buf,"Error loading cursor, reason: %d",dwError);
    MessageBox(NULL,buf,"Error",MB_OK);
}
0
 
davidbermancomAuthor Commented:
Thank you. I ran that. I got this message:

"Error loading cursor: reason 1813"
0
 
jkrCommented:
Well, that is

//
// MessageId: ERROR_RESOURCE_TYPE_NOT_FOUND
//
// MessageText:
//
//  The specified resource type cannot be found in the image file.
//
#define ERROR_RESOURCE_TYPE_NOT_FOUND    1813L

Are you sure your cursor resource is correctly linked with your executable? To check this, open the file with Visual Studio (use 'open as Resource' in the file dialog) and see if you can find it there.
0
 
davidbermancomAuthor Commented:
In Visual Studio,
when I choose File | Open | Open As = Resources | cursor1.cur | Open button,
I get a dialog that says "cursor1.cur Is not a known file type".
0
 
jkrCommented:
You should open xour executable and check it there...
0
 
davidbermancomAuthor Commented:
I'm not clear what you are suggesting I do. Could you please give me step by step instructions? I've never encountered an issue like this one before. thank you.
0
 
jkrConnect With a Mentor Commented:
No problem. Use the same way you wanted to open your cursor file, but open the executable "as resource". Then, VS will give you the ability to browse through the resources that are contained in it, and you'll probably find that this very cursor is missing.
0
 
davidbermancomAuthor Commented:
Ah, gotcha.
Okay, so I did that and in the cursor list,
my cursor is indeed there, but it is listed as ID "216" rather than "cursor1".

I am puzzled, so I look at other resources to see what their IDs are.
I look at my bitmaps of which I have around 20:15 of them have the names I gave them, but 5 have numbers instead.
Same anomaly with one of my Icons, one of my Menus, and two of my Dialogs (however all those things are working fine).

Have you seen this kind of thing before?
0
 
davidbermancomAuthor Commented:
There are actuall two numbered cursors on my list of cursors and none others.
There are two because I inserted the desired one twice: once as redcross.cur and once as cursor1.cur .
They are showing as 216 and 217. I don't have any other cursors.
0
 
jkrCommented:
What is the numeric value of 'IDC_REDCROSS'? You can check that on your "resource.h".
0
 
reggieperrinConnect With a Mentor Commented:
IDC_REDCROSS is 216
IDC_CURSOR1 is 217
0
 
bastibartelCommented:
Try AfxGetApp()->LoadCurser(IDC_REDCROSS');

Cheers,
Sebastian
0
 
bastibartelCommented:
Hi there,

Browsing the answers I was wondering. Why not split
AlexFM {http:#16724170} & jkr {http:#16739202}

the third answer was
IDC_REDCROSS is 216
IDC_CURSOR1 is 217

Just a newby question
Sebastian
0
 
bastibartelCommented:
Hi there,

I'd appreciate an answer to my question - or, alternativley object to the split.
Sebastian

 
0
All Courses

From novice to tech pro — start learning today.