-
Notifications
You must be signed in to change notification settings - Fork 1
/
win.go
73 lines (63 loc) · 1.49 KB
/
win.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
package main
import (
"syscall"
"github.com/lxn/win"
)
var (
setLayeredWindowAttributes,
showScrollBar uintptr
)
const (
// Layered Window Attributes
LWA_COLORKEY = 1
LWA_ALPHA = 2
// Owner Draw Type (win.DRAWITEMSTRUCT.CtlType)
ODT_MENU = 0x1
ODT_LISTBOX = 0x2
ODT_COMBOBOX = 0x3
ODT_BUTTON = 0x4
ODT_STATIC = 0x5
// Owner Draw Action (win.DRAWITEMSTRUCT.ItemAction)
ODA_DRAWENTIRE = 0x1
ODA_SELECT = 0x2
ODA_FOCUS = 0x4
// Owner Draw State (win.DRAWITEMSTRUCT.ItemState)
ODS_SELECTED = 0x0001
ODS_GRAYED = 0x0002
ODS_DISABLED = 0x0004
ODS_CHECKED = 0x0008
ODS_FOCUS = 0x0010
ODS_DEFAULT = 0x0020
ODS_COMBOBOXEDIT = 0x1000
ODS_HOTLIGHT = 0x0040
ODS_INACTIVE = 0x0080
ODS_NOACCEL = 0x0100
ODS_NOFOCUSRECT = 0x0200
)
func init() {
libuser32, err := syscall.LoadLibrary("user32.dll")
if err != nil {
panic(err)
}
setLayeredWindowAttributes, err = syscall.GetProcAddress(libuser32, "SetLayeredWindowAttributes")
if err != nil {
panic(err)
}
showScrollBar, err = syscall.GetProcAddress(libuser32, "ShowScrollBar")
}
func ShowScrollBar(hwnd win.HWND, wBar int, bShow int) {
syscall.Syscall(showScrollBar, 3,
uintptr(hwnd),
uintptr(wBar),
uintptr(bShow),
)
}
func SetLayeredWindowAttributes(hwnd win.HWND, crKey, bAlpha, dwFlags int32) bool {
ret, _, _ := syscall.Syscall6(setLayeredWindowAttributes, 4,
uintptr(hwnd),
uintptr(crKey),
uintptr(bAlpha),
uintptr(dwFlags),
0, 0)
return ret != 0
}