I want to sub-class the actual window to detect when its size has changed.
This is the code relevant where I’ve tried to subclassing it, using CallWindowProcW and SetWindowLongW, but it does not show any message when I maximize the window, so I’m supposed I’ve set wrongly some of those procedures. How to do it?
var oldWindowProc uintptr
func windowProc(hwnd syscall.Handle, msg uint32, wparam, lparam uintptr) (rc uintptr) {
switch msg {
case WM_SIZE:
fmt.Println("Size")
if wparam == SIZE_MAXIMIZED {
fmt.Println("Changed!")
}
default:
return CallWindowProcW(oldWindowProc, hwnd, msg, wparam, lparam)
}
return 0
}
func main() {
oldWindowProc, _ = SetWindowLongW(syscall.Stdin, GWLP_WNDPROC,
syscall.NewCallback(windowProc))
for {
}
}
I don’t know much about winapi, but it seems your code closely resembles an example of
go-winapiwrapperAnd using that wrapper lib, this modified version seems to work for me:
(Full code)
snip
I am sure you could look at that wrapper lib and derive the more direct way of doing it.