-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhtheme.go
151 lines (131 loc) Β· 5.13 KB
/
htheme.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package wingo
import (
"github.com/rogeecn/wingo/proc"
"syscall"
"unsafe"
"github.com/rogeecn/wingo/co"
"github.com/rogeecn/wingo/errco"
)
// Handle to a theme.
//
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/
type HTHEME HANDLE
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-closethemedata
func (hTheme HTHEME) CloseThemeData() {
if hTheme != 0 {
syscall.Syscall(proc.CloseThemeData.Addr(), 1,
uintptr(hTheme), 0, 0)
}
}
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-drawthemebackground
func (hTheme HTHEME) DrawThemeBackground(
hdc HDC, partStateId co.VS, rc *RECT, clipRc *RECT) {
ret, _, _ := syscall.Syscall6(proc.DrawThemeBackground.Addr(), 6,
uintptr(hTheme), uintptr(hdc),
uintptr(partStateId.Part()), uintptr(partStateId.State()),
uintptr(unsafe.Pointer(rc)), uintptr(unsafe.Pointer(clipRc)))
if hr := errco.ERROR(ret); hr != errco.S_OK {
panic(hr)
}
}
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-getthemecolor
func (hTheme HTHEME) GetThemeColor(
partStateId co.VS, propId co.TMT_COLOR) COLORREF {
var color COLORREF
ret, _, _ := syscall.Syscall6(proc.GetThemeColor.Addr(), 5,
uintptr(hTheme), uintptr(partStateId.Part()), uintptr(partStateId.State()),
uintptr(propId), uintptr(unsafe.Pointer(&color)), 0)
if hr := errco.ERROR(ret); hr != errco.S_OK {
panic(hr)
}
return color
}
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-getthemeint
func (hTheme HTHEME) GetThemeInt(partStateId co.VS, propId co.TMT_INT) int32 {
var intVal int32
ret, _, _ := syscall.Syscall6(proc.GetThemeInt.Addr(), 5,
uintptr(hTheme), uintptr(partStateId.Part()), uintptr(partStateId.State()),
uintptr(propId), uintptr(unsafe.Pointer(&intVal)), 0)
if hr := errco.ERROR(ret); hr != errco.S_OK {
panic(hr)
}
return intVal
}
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-getthememetric
func (hTheme HTHEME) GetThemeMetric(
hdc HDC, partStateId co.VS, propId co.TMT_INT) int32 {
var intVal int32
ret, _, _ := syscall.Syscall6(proc.GetThemeMetric.Addr(), 6,
uintptr(hTheme), uintptr(hdc),
uintptr(partStateId.Part()), uintptr(partStateId.State()),
uintptr(propId), uintptr(unsafe.Pointer(&intVal)))
if hr := errco.ERROR(ret); hr != errco.S_OK {
panic(hr)
}
return intVal
}
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-getthemeposition
func (hTheme HTHEME) GetThemePosition(
partStateId co.VS, propId co.TMT_POSITION) POINT {
var pt POINT
ret, _, _ := syscall.Syscall6(proc.GetThemePosition.Addr(), 5,
uintptr(hTheme), uintptr(partStateId.Part()), uintptr(partStateId.State()),
uintptr(propId), uintptr(unsafe.Pointer(&pt)), 0)
if hr := errco.ERROR(ret); hr != errco.S_OK {
panic(hr)
}
return pt
}
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-getthemerect
func (hTheme HTHEME) GetThemeRect(partStateId co.VS, propId co.TMT_RECT) RECT {
var rc RECT
ret, _, _ := syscall.Syscall6(proc.GetThemeRect.Addr(), 5,
uintptr(hTheme), uintptr(partStateId.Part()), uintptr(partStateId.State()),
uintptr(propId), uintptr(unsafe.Pointer(&rc)), 0)
if hr := errco.ERROR(ret); hr != errco.S_OK {
panic(hr)
}
return rc
}
// β οΈ You must defer HBRUSH.DeleteObject().
//
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-getthemesyscolorbrush
func (hTheme HTHEME) GetThemeSysColorBrush(colorId co.TMT_COLOR) HBRUSH {
ret, _, err := syscall.Syscall(proc.GetThemeSysColorBrush.Addr(), 2,
uintptr(hTheme), uintptr(colorId), 0)
if ret == 0 {
panic(errco.ERROR(err)) // uncertain?
}
return HBRUSH(ret)
}
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-getthemesysfont
func (hTheme HTHEME) GetThemeSysFont(fontId co.TMT_FONT, lf *LOGFONT) {
ret, _, _ := syscall.Syscall(proc.GetThemeSysFont.Addr(), 3,
uintptr(hTheme), uintptr(fontId), uintptr(unsafe.Pointer(lf)))
if hr := errco.ERROR(ret); hr != errco.S_OK {
panic(hr)
}
}
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-getthemetextmetrics
func (hTheme HTHEME) GetThemeTextMetrics(
hdc HDC, partStateId co.VS, tm *TEXTMETRIC) {
ret, _, _ := syscall.Syscall6(proc.GetThemeTextMetrics.Addr(), 5,
uintptr(hTheme), uintptr(hdc),
uintptr(partStateId.Part()), uintptr(partStateId.State()),
uintptr(unsafe.Pointer(tm)), 0)
if hr := errco.ERROR(ret); hr != errco.S_OK {
panic(hr)
}
}
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-isthemebackgroundpartiallytransparent
func (hTheme HTHEME) IsThemeBackgroundPartiallyTransparent(partStateId co.VS) bool {
ret, _, _ := syscall.Syscall(proc.IsThemeBackgroundPartiallyTransparent.Addr(), 3,
uintptr(hTheme), uintptr(partStateId.Part()), uintptr(partStateId.State()))
return ret != 0
}
// π https://docs.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-isthemepartdefined
func (hTheme HTHEME) IsThemePartDefined(partStateId co.VS) bool {
ret, _, _ := syscall.Syscall(proc.IsThemePartDefined.Addr(), 3,
uintptr(hTheme), uintptr(partStateId.Part()), uintptr(partStateId.State()))
return ret != 0
}