Class: Win32::WindowManager
- Inherits:
-
Object
- Object
- Win32::WindowManager
- Defined in:
- lib/Win32/WindowManager.rb
Defined Under Namespace
Classes: Window
Constant Summary collapse
- TRUE =
1
Instance Method Summary collapse
- #get_all_windows(get_not_visible_windows = false, test = false) ⇒ Object
- #get_top_window(windows) ⇒ Object
- #hide_window(window_handle) ⇒ Object
- #iconic?(window_handle) ⇒ Boolean
-
#initialize ⇒ WindowManager
constructor
A new instance of WindowManager.
- #process_window_handles(window_handles, test) ⇒ Object
- #show_window(window_handle, is_iconic) ⇒ Object
Constructor Details
#initialize ⇒ WindowManager
Returns a new instance of WindowManager.
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/Win32/WindowManager.rb', line 77 def initialize @buff = " " * 16 @windows = {} @enum_windows_proc = DL.callback('ILL') do |hwnd,lparam| @window_handles.push(hwnd) TRUE end end |
Instance Method Details
#get_all_windows(get_not_visible_windows = false, test = false) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/Win32/WindowManager.rb', line 117 def get_all_windows(get_not_visible_windows=false,test=false) #if !@enum_windows_proc then #end @buff = " " * 16 @windows = {} @window_handles = [] @test = test @get_not_visible_windows = get_not_visible_windows r,rs = EnumWindows.call(@enum_windows_proc, 0) process_window_handles(@window_handles, test) #if !test return @windows end |
#get_top_window(windows) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/Win32/WindowManager.rb', line 133 def get_top_window(windows) get_all_windows.each_key do |hwnd| top_window = hwnd sub_windows = [] #puts "#{top_window}: " while true hwnd, rs = GetWindow.call(hwnd, GW_HWNDPREV) break if hwnd == NULL #puts " #{hwnd}" sub_windows.push(hwnd) if windows.has_key?(hwnd) end #puts "#{top_window}: " + sub_windows.join(",") return top_window if sub_windows == [] end return 0 end |
#hide_window(window_handle) ⇒ Object
150 151 152 153 154 155 156 157 158 |
# File 'lib/Win32/WindowManager.rb', line 150 def hide_window(window_handle) $TRACE.debug 5, "@hwnd_task_list = #{@hwnd_task_list}" $TRACE.debug 5, "@shell_hook_message = #{@shell_hook_message}" $TRACE.debug 5, "window_handle = #{window_handle}" SendMessage.call(@hwnd_task_list, @shell_hook_message, 2, window_handle) # ShowWindow.call(window_handle, SW_SHOWMINNOACTIVE) ShowWindow.call(window_handle, SW_HIDE) end |
#iconic?(window_handle) ⇒ Boolean
170 171 172 173 |
# File 'lib/Win32/WindowManager.rb', line 170 def iconic?(window_handle) r, rs = IsIconic.call(window_handle) r == TRUE end |
#process_window_handles(window_handles, test) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/Win32/WindowManager.rb', line 89 def process_window_handles(window_handles, test) window_handles.each do |hwnd| #style, rs = GetWindowLong.call(hwnd, GWL_STYLE) #ex_style, rs = GetWindowLong.call(hwnd, GWL_EXSTYLE) #owner, rs = GetWindow.call(hwnd, GW_OWNER) style = GetWindowLong_2.call(hwnd, GWL_STYLE) ex_style = GetWindowLong_2.call(hwnd, GWL_EXSTYLE) owner = GetWindow_2.call(hwnd, GW_OWNER) # if the window is visible AND # its NOT a tool window with no parent #r,rs = GetClassName.call(hwnd, @buff, @buff.size) #class_name = rs[1] GetClassName_2.call(hwnd, @buff, @buff.size) class_name = @buff.dup if !(((ex_style & WS_EX_TOOLWINDOW) != 0) && (owner == NULL)) then if ((style & WS_VISIBLE) != 0) || @get_not_visible_windows then # ignore Kapsules main window next if (/WindowsForms10/.match(class_name)) @windows[hwnd] = Window.create(hwnd, style, ex_style, class_name, owner, self) $TRACE.debug 7, sprintf("%d, rs[1] = '%s', style = %8.8x, ex_style = %8.8x, owner = %d\n", hwnd, class_name, style, ex_style, owner) end end end end |
#show_window(window_handle, is_iconic) ⇒ Object
160 161 162 163 164 165 166 167 168 |
# File 'lib/Win32/WindowManager.rb', line 160 def show_window(window_handle, is_iconic) SendMessage.call(@hwnd_task_list, @shell_hook_message, 1, window_handle) if is_iconic then ShowWindow.call(window_handle, SW_SHOWMINNOACTIVE) else ShowWindow.call(window_handle, SW_SHOWNOACTIVATE) end # ShowWindow.call(window_handle, SW_SHOW) end |