diff options
author | Alexander Neumann <alexander.neumann@picos-software.com> | 2018-12-05 16:36:34 +0100 |
---|---|---|
committer | Alexander Neumann <alexander.neumann@picos-software.com> | 2018-12-05 16:36:34 +0100 |
commit | c1af619bceabb3611026b5fdb62d75379b757cbf (patch) | |
tree | 7d55f8865b6c36db80c3b07e8aa8ef3b9433174c | |
parent | Don't activate a window when it is made visible (diff) | |
download | wireguard-windows-c1af619bceabb3611026b5fdb62d75379b757cbf.tar.xz wireguard-windows-c1af619bceabb3611026b5fdb62d75379b757cbf.zip |
WindowBase: Add ForEachDescendant
-rw-r--r-- | window.go | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -915,6 +915,28 @@ func setWindowText(hwnd win.HWND, text string) error { return nil } +func forEachDescendant(hwnd win.HWND, lParam uintptr) uintptr { + if window := windowFromHandle(hwnd); window != nil && forEachDescendantCallback(window.(Widget)) { + return 1 + } + + return 0 +} + +var ( + forEachDescendantCallbackPtr = syscall.NewCallback(forEachDescendant) + forEachDescendantCallback func(widget Widget) bool +) + +func (wb *WindowBase) ForEachDescendant(f func(widget Widget) bool) { + forEachDescendantCallback = f + defer func() { + forEachDescendantCallback = nil + }() + + win.EnumChildWindows(wb.hWnd, forEachDescendantCallbackPtr, 0) +} + // Visible returns if the *WindowBase is visible. func (wb *WindowBase) Visible() bool { return win.IsWindowVisible(wb.hWnd) |