diff --git a/dwmapi.go b/dwmapi.go new file mode 100644 index 0000000..c4314cf --- /dev/null +++ b/dwmapi.go @@ -0,0 +1,116 @@ +// Copyright (c) Tailscale Inc & AUTHORS +// SPDX-License-Identifier: BSD-3-Clause + +//go:build windows +// +build windows + +package win + +import "golang.org/x/sys/windows" + +type DWMWINDOWATTRIBUTE uint32 + +const ( + DWMWA_NCRENDERING_ENABLED DWMWINDOWATTRIBUTE = 1 + DWMWA_NCRENDERING_POLICY DWMWINDOWATTRIBUTE = 2 + DWMWA_TRANSITIONS_FORCEDISABLED DWMWINDOWATTRIBUTE = 3 + DWMWA_ALLOW_NCPAINT DWMWINDOWATTRIBUTE = 4 + DWMWA_CAPTION_BUTTON_BOUNDS DWMWINDOWATTRIBUTE = 5 + DWMWA_NONCLIENT_RTL_LAYOUT DWMWINDOWATTRIBUTE = 6 + DWMWA_FORCE_ICONIC_REPRESENTATION DWMWINDOWATTRIBUTE = 7 + DWMWA_FLIP3D_POLICY DWMWINDOWATTRIBUTE = 8 + DWMWA_EXTENDED_FRAME_BOUNDS DWMWINDOWATTRIBUTE = 9 + DWMWA_HAS_ICONIC_BITMAP DWMWINDOWATTRIBUTE = 10 + DWMWA_DISALLOW_PEEK DWMWINDOWATTRIBUTE = 11 + DWMWA_EXCLUDED_FROM_PEEK DWMWINDOWATTRIBUTE = 12 + DWMWA_CLOAK DWMWINDOWATTRIBUTE = 13 + DWMWA_CLOAKED DWMWINDOWATTRIBUTE = 14 + DWMWA_FREEZE_REPRESENTATION DWMWINDOWATTRIBUTE = 15 + DWMWA_PASSIVE_UPDATE_MODE DWMWINDOWATTRIBUTE = 16 + DWMWA_USE_HOSTBACKDROPBRUSH DWMWINDOWATTRIBUTE = 17 + DWMWA_USE_IMMERSIVE_DARK_MODE DWMWINDOWATTRIBUTE = 20 + DWMWA_WINDOW_CORNER_PREFERENCE DWMWINDOWATTRIBUTE = 33 + DWMWA_BORDER_COLOR DWMWINDOWATTRIBUTE = 34 + DWMWA_CAPTION_COLOR DWMWINDOWATTRIBUTE = 35 + DWMWA_TEXT_COLOR DWMWINDOWATTRIBUTE = 36 + DWMWA_VISIBLE_FRAME_BORDER_THICKNESS DWMWINDOWATTRIBUTE = 37 + DWMWA_SYSTEMBACKDROP_TYPE DWMWINDOWATTRIBUTE = 38 +) + +const ( + DWM_CLOAKED_APP uint32 = 0x00000001 + DWM_CLOAKED_SHELL uint32 = 0x00000002 + DWM_CLOAKED_INHERITED uint32 = 0x00000004 +) + +const ( + DWMWA_COLOR_NONE uint32 = 0xFFFFFFFE + DWMWA_COLOR_DEFAULT uint32 = 0xFFFFFFFF +) + +type DWMNCRENDERINGPOLICY int32 + +const ( + DWMNCRP_USEWINDOWSTYLE DWMNCRENDERINGPOLICY = 0 + DWMNCRP_DISABLED DWMNCRENDERINGPOLICY = 1 + DWMNCRP_ENABLED DWMNCRENDERINGPOLICY = 2 +) + +type DWMFLIP3DWINDOWPOLICY int32 + +const ( + DWMFLIP3D_DEFAULT DWMFLIP3DWINDOWPOLICY = 0 + DWMFLIP3D_EXCLUDEBELOW DWMFLIP3DWINDOWPOLICY = 1 + DWMFLIP3D_EXCLUDEABOVE DWMFLIP3DWINDOWPOLICY = 2 +) + +type DWM_WINDOW_CORNER_PREFERENCE int32 + +const ( + DWMWCP_DEFAULT DWM_WINDOW_CORNER_PREFERENCE = 0 + DWMWCP_DONOTROUND DWM_WINDOW_CORNER_PREFERENCE = 1 + DWMWCP_ROUND DWM_WINDOW_CORNER_PREFERENCE = 2 + DWMWCP_ROUNDSMALL DWM_WINDOW_CORNER_PREFERENCE = 3 +) + +type DWM_SYSTEMBACKDROP_TYPE int32 + +const ( + DWMSBT_AUTO DWM_SYSTEMBACKDROP_TYPE = 0 + DWMSBT_NONE DWM_SYSTEMBACKDROP_TYPE = 1 + DWMSBT_MAINWINDOW DWM_SYSTEMBACKDROP_TYPE = 2 + DWMSBT_TRANSIENTWINDOW DWM_SYSTEMBACKDROP_TYPE = 3 + DWMSBT_TABBEDWINDOW DWM_SYSTEMBACKDROP_TYPE = 4 +) + +type HTHUMBNAIL windows.Handle + +const ( + DWM_TNP_RECTDESTINATION = 0x00000001 + DWM_TNP_RECTSOURCE = 0x00000002 + DWM_TNP_OPACITY = 0x00000004 + DWM_TNP_VISIBLE = 0x00000008 + DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010 +) + +type DWM_THUMBNAIL_PROPERTIES struct { + Flags uint32 + RcDestination RECT + RcSource RECT + Opacity byte + FVisible BOOL + FSourceClientAreaOnly BOOL +} + +const DWM_SIT_DISPLAYFRAME = 0x00000001 + +//sys DwmExtendFrameIntoClientArea(hwnd HWND, inset *MARGINS) (ret HRESULT) = dwmapi.DwmExtendFrameIntoClientArea +//sys DwmGetWindowAttribute(hwnd HWND, attribute DWMWINDOWATTRIBUTE, attrVal unsafe.Pointer, attrValLen uint32) (ret HRESULT) = dwmapi.DwmGetWindowAttribute +//sys DwmInvalidateIconicBitmaps(hwnd HWND) (ret HRESULT) = dwmapi.DwmInvalidateIconicBitmaps +//sys DwmQueryThumbnailSourceSize(thumbnail HTHUMBNAIL, size *SIZE) (ret HRESULT) = dwmapi.DwmQueryThumbnailSourceSize +//sys DwmRegisterThumbnail(hwndDest HWND, hwndSrc HWND, handle *HTHUMBNAIL) (ret HRESULT) = dwmapi.DwmRegisterThumbnail +//sys DwmSetIconicLivePreviewBitmap(hwnd HWND, hbmp HBITMAP, clientRegionOffset *POINT, flags uint32) (ret HRESULT) = dwmapi.DwmSetIconicLivePreviewBitmap +//sys DwmSetIconicThumbnail(hwnd HWND, hbmp HBITMAP, flags uint32) (ret HRESULT) = dwmapi.DwmSetIconicThumbnail +//sys DwmSetWindowAttribute(hwnd HWND, attribute DWMWINDOWATTRIBUTE, attrVal unsafe.Pointer, attrValLen uint32) (ret HRESULT) = dwmapi.DwmSetWindowAttribute +//sys DwmUpdateThumbnailProperties(thumbnail HTHUMBNAIL, props *DWM_THUMBNAIL_PROPERTIES) (ret HRESULT) = dwmapi.DwmUpdateThumbnailProperties +//sys DwmUnregisterThumbnail(thumbnail HTHUMBNAIL) (ret HRESULT) = dwmapi.DwmUnregisterThumbnail diff --git a/mksyscall.go b/mksyscall.go index 6095049..6ca7b46 100644 --- a/mksyscall.go +++ b/mksyscall.go @@ -4,5 +4,5 @@ package win -//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go comctl32.go gdiplus.go kernel32.go user32.go uxtheme.go +//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go comctl32.go dwmapi.go gdiplus.go kernel32.go user32.go uxtheme.go //go:generate go run golang.org/x/tools/cmd/goimports -w zsyscall_windows.go diff --git a/zsyscall_windows.go b/zsyscall_windows.go index 303e30e..2c75f25 100644 --- a/zsyscall_windows.go +++ b/zsyscall_windows.go @@ -40,12 +40,23 @@ func errnoErr(e syscall.Errno) error { var ( modcomctl32 = windows.NewLazySystemDLL("comctl32.dll") + moddwmapi = windows.NewLazySystemDLL("dwmapi.dll") modgdiplus = windows.NewLazySystemDLL("gdiplus.dll") modkernel32 = windows.NewLazySystemDLL("kernel32.dll") moduser32 = windows.NewLazySystemDLL("user32.dll") moduxtheme = windows.NewLazySystemDLL("uxtheme.dll") procTaskDialogIndirect = modcomctl32.NewProc("TaskDialogIndirect") + procDwmExtendFrameIntoClientArea = moddwmapi.NewProc("DwmExtendFrameIntoClientArea") + procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute") + procDwmInvalidateIconicBitmaps = moddwmapi.NewProc("DwmInvalidateIconicBitmaps") + procDwmQueryThumbnailSourceSize = moddwmapi.NewProc("DwmQueryThumbnailSourceSize") + procDwmRegisterThumbnail = moddwmapi.NewProc("DwmRegisterThumbnail") + procDwmSetIconicLivePreviewBitmap = moddwmapi.NewProc("DwmSetIconicLivePreviewBitmap") + procDwmSetIconicThumbnail = moddwmapi.NewProc("DwmSetIconicThumbnail") + procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute") + procDwmUnregisterThumbnail = moddwmapi.NewProc("DwmUnregisterThumbnail") + procDwmUpdateThumbnailProperties = moddwmapi.NewProc("DwmUpdateThumbnailProperties") procGdipAddPathEllipseI = modgdiplus.NewProc("GdipAddPathEllipseI") procGdipCreateBitmapFromFile = modgdiplus.NewProc("GdipCreateBitmapFromFile") procGdipCreateBitmapFromGraphics = modgdiplus.NewProc("GdipCreateBitmapFromGraphics") @@ -125,6 +136,66 @@ func TaskDialogIndirect(pTaskConfig *TASKDIALOGCONFIG, pnButton *int32, pnRadioB return } +func DwmExtendFrameIntoClientArea(hwnd HWND, inset *MARGINS) (ret HRESULT) { + r0, _, _ := syscall.Syscall(procDwmExtendFrameIntoClientArea.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(inset)), 0) + ret = HRESULT(r0) + return +} + +func DwmGetWindowAttribute(hwnd HWND, attribute DWMWINDOWATTRIBUTE, attrVal unsafe.Pointer, attrValLen uint32) (ret HRESULT) { + r0, _, _ := syscall.Syscall6(procDwmGetWindowAttribute.Addr(), 4, uintptr(hwnd), uintptr(attribute), uintptr(attrVal), uintptr(attrValLen), 0, 0) + ret = HRESULT(r0) + return +} + +func DwmInvalidateIconicBitmaps(hwnd HWND) (ret HRESULT) { + r0, _, _ := syscall.Syscall(procDwmInvalidateIconicBitmaps.Addr(), 1, uintptr(hwnd), 0, 0) + ret = HRESULT(r0) + return +} + +func DwmQueryThumbnailSourceSize(thumbnail HTHUMBNAIL, size *SIZE) (ret HRESULT) { + r0, _, _ := syscall.Syscall(procDwmQueryThumbnailSourceSize.Addr(), 2, uintptr(thumbnail), uintptr(unsafe.Pointer(size)), 0) + ret = HRESULT(r0) + return +} + +func DwmRegisterThumbnail(hwndDest HWND, hwndSrc HWND, handle *HTHUMBNAIL) (ret HRESULT) { + r0, _, _ := syscall.Syscall(procDwmRegisterThumbnail.Addr(), 3, uintptr(hwndDest), uintptr(hwndSrc), uintptr(unsafe.Pointer(handle))) + ret = HRESULT(r0) + return +} + +func DwmSetIconicLivePreviewBitmap(hwnd HWND, hbmp HBITMAP, clientRegionOffset *POINT, flags uint32) (ret HRESULT) { + r0, _, _ := syscall.Syscall6(procDwmSetIconicLivePreviewBitmap.Addr(), 4, uintptr(hwnd), uintptr(hbmp), uintptr(unsafe.Pointer(clientRegionOffset)), uintptr(flags), 0, 0) + ret = HRESULT(r0) + return +} + +func DwmSetIconicThumbnail(hwnd HWND, hbmp HBITMAP, flags uint32) (ret HRESULT) { + r0, _, _ := syscall.Syscall(procDwmSetIconicThumbnail.Addr(), 3, uintptr(hwnd), uintptr(hbmp), uintptr(flags)) + ret = HRESULT(r0) + return +} + +func DwmSetWindowAttribute(hwnd HWND, attribute DWMWINDOWATTRIBUTE, attrVal unsafe.Pointer, attrValLen uint32) (ret HRESULT) { + r0, _, _ := syscall.Syscall6(procDwmSetWindowAttribute.Addr(), 4, uintptr(hwnd), uintptr(attribute), uintptr(attrVal), uintptr(attrValLen), 0, 0) + ret = HRESULT(r0) + return +} + +func DwmUnregisterThumbnail(thumbnail HTHUMBNAIL) (ret HRESULT) { + r0, _, _ := syscall.Syscall(procDwmUnregisterThumbnail.Addr(), 1, uintptr(thumbnail), 0, 0) + ret = HRESULT(r0) + return +} + +func DwmUpdateThumbnailProperties(thumbnail HTHUMBNAIL, props *DWM_THUMBNAIL_PROPERTIES) (ret HRESULT) { + r0, _, _ := syscall.Syscall(procDwmUpdateThumbnailProperties.Addr(), 2, uintptr(thumbnail), uintptr(unsafe.Pointer(props)), 0) + ret = HRESULT(r0) + return +} + func GdipAddPathEllipseI(path *GpPath, x int32, y int32, width int32, height int32) (ret GpStatus) { r0, _, _ := syscall.Syscall6(procGdipAddPathEllipseI.Addr(), 5, uintptr(unsafe.Pointer(path)), uintptr(x), uintptr(y), uintptr(width), uintptr(height), 0) ret = GpStatus(r0)