go-tg-screenshot-bot
390 строк · 9.7 Кб
1// Copyright 2016 The win Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build windows
6
7package win8
9import (10"syscall"11"unsafe"12
13"golang.org/x/sys/windows"14)
15
16// Button control messages
17const (18BCM_FIRST = 0x160019BCM_GETIDEALSIZE = BCM_FIRST + 0x000120BCM_SETIMAGELIST = BCM_FIRST + 0x000221BCM_GETIMAGELIST = BCM_FIRST + 0x000322BCM_SETTEXTMARGIN = BCM_FIRST + 0x000423BCM_GETTEXTMARGIN = BCM_FIRST + 0x000524BCM_SETDROPDOWNSTATE = BCM_FIRST + 0x000625BCM_SETSPLITINFO = BCM_FIRST + 0x000726BCM_GETSPLITINFO = BCM_FIRST + 0x000827BCM_SETNOTE = BCM_FIRST + 0x000928BCM_GETNOTE = BCM_FIRST + 0x000A29BCM_GETNOTELENGTH = BCM_FIRST + 0x000B30BCM_SETSHIELD = BCM_FIRST + 0x000C31)
32
33const (34CCM_FIRST = 0x200035CCM_LAST = CCM_FIRST + 0x20036CCM_SETBKCOLOR = 819337CCM_SETCOLORSCHEME = 819438CCM_GETCOLORSCHEME = 819539CCM_GETDROPTARGET = 819640CCM_SETUNICODEFORMAT = 819741CCM_GETUNICODEFORMAT = 819842CCM_SETVERSION = 0x200743CCM_GETVERSION = 0x200844CCM_SETNOTIFYWINDOW = 0x200945CCM_SETWINDOWTHEME = 0x200b46CCM_DPISCALE = 0x200c47)
48
49// Common controls styles
50const (51CCS_TOP = 152CCS_NOMOVEY = 253CCS_BOTTOM = 354CCS_NORESIZE = 455CCS_NOPARENTALIGN = 856CCS_ADJUSTABLE = 3257CCS_NODIVIDER = 6458CCS_VERT = 12859CCS_LEFT = 12960CCS_NOMOVEX = 13061CCS_RIGHT = 13162)
63
64// InitCommonControlsEx flags
65const (66ICC_LISTVIEW_CLASSES = 167ICC_TREEVIEW_CLASSES = 268ICC_BAR_CLASSES = 469ICC_TAB_CLASSES = 870ICC_UPDOWN_CLASS = 1671ICC_PROGRESS_CLASS = 3272ICC_HOTKEY_CLASS = 6473ICC_ANIMATE_CLASS = 12874ICC_WIN95_CLASSES = 25575ICC_DATE_CLASSES = 25676ICC_USEREX_CLASSES = 51277ICC_COOL_CLASSES = 102478ICC_INTERNET_CLASSES = 204879ICC_PAGESCROLLER_CLASS = 409680ICC_NATIVEFNTCTL_CLASS = 819281INFOTIPSIZE = 102482ICC_STANDARD_CLASSES = 0x0000400083ICC_LINK_CLASS = 0x0000800084)
85
86// WM_NOTITY messages
87const (88NM_FIRST = 089NM_OUTOFMEMORY = ^uint32(0) // NM_FIRST - 190NM_CLICK = ^uint32(1) // NM_FIRST - 291NM_DBLCLK = ^uint32(2) // NM_FIRST - 392NM_RETURN = ^uint32(3) // NM_FIRST - 493NM_RCLICK = ^uint32(4) // NM_FIRST - 594NM_RDBLCLK = ^uint32(5) // NM_FIRST - 695NM_SETFOCUS = ^uint32(6) // NM_FIRST - 796NM_KILLFOCUS = ^uint32(7) // NM_FIRST - 897NM_CUSTOMDRAW = ^uint32(11) // NM_FIRST - 1298NM_HOVER = ^uint32(12) // NM_FIRST - 1399NM_NCHITTEST = ^uint32(13) // NM_FIRST - 14100NM_KEYDOWN = ^uint32(14) // NM_FIRST - 15101NM_RELEASEDCAPTURE = ^uint32(15) // NM_FIRST - 16102NM_SETCURSOR = ^uint32(16) // NM_FIRST - 17103NM_CHAR = ^uint32(17) // NM_FIRST - 18104NM_TOOLTIPSCREATED = ^uint32(18) // NM_FIRST - 19105NM_LAST = ^uint32(98) // NM_FIRST - 99106TRBN_THUMBPOSCHANGING = 0xfffffa22 // TRBN_FIRST - 1107)
108
109// ProgressBar messages
110const (111PBM_SETPOS = WM_USER + 2112PBM_DELTAPOS = WM_USER + 3113PBM_SETSTEP = WM_USER + 4114PBM_STEPIT = WM_USER + 5115PBM_SETMARQUEE = WM_USER + 10116PBM_SETRANGE32 = 1030117PBM_GETRANGE = 1031118PBM_GETPOS = 1032119PBM_SETBARCOLOR = 1033120PBM_SETBKCOLOR = CCM_SETBKCOLOR121)
122
123// ProgressBar styles
124const (125PBS_SMOOTH = 0x01126PBS_VERTICAL = 0x04127PBS_MARQUEE = 0x08128)
129
130// TrackBar (Slider) messages
131const (132TBM_GETPOS = WM_USER133TBM_GETRANGEMIN = WM_USER + 1134TBM_GETRANGEMAX = WM_USER + 2135TBM_SETPOS = WM_USER + 5136TBM_SETRANGEMIN = WM_USER + 7137TBM_SETRANGEMAX = WM_USER + 8138TBM_SETPAGESIZE = WM_USER + 21139TBM_GETPAGESIZE = WM_USER + 22140TBM_SETLINESIZE = WM_USER + 23141TBM_GETLINESIZE = WM_USER + 24142)
143
144// TrackBar (Slider) styles
145const (146TBS_VERT = 0x002147TBS_TOOLTIPS = 0x100148)
149
150// ImageList creation flags
151const (152ILC_MASK = 0x00000001153ILC_COLOR = 0x00000000154ILC_COLORDDB = 0x000000FE155ILC_COLOR4 = 0x00000004156ILC_COLOR8 = 0x00000008157ILC_COLOR16 = 0x00000010158ILC_COLOR24 = 0x00000018159ILC_COLOR32 = 0x00000020160ILC_PALETTE = 0x00000800161ILC_MIRROR = 0x00002000162ILC_PERITEMMIRROR = 0x00008000163)
164
165// ImageList_Draw[Ex] flags
166const (167ILD_NORMAL = 0x00000000168ILD_TRANSPARENT = 0x00000001169ILD_BLEND25 = 0x00000002170ILD_BLEND50 = 0x00000004171ILD_MASK = 0x00000010172ILD_IMAGE = 0x00000020173ILD_SELECTED = ILD_BLEND50174ILD_FOCUS = ILD_BLEND25175ILD_BLEND = ILD_BLEND50176)
177
178// LoadIconMetric flags
179const (180LIM_SMALL = 0181LIM_LARGE = 1182)
183
184const (185CDDS_PREPAINT = 0x00000001186CDDS_POSTPAINT = 0x00000002187CDDS_PREERASE = 0x00000003188CDDS_POSTERASE = 0x00000004189CDDS_ITEM = 0x00010000190CDDS_ITEMPREPAINT = CDDS_ITEM | CDDS_PREPAINT191CDDS_ITEMPOSTPAINT = CDDS_ITEM | CDDS_POSTPAINT192CDDS_ITEMPREERASE = CDDS_ITEM | CDDS_PREERASE193CDDS_ITEMPOSTERASE = CDDS_ITEM | CDDS_POSTERASE194CDDS_SUBITEM = 0x00020000195)
196
197const (198CDIS_SELECTED = 0x0001199CDIS_GRAYED = 0x0002200CDIS_DISABLED = 0x0004201CDIS_CHECKED = 0x0008202CDIS_FOCUS = 0x0010203CDIS_DEFAULT = 0x0020204CDIS_HOT = 0x0040205CDIS_MARKED = 0x0080206CDIS_INDETERMINATE = 0x0100207CDIS_SHOWKEYBOARDCUES = 0x0200208CDIS_NEARHOT = 0x0400209CDIS_OTHERSIDEHOT = 0x0800210CDIS_DROPHILITED = 0x1000211)
212
213const (214CDRF_DODEFAULT = 0x00000000215CDRF_NEWFONT = 0x00000002216CDRF_SKIPDEFAULT = 0x00000004217CDRF_DOERASE = 0x00000008218CDRF_NOTIFYPOSTPAINT = 0x00000010219CDRF_NOTIFYITEMDRAW = 0x00000020220CDRF_NOTIFYSUBITEMDRAW = 0x00000020221CDRF_NOTIFYPOSTERASE = 0x00000040222CDRF_SKIPPOSTPAINT = 0x00000100223)
224
225const (226LVIR_BOUNDS = 0227LVIR_ICON = 1228LVIR_LABEL = 2229LVIR_SELECTBOUNDS = 3230)
231
232const (233LPSTR_TEXTCALLBACK = ^uintptr(0)234I_CHILDRENCALLBACK = -1235I_IMAGECALLBACK = -1236I_IMAGENONE = -2237)
238
239type HIMAGELIST HANDLE240
241type INITCOMMONCONTROLSEX struct {242DwSize, DwICC uint32243}
244
245type NMCUSTOMDRAW struct {246Hdr NMHDR
247DwDrawStage uint32248Hdc HDC
249Rc RECT
250DwItemSpec uintptr251UItemState uint32252LItemlParam uintptr253}
254
255var (256// Library257libcomctl32 *windows.LazyDLL258
259// Functions260imageList_Add *windows.LazyProc261imageList_AddMasked *windows.LazyProc262imageList_Create *windows.LazyProc263imageList_Destroy *windows.LazyProc264imageList_DrawEx *windows.LazyProc265imageList_ReplaceIcon *windows.LazyProc266initCommonControlsEx *windows.LazyProc267loadIconMetric *windows.LazyProc268loadIconWithScaleDown *windows.LazyProc269)
270
271func init() {272// Library273libcomctl32 = windows.NewLazySystemDLL("comctl32.dll")274
275// Functions276imageList_Add = libcomctl32.NewProc("ImageList_Add")277imageList_AddMasked = libcomctl32.NewProc("ImageList_AddMasked")278imageList_Create = libcomctl32.NewProc("ImageList_Create")279imageList_Destroy = libcomctl32.NewProc("ImageList_Destroy")280imageList_DrawEx = libcomctl32.NewProc("ImageList_DrawEx")281imageList_ReplaceIcon = libcomctl32.NewProc("ImageList_ReplaceIcon")282initCommonControlsEx = libcomctl32.NewProc("InitCommonControlsEx")283loadIconMetric = libcomctl32.NewProc("LoadIconMetric")284loadIconWithScaleDown = libcomctl32.NewProc("LoadIconWithScaleDown")285}
286
287func ImageList_Add(himl HIMAGELIST, hbmImage, hbmMask HBITMAP) int32 {288ret, _, _ := syscall.Syscall(imageList_Add.Addr(), 3,289uintptr(himl),290uintptr(hbmImage),291uintptr(hbmMask))292
293return int32(ret)294}
295
296func ImageList_AddMasked(himl HIMAGELIST, hbmImage HBITMAP, crMask COLORREF) int32 {297ret, _, _ := syscall.Syscall(imageList_AddMasked.Addr(), 3,298uintptr(himl),299uintptr(hbmImage),300uintptr(crMask))301
302return int32(ret)303}
304
305func ImageList_Create(cx, cy int32, flags uint32, cInitial, cGrow int32) HIMAGELIST {306ret, _, _ := syscall.Syscall6(imageList_Create.Addr(), 5,307uintptr(cx),308uintptr(cy),309uintptr(flags),310uintptr(cInitial),311uintptr(cGrow),3120)313
314return HIMAGELIST(ret)315}
316
317func ImageList_Destroy(hIml HIMAGELIST) bool {318ret, _, _ := syscall.Syscall(imageList_Destroy.Addr(), 1,319uintptr(hIml),3200,3210)322
323return ret != 0324}
325
326func ImageList_DrawEx(himl HIMAGELIST, i int32, hdcDst HDC, x, y, dx, dy int32, rgbBk COLORREF, rgbFg COLORREF, fStyle uint32) bool {327ret, _, _ := syscall.Syscall12(imageList_DrawEx.Addr(), 10,328uintptr(himl),329uintptr(i),330uintptr(hdcDst),331uintptr(x),332uintptr(y),333uintptr(dx),334uintptr(dy),335uintptr(rgbBk),336uintptr(rgbFg),337uintptr(fStyle),3380,3390)340
341return ret != 0342}
343
344func ImageList_ReplaceIcon(himl HIMAGELIST, i int32, hicon HICON) int32 {345ret, _, _ := syscall.Syscall(imageList_ReplaceIcon.Addr(), 3,346uintptr(himl),347uintptr(i),348uintptr(hicon))349
350return int32(ret)351}
352
353func InitCommonControlsEx(lpInitCtrls *INITCOMMONCONTROLSEX) bool {354ret, _, _ := syscall.Syscall(initCommonControlsEx.Addr(), 1,355uintptr(unsafe.Pointer(lpInitCtrls)),3560,3570)358
359return ret != 0360}
361
362func LoadIconMetric(hInstance HINSTANCE, lpIconName *uint16, lims int32, hicon *HICON) HRESULT {363if loadIconMetric.Find() != nil {364return HRESULT(0)365}366ret, _, _ := syscall.Syscall6(loadIconMetric.Addr(), 4,367uintptr(hInstance),368uintptr(unsafe.Pointer(lpIconName)),369uintptr(lims),370uintptr(unsafe.Pointer(hicon)),3710,3720)373
374return HRESULT(ret)375}
376
377func LoadIconWithScaleDown(hInstance HINSTANCE, lpIconName *uint16, w int32, h int32, hicon *HICON) HRESULT {378if loadIconWithScaleDown.Find() != nil {379return HRESULT(0)380}381ret, _, _ := syscall.Syscall6(loadIconWithScaleDown.Addr(), 5,382uintptr(hInstance),383uintptr(unsafe.Pointer(lpIconName)),384uintptr(w),385uintptr(h),386uintptr(unsafe.Pointer(hicon)),3870)388
389return HRESULT(ret)390}
391