News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

How to get cursor hotspot using masm

Started by vishwadt, March 15, 2014, 05:33:56 PM

Previous topic - Next topic

vishwadt

I search the internet but i can't find answer. please help me

TouEnMasm

"msdn cursor" in a motor search.
give GetCursorPos ....
http://msdn.microsoft.com/en-us/library/0b1674x8.aspx

A search for "cursor" in this forum is also a good way.
Fa is a musical note to play with CL

vishwadt

thank you for your help.
but i need to get hotspot of cursor icon. not a cursor location

hutch--

You may need the file format for a cursor to get that info. A cursor editor can load that info when you edit a cursor so it must be contained in the file.


dedndave

not tested
CharacterizeCursor PROTO :HINSTANCE,:LPCTSTR


CharacterizeCursor PROC hInst:HINSTANCE,lpCursorName:LPCTSTR

;Load Cursor and return handle and hotspot.
;May only be used for cursors that are standard size for the system (normally 32x32).

;Call With:    hInstance = module handle (NULL for system cursors)
;           lpCursorName = pointer to cursor name, or a system cursor constant
;           To load a cursor from resource: hInst = module handle of current process
;                                           lpCursorName = resource ordinal
;
;  Returns: EAX = cursor handle (0 if error)
;           ECX = hotspot X (-1 if error)
;           EDX = hotspot Y (-1 if error)
;
;Also Uses: All other registers are preserved

;---------------------------------------------------------

;standard system cursor constants
;
;IDC_APPSTARTING  Standard arrow and small hourglass
;IDC_ARROW        Standard arrow
;IDC_CROSS        Crosshair
;IDC_HAND         Hand
;IDC_HELP         Arrow and question mark
;IDC_IBEAM        I-beam
;IDC_ICON         Obsolete for applications marked version 4.0 or later.
;IDC_NO           Slashed circle
;IDC_SIZE         Obsolete for applications marked version 4.0 or later. Use IDC_SIZEALL.
;IDC_SIZEALL      Four-pointed arrow pointing north, south, east, and west
;IDC_SIZENESW     Double-pointed arrow pointing northeast and southwest
;IDC_SIZENS       Double-pointed arrow pointing north and south
;IDC_SIZENWSE     Double-pointed arrow pointing northwest and southeast
;IDC_SIZEWE       Double-pointed arrow pointing west and east
;IDC_UPARROW      Vertical arrow
;IDC_WAIT         Hourglass

;ICONINFO  STRUCT
;  fIcon    dd      ?
;  xHotspot dd      ?
;  yHotspot dd      ?
;  hbmMask  HBITMAP ?
;  hbmColor HBITMAP ?

;---------------------------------------------------------

    LOCAL   _iis    :ICONINFO

;---------------------------------------------------------

    INVOKE  LoadCursor,hInst,lpCursorName
    .if eax
        push    eax
        INVOKE  GetIconInfo,eax,addr _iis
        .if eax
            mov     eax,_iis.hbmMask
            .if eax
                INVOKE  DeleteObject,eax
            .endif
            mov     eax,_iis.hbmColor
            .if eax
                INVOKE  DeleteObject,eax
            .endif
            mov     ecx,_iis.xHotspot
            mov     edx,_iis.yHotspot
        .else
            or      ecx,-1
            mov     edx,ecx
        .endif
        pop     eax
    .else
        or      ecx,-1
        mov     edx,ecx
    .endif
    ret

CharacterizeCursor ENDP

vishwadt

Thank you very much @dedndave your code very helpful. I correct my codes. :t
and @hutch Thank you for correct the path