Skip to content

Commit

Permalink
user32 EnumDisplayMonitors rewrite (go style) (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciuslrangel authored Jan 17, 2021
1 parent 08168e3 commit fa6acf9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions typedef.go
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,8 @@ type HOOKPROC func(int, WPARAM, LPARAM) LRESULT
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms633498(v=vs.85).aspx
type WNDENUMPROC func(HWND, LPARAM) LRESULT

type MONITORENUMPROC func(HMONITOR, HDC, RECT, LPARAM) bool

//https://msdn.microsoft.com/en-us/library/windows/desktop/aa366775(v=vs.85).aspx
type MEMORY_BASIC_INFORMATION struct {
BaseAddress PVOID
Expand Down
12 changes: 9 additions & 3 deletions user32.go
Original file line number Diff line number Diff line change
Expand Up @@ -1077,12 +1077,18 @@ func GetMonitorInfo(hMonitor HMONITOR, lmpi *MONITORINFO) bool {
return ret != 0
}

func EnumDisplayMonitors(hdc HDC, clip *RECT, fnEnum, dwData uintptr) bool {
func EnumDisplayMonitors(hdc HDC, clip *RECT, fnEnum MONITORENUMPROC, dwData LPARAM) bool {
ret, _, _ := procEnumDisplayMonitors.Call(
uintptr(hdc),
uintptr(unsafe.Pointer(clip)),
fnEnum,
dwData,
syscall.NewCallback(func(Arg1 HMONITOR, Arg2 HDC, Arg3 uintptr, Arg4 LPARAM) LRESULT {
if fnEnum(Arg1, Arg2, *(*RECT)(unsafe.Pointer(Arg3)), Arg4) {
return 1
} else {
return 0
}
}),
uintptr(dwData),
)
return ret != 0
}
Expand Down

0 comments on commit fa6acf9

Please sign in to comment.