Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Load Cursor from Resource in Win 95

Posted on 1998-12-08
16
Medium Priority
?
363 Views
Last Modified: 2013-12-03
I am trying to load a cursor from a resource - it works in nt but not in 95. here is what I am doing

HCURSOR hCursor,hOldCursor

hCursor = ::LoadCursor(hInst,MAKEINTRESOURCE(IDC_HAND));
hOldCursor = SetCursor(hCursor);

I have also tried
hCursor = ::LoadCursor(hinst,(LPCTSTR)IDC_HAND);
hOldCursor = SetCursor(hCursor);

also tried -
hCursor = (HCURSOR)LoadImage(hInst,MAKEINTRESOURCE(IDC_HAND),IMAGE_CURSOR,0,0,NULL);
hOldCursor = SetCursor(hCursor);
0
Comment
Question by:gpaige
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 2
  • +2
16 Comments
 

Author Comment

by:gpaige
ID: 1416932
Sorry I want to add - when the LoadCursor command returns it returns NULL which causes the SetCursor(NULL) statement to execute - so the cursor disappears.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1416933
First of all IDC_HAND is only available on NT.  2nd of all if you se these constants, the HINSTANCE parameter should be NULL.


Let me know if you have questons.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1416934
Actually, to be more precise, the IDC_HAND is available only on NT 5 and later.
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:gpaige
ID: 1416935
Sorry - I mislead you.  I defined a resource called IDC_HAND - I didnt intend to use a system defined one.

0
 
LVL 22

Expert Comment

by:nietod
ID: 1416936
Better rename that ID.  You will regret using it in the future!
0
 
LVL 3

Expert Comment

by:Sendoh
ID: 1416937
Hi !
Did you check that you can edit the Cursor usign msvc++4.0 cursor editor ??
I suspect your cursor corrupted.
If not, did you tried create new workspace of project and add the c,resource, cursor into it and recompile again ??

BTW, I tried custom cursor on Win95 platform. It works fine.
Probably you can let me know your e-mail add so that I can mail you the example that I'd created.
Hope that it'll solve your problem.
0
 
LVL 27

Expert Comment

by:BigRat
ID: 1416938
Are we 100% certain that the hInst parameter to the call is correct? And what is the numerical value of IDC_HAND?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1416939
Since it is working under NT, it probably isn't a simple problem like that (or even a corrupted cursor.)
0
 

Author Comment

by:gpaige
ID: 1416940
I know the cursor is not corrupt and I've checked the hInst variable - thats not the problem.... I can load a cursor from a file and it will work on both machines... It seems like win95 cannot or doesn't get the correct resource id ?? I have looked at the executable to make sure the cursor is a resource in the exe..
0
 
LVL 22

Expert Comment

by:nietod
ID: 1416941
Did you check to se what GetLastError() was returning?
0
 

Author Comment

by:gpaige
ID: 1416942
The last error says that the command succeeded...
What I did was call get GetLastError() if hCursor == NULL..
0
 

Author Comment

by:gpaige
ID: 1416943
The last error says that the command succeeded...
What I did was call get GetLastError() if hCursor == NULL..
0
 
LVL 27

Expert Comment

by:BigRat
ID: 1416944
Nietod's first answer is probably the correct one. If you have the include files the wrong way round you're going to get the wrong constant. That is why I asked what the value of the constant was. Secondly have you tried changing the name like Nietod suggested? If you change the name to say IDC_NIETOD or IDC_RAT in both the defining and referenced places AND ensure that the value of the constant is NOT the same value as that of the system constant, we might get somewhere.
0
 

Author Comment

by:gpaige
ID: 1416945
OK I've about had it...
I've changed the resource name to IDC_CURSOR1 I now load it into HCURSOR hMyCursor but no matter what I do hMyCursor is NULL on a Windows 95 machine.  I didn't think changing cursors was so hard.  I also checked the constant value it is 135...
Ive tried calling it by number also with
hMyCursor = LoadCursor(hInst,MAKEINTRESOURCE(135));

0
 
LVL 22

Expert Comment

by:nietod
ID: 1416946
Try using LoadResource just to see if the cursor resource is being found.

If so, the problem must be that windows can't load it as a cursor for some reason.  If no, the problem is that the resource is somehow being left out of the project or is being included wrong.
0
 

Accepted Solution

by:
Srinibhatla earned 180 total points
ID: 1416947
From the Help:

Windows 95: The width and height of the cursor must be the values returned by the GetSystemMetrics function for SM_CXCURSOR and SM_CYCURSOR. In addition, the cursor bit depth must match the bit depth of the display or the cursor must be monochrome.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question