Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changed Cursor not displaying

Status
Not open for further replies.

richsb

Technical User
Aug 2, 2001
34
NO
Hi,

I have a Dialog app that has WM_ONMOUSEMOVE message map function created from which I catch a certain area of the window. When the cursor is over this area I wish to change to default arrow cursor with one of my own.

The problem that I have is that the code below compiles and runs, but when over my chosen area the cursor dissapears. Within the WM_ONMOUSEMOVE function I have the following code :-

Code:
LPCTSTR myCursor = "IDC_CURSOR1" [COLOR=green]// my cursor created in the editor and listed in the resource.h file[/color]

HINSTANCE hInstance;
hInstance = AfxGetInstanceHandle(); [COLOR=green]// catch a handle to the window[/color]

HCURSOR hCursor;
hCursor = (HCURSOR) LoadImage
           (hInstance,
            myCursor,
            IMAGE_CURSOR,
            32,
            32,
            NULL
            );

::SetCursor(hCursor);

I have tried all permatations using this function and the now redundant LoadCursor(), CopyCursor(), ShowCursor()plus other functions.

Any help appreciated.

If it is not broke, don't fix it!!!
 
1) Does hCursor return a valid value?

2) Try SM_CXCURSOR and SM_CYCURSOR instead of 32, 32

3) Last parameter, try LR_DEFAULTCOLOR

4) If all else fails, does this work
Code:
HCURSOR hhand = LoadCursor (NULL, IDC_HAND);
::SetCursor (hhand);
 
It turns out that the hCursor is unused with the following messege in debug:-

hCursor : 0x00000000
unused
CXX0030 : Error : expression cannot be evaluated

I guess there is more handling of the resource handle to be done, such as using FindResource();

Any suggestions?

If it is not broke, don't fix it!!!
 
Got it sorted,

It was as simple as using the cursor ID number rather than the cursor name as follows, more importantly using the hash sign as well (#).

Code:
LPCTSTR myCursor = "#151"

If it is not broke, don't fix it!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top