News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

How to change the desjtop cursor?

Started by xandaz, December 21, 2021, 11:06:33 PM

Previous topic - Next topic

xandaz

    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

daydreamer

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
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

xandaz

    Thanks daydreamer. The code is in WndProc.

xandaz

    Still downt work with the WM_SETCIRSOR message. reutrns 0

Greenhorn

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.
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

Greenhorn

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 ...
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

hutch--

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.

xandaz