Method: WinWindow#each_child
- Defined in:
- lib/winwindow.rb
#each_child ⇒ Object
iterates over each child, yielding a WinWindow object.
raises a WinWindow::NotExistsError if the window does not exist, or a WinWindow::SystemError if a System Error errors.
use #children to get an Enumerable object.
msdn.microsoft.com/en-us/library/ms633494(VS.85).aspx
For System Error Codes see msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 |
# File 'lib/winwindow.rb', line 1056 def each_child raise WinWindow::NotExistsError, "Window does not exist! Cannot enumerate children." unless exists? enum_child_windows_callback= WinUser.window_enum_callback do |chwnd, lparam| yield WinWindow.new(chwnd) WIN_TRUE end begin ret=WinUser.EnumChildWindows(hwnd, enum_child_windows_callback, nil) ensure WinUser.remove_window_enum_callback(enum_child_windows_callback) end if ret==0 self.class.system_error("EnumChildWindows") # actually, EnumChildWindows doesn't say anything about return value indicating error encountered. # Although EnumWindows does, so it seems sort of safe to assume that would apply here too. # but, maybe not - so, should we raise an error here? end nil end |