-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhcursor.go
39 lines (33 loc) · 1.05 KB
/
hcursor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package wingo
import (
"github.com/rogeecn/wingo/proc"
"syscall"
"github.com/rogeecn/wingo/co"
"github.com/rogeecn/wingo/errco"
)
// A handle to a cursor.
//
// 📑 https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types#hcursor
type HCURSOR HANDLE
// ⚠️ You must defer HCURSOR.DestroyCursor().
//
// 📑 https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-copycursor
func (hCursor HCURSOR) CopyCursor() HCURSOR {
return (HCURSOR)(((HICON)(hCursor)).CopyIcon())
}
// 📑 https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-destroycursor
func (hCursor HCURSOR) DestroyCursor() {
ret, _, err := syscall.Syscall(proc.DestroyCursor.Addr(), 1,
uintptr(hCursor), 0, 0)
if ret == 0 {
panic(errco.ERROR(err))
}
}
// 📑 https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setsystemcursor
func (hCursor HCURSOR) SetSystemCursor(id co.OCR) {
ret, _, err := syscall.Syscall(proc.SetSystemCursor.Addr(), 2,
uintptr(hCursor), uintptr(id), 0)
if ret == 0 {
panic(errco.ERROR(err))
}
}