The MASM Forum

General => The Campus => Topic started by: xandaz on December 21, 2021, 11:06:33 PM

Title: How to change the desjtop cursor?
Post by: xandaz on December 21, 2021, 11:06:33 PM
    I'm wondering why this code doesn't work: invoke GetDesktopWindow
mov hDesktop,eax
invoke LoadImage,hInstance,addr CursorName,IMAGE_CURSOR,32,32,LR_LOADFROMFILE
invoke SetClassLong,hWnd,GCL_HCURSOR,eax

    Thanks for in advenace for help
Title: Re: How to change the desjtop cursor?
Post by: daydreamer on December 22, 2021, 01:11:26 AM
Quote from: xandaz on December 21, 2021, 11:06:33 PM
    I'm wondering why this code doesn't work: invoke GetDesktopWindow
mov hDesktop,eax
invoke LoadImage,hInstance,addr CursorName,IMAGE_CURSOR,32,32,LR_LOADFROMFILE
invoke SetClassLong,hWnd,GCL_HCURSOR,eax

    Thanks for in advenace for help
Where do you have that code?
If you don't use WM_SETCURSOR message it only works until next mouse move
https://docs.microsoft.com/en-us/windows/win32/learnwin32/setting-the-cursor-image
(https://docs.microsoft.com/en-us/windows/win32/learnwin32/setting-the-cursor-image)
Title: Re: How to change the desjtop cursor?
Post by: xandaz on December 22, 2021, 04:25:18 AM
    Thanks daydreamer. The code is in WndProc.
Title: Re: How to change the desjtop cursor?
Post by: xandaz on December 22, 2021, 04:35:09 AM
    Still downt work with the WM_SETCIRSOR message. reutrns 0
Title: Re: How to change the desjtop cursor?
Post by: Greenhorn on December 22, 2021, 09:34:14 AM
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadimagea (https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadimagea)
If the fuLoad parameter includes the LR_LOADFROMFILE value, lpszName is the name of the file that contains the stand-alone resource (icon, cursor, or bitmap file). Therefore, set hinst to NULL.

However, your code snippet does not explain what you want to achive.
If you want to set the cursor for your own window, just put SetCursor (hCursor) into your WM_MOUSEMOVE.
Title: Re: How to change the desjtop cursor?
Post by: Greenhorn on December 22, 2021, 09:42:06 AM
Additional error ...

invoke   GetDesktopWindow
mov   hDesktop,eax
invoke   LoadImage,hInstance,addr CursorName,IMAGE_CURSOR,32,32,LR_LOADFROMFILE
invoke   SetClassLong,hWnd,GCL_HCURSOR,eax


To change the cursor of foreign windows is not very polite ...
Title: Re: How to change the desjtop cursor?
Post by: hutch-- on December 22, 2021, 03:31:24 PM
You will find that as the desktop is a different running process running in its own memory space, it is not a viable task to change the characteristics of another binary file.
Title: Re: How to change the desjtop cursor?
Post by: xandaz on December 23, 2021, 03:44:42 AM
    ok guys. learmed much. thanks