Using package lxn/win in main:
win.EnumChildWindows(hw, printme, 0)
Then after main:
func printme(HWND win.HANDLE, LPARAM uintptr) { //HWND hwnd, LPARAM lParam
spew.Dump(HWND)
}
I get:
.\test.go:40: cannot use printme (type func(win.HANDLE, uintptr)) as type uintptr in argument to win.EnumChildWindows
error:exit status 2
I don't understand the error message.
答案 0 :(得分:0)
我让它可以使用:
win.EnumChildWindows(hwnd, syscall.NewCallback(printme), 0)
func printme(hwnd uintptr, lParam uintptr) uintptr {
spew.Dump(hwnd)
fmt.Printf("getWindowText: '%s'\n", getWindowText(hwnd))
return 1 // true to continue
}
请参见lxn/win
issue 19:
回调签名是错误的:如果函数应继续枚举,则它必须返回类型为
int32
(C BOOL
)的非零值。
See MSDN。例如,可能是:
func printme(hwnd uintptr, lParam uintptr) int32 { spew.Dump(hwnd) return 1 // true to continue }