; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "BSD 2-clause" license."          |
;|_______________________________________________________________________________________|
;
;  Description: Provides unified access to standard mouse cursors.
;
;  Target OS: Win32
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

; ToDo: Arbitrary mouse cursors, B&W for the begining.


proc SetMouseCursor, .hWindow, .hCursor
begin
        push    ecx edx
        invoke  SetCursor, [.hCursor]
        pop     edx ecx
        return
endp



proc GetStockCursor, .index
begin
        push    ecx edx
        mov     eax, [.index]
        cmp     eax, mcCount
        jb      @f
        xor     eax, eax
@@:
        movzx   eax, [_cursors+2*eax]
        invoke  LoadCursorW, 0, eax
        pop     edx ecx
        return
endp

if used _cursors
  _cursors dw IDC_ARROW, IDC_IBEAM, IDC_CROSS, IDC_SIZEWE, IDC_SIZENS, IDC_SIZENWSE, IDC_SIZENESW, IDC_WAIT, IDC_HAND, IDC_HAND, IDC_ARROW
end if



proc __MouseCapture, .hwnd
begin
        push    eax ecx edx
        cmp     [.hwnd], 0
        je      .release

        invoke  SetCapture, [.hwnd]

.finish:
        pop     edx ecx eax
        return

.release:
        invoke  ReleaseCapture
        jmp     .finish
endp