WndProc is the window procedure of the window. When implementing your own WndProc to add or modify behavior, call the WndProc of the embedded window for messages you don't handle yourself.
(hwnd win.HWND, msg uint32, wParam, lParam uintptr)
| 2325 | // When implementing your own WndProc to add or modify behavior, call the |
| 2326 | // WndProc of the embedded window for messages you don't handle yourself. |
| 2327 | func (wb *WindowBase) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) uintptr { |
| 2328 | window := windowFromHandle(hwnd) |
| 2329 | |
| 2330 | switch msg { |
| 2331 | case win.WM_ERASEBKGND: |
| 2332 | if _, ok := window.(Widget); !ok { |
| 2333 | return 0 |
| 2334 | } |
| 2335 | |
| 2336 | bg, wnd := wb.backgroundEffective() |
| 2337 | if bg == nil { |
| 2338 | break |
| 2339 | } |
| 2340 | |
| 2341 | hdc := win.HDC(wParam) |
| 2342 | |
| 2343 | canvas, err := newCanvasFromHDC(hdc) |
| 2344 | if err != nil { |
| 2345 | break |
| 2346 | } |
| 2347 | defer canvas.Dispose() |
| 2348 | |
| 2349 | wb.prepareDCForBackground(hdc, hwnd, wnd) |
| 2350 | |
| 2351 | if err := canvas.FillRectanglePixels(bg, wb.ClientBoundsPixels()); err != nil { |
| 2352 | break |
| 2353 | } |
| 2354 | |
| 2355 | return 1 |
| 2356 | |
| 2357 | case win.WM_HSCROLL, win.WM_VSCROLL: |
| 2358 | if window := windowFromHandle(win.HWND(lParam)); window != nil { |
| 2359 | // The window that sent the notification shall handle it itself. |
| 2360 | return window.WndProc(hwnd, msg, wParam, lParam) |
| 2361 | } |
| 2362 | |
| 2363 | case win.WM_LBUTTONDOWN, win.WM_MBUTTONDOWN, win.WM_RBUTTONDOWN: |
| 2364 | if msg == win.WM_LBUTTONDOWN && wb.origWndProcPtr == 0 { |
| 2365 | // Only call SetCapture if this is no subclassed control. |
| 2366 | // (Otherwise e.g. WM_COMMAND(BN_CLICKED) would no longer |
| 2367 | // be generated for PushButton.) |
| 2368 | win.SetCapture(wb.hWnd) |
| 2369 | } |
| 2370 | wb.publishMouseEvent(&wb.mouseDownPublisher, msg, wParam, lParam) |
| 2371 | |
| 2372 | case win.WM_LBUTTONUP, win.WM_MBUTTONUP, win.WM_RBUTTONUP: |
| 2373 | if msg == win.WM_LBUTTONUP && wb.origWndProcPtr == 0 { |
| 2374 | // See WM_LBUTTONDOWN for why we require origWndProcPtr == 0 here. |
| 2375 | if !win.ReleaseCapture() { |
| 2376 | lastError("ReleaseCapture") |
| 2377 | } |
| 2378 | } |
| 2379 | wb.publishMouseEvent(&wb.mouseUpPublisher, msg, wParam, lParam) |
| 2380 | |
| 2381 | case win.WM_MOUSEMOVE: |
| 2382 | wb.publishMouseEvent(&wb.mouseMovePublisher, msg, wParam, lParam) |
| 2383 | |
| 2384 | case win.WM_MOUSEWHEEL: |
nothing calls this directly
no test coverage detected