-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhdwp.go
49 lines (42 loc) · 1.36 KB
/
hdwp.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
package wingo
import (
"github.com/rogeecn/wingo/proc"
"syscall"
"github.com/rogeecn/wingo/co"
"github.com/rogeecn/wingo/errco"
)
// A handle to a deferred window position structure.
//
// 📑 https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types#hdwp
type HDWP HANDLE
// ⚠️ You must defer HDWP.EndDeferWindowPos().
//
// 📑 https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-begindeferwindowpos
func BeginDeferWindowPos(numWindows int32) HDWP {
ret, _, err := syscall.Syscall(proc.BeginDeferWindowPos.Addr(), 1,
uintptr(numWindows), 0, 0)
if ret == 0 {
panic(errco.ERROR(err))
}
return HDWP(ret)
}
// 📑 https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-deferwindowpos
func (hDwp HDWP) DeferWindowPos(
hWnd, hwndInsertAfter HWND, x, y, cx, cy int32, uFlags co.SWP) HDWP {
ret, _, err := syscall.Syscall9(proc.DeferWindowPos.Addr(), 8,
uintptr(hDwp), uintptr(hWnd), uintptr(hwndInsertAfter),
uintptr(x), uintptr(y), uintptr(cx), uintptr(cy), uintptr(uFlags),
0)
if ret == 0 {
panic(errco.ERROR(err))
}
return HDWP(ret)
}
// 📑 https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enddeferwindowpos
func (hDwp HDWP) EndDeferWindowPos() {
ret, _, err := syscall.Syscall(proc.EndDeferWindowPos.Addr(), 1,
uintptr(hDwp), 0, 0)
if ret == 0 {
panic(errco.ERROR(err))
}
}