Author Topic: How to change the desjtop cursor?  (Read 1293 times)

xandaz

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
How to change the desjtop cursor?
« on: December 21, 2021, 11:06:33 PM »
    I'm wondering why this code doesn't work:
Code: [Select]
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

  • Member
  • *****
  • Posts: 2399
  • my kind of REAL10 Blonde
Re: How to change the desjtop cursor?
« Reply #1 on: December 22, 2021, 01:11:26 AM »
    I'm wondering why this code doesn't work:
Code: [Select]
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
http://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

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
Re: How to change the desjtop cursor?
« Reply #2 on: December 22, 2021, 04:25:18 AM »
    Thanks daydreamer. The code is in WndProc.

xandaz

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
Re: How to change the desjtop cursor?
« Reply #3 on: December 22, 2021, 04:35:09 AM »
    Still downt work with the WM_SETCIRSOR message. reutrns 0

Greenhorn

  • Member
  • ***
  • Posts: 493
Re: How to change the desjtop cursor?
« Reply #4 on: December 22, 2021, 09:34:14 AM »
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

  • Member
  • ***
  • Posts: 493
Re: How to change the desjtop cursor?
« Reply #5 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 ...
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: How to change the desjtop cursor?
« Reply #6 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

xandaz

  • Member
  • ****
  • Posts: 529
  • I luv you babe
    • My asm examples
Re: How to change the desjtop cursor?
« Reply #7 on: December 23, 2021, 03:44:42 AM »
    ok guys. learmed much. thanks