Module: AMS::Window
- Defined in:
- window.rb
Class Method Summary (collapse)
-
+ (Array<Fixnum>) adjust_rect(rect, style, style_ex, b_menu)
Adjust window rect.
-
+ (Boolean) bring_window_to_top(handle)
Bring window to the top of the Z order.
-
+ (Object) close(handle)
Close window.
-
+ (Boolean) draw_menu_bar(handle)
Update menu bar of the specified window.
-
+ (Boolean) enable_input(handle, b_state)
Enable/Disable keyboard and mouse input to the specified window.
-
+ (Fixnum) get_active
Get active window.
-
+ (String) get_class_name(handle)
Get window class name.
-
+ (Array<Fixnum>) get_client_rect(handle)
Get upper-left and lower-right coordinates of the window's client area in client coordinates, relative to the upper-left corner of the window's client area.
-
+ (Fixnum) get_long(handle, index)
Get window long.
-
+ (Fixnum) get_menu(handle)
Get window menu.
-
+ (Array<Fixnum>) get_origin(handle)
Get window origin.
-
+ (Fixnum) get_parent(handle)
Get window's parent window.
-
+ (Array) get_placement(handle)
Get window placement.
-
+ (Fixnum) get_process_id(handle)
Get window process ID.
-
+ (Array<Fixnum>) get_rect(handle)
Get upper-left and lower-right coordinates of the window in screen coordinates, relative to the upper-left corner of the screen.
-
+ (Array<Fixnum>) get_size(handle)
Get window size.
-
+ (String) get_text(handle)
Get window caption.
-
+ (Fixnum) get_thread_id(handle)
Get window thread ID.
-
+ (Boolean) is_active?(handle)
Determine whether handle is a reference to an active window; the window with which the user is currently working.
-
+ (Boolean) is_child?(parent_handle, handle)
Determine whether handle is a reference to a child window.
-
+ (Boolean) is_input_enabled?(handle)
Determine whether keyboard and mouse input is enabled to the specified window.
-
+ (Boolean) is_maximized?(handle)
Determine whether handle is a reference to a maximized window.
-
+ (Boolean) is_minimized?(handle)
Determine whether handle is a reference to a minimized window.
-
+ (Boolean) is_resizeable?(handle)
Determine whether window is resizeable.
-
+ (Boolean) is_restored?(handle)
Determine whether handle is a reference to a restored window; a window that is not maximized or minimized.
-
+ (Boolean) is_valid?(handle)
Determine whether handle is a reference to a valid window.
-
+ (Boolean) is_visible?(handle)
Determine whether handle is a reference to a visible window.
-
+ (Boolean) lock_update(handle)
Lock window update.
-
+ (Boolean) move(handle, x, y, width, height, b_repaint = true)
Move window.
-
+ (Object) refresh(handle)
Refresh window.
-
+ (nil) send_message(handle, message, wParam, lParam)
Send Message to the specified window.
-
+ (Fixnum) set_active(handle)
Set active window.
-
+ (Boolean) set_icon(handle, path)
Modify window icon.
-
+ (Boolean) set_layered_attributes(handle, color, opacity, flags)
Set layered window attributes.
-
+ (Fixnum) set_long(handle, index, long)
Set window long.
-
+ (Boolean) set_menu(handle, menu_handle)
Set window menu.
-
+ (Boolean) set_origin(handle, x, y, b_activate = true)
Set window origin.
-
+ (Fixnum) set_parent(handle, parent_handle)
Set window's parent window.
-
+ (Boolean) set_placement(handle, flags, show_cmd, min_pt, max_pt, rect)
Set Window Placement.
-
+ (Boolean) set_pos(handle, handle_insert_after, x, y, cx, cy, flags)
Set window position.
-
+ (Boolean) set_rect(handle, x1, y1, x2, y2, b_activate = true)
Set upper-left and lower-right coordinates of the window.
-
+ (Boolean) set_resizeable(handle, b_state, b_activate = true)
Set window resizeable.
-
+ (Boolean) set_size(handle, w, h, b_activate = true)
Set window size.
-
+ (Boolean) set_text(handle, caption)
Set window caption.
-
+ (Fixnum) show(handle, state)
Set window show state.
-
+ (void) validate(handle)
Verify that handle is a reference to a valid window.
Class Method Details
+ (Array<Fixnum>) adjust_rect(rect, style, style_ex, b_menu)
Adjust window rect.
289 290 291 292 293 294 295 |
# File 'window.rb', line 289 def adjust_rect(rect, style, style_ex, ) AMS.validate_type(rect, Enumerable) AMS.validate_type(style, Numeric) AMS.validate_type(style_ex, Numeric) AMS.validate_type(, TrueClass, FalseClass) AMS::C.adjust_window_rect(rect, style.to_i, style_ex.to_i, ) end |
+ (Boolean) bring_window_to_top(handle)
Bring window to the top of the Z order. If the window is a top-level window, it is activated. If the window is a child window, the top-level parent window associated with the child window is activated.
149 150 151 152 |
# File 'window.rb', line 149 def bring_window_to_top(handle) validate(handle) AMS::C.bring_window_to_top(handle) end |
+ (Object) close(handle)
Close window. This behaves the same as clicking the 'X' button.
408 409 410 411 |
# File 'window.rb', line 408 def close(handle) validate(handle) AMS::C.close_window(handle) end |
+ (Boolean) draw_menu_bar(handle)
Update menu bar of the specified window.
542 543 544 545 |
# File 'window.rb', line 542 def (handle) validate(handle) AMS::C.(handle) end |
+ (Boolean) enable_input(handle, b_state)
Enable/Disable keyboard and mouse input to the specified window.
497 498 499 500 |
# File 'window.rb', line 497 def enable_input(handle, b_state) validate(handle) AMS::C.enable_window(handle, b_state) end |
+ (Fixnum) get_active
Get active window.
102 103 104 |
# File 'window.rb', line 102 def get_active AMS::C.get_active_window() end |
+ (String) get_class_name(handle)
Get window class name.
159 160 161 162 |
# File 'window.rb', line 159 def get_class_name(handle) validate(handle) AMS::C.get_window_class_name(handle).unpack('C*').pack('U*') end |
+ (Array<Fixnum>) get_client_rect(handle)
Get upper-left and lower-right coordinates of the window's client area in client coordinates, relative to the upper-left corner of the window's client area. Because coordinates are relative to the upper-left corner of the client area, the coordinates of the upper-left corner are (0,0).
276 277 278 279 |
# File 'window.rb', line 276 def get_client_rect(handle) validate(handle) AMS::C.get_client_rect(handle) end |
+ (Fixnum) get_long(handle, index)
Get window long.
190 191 192 193 |
# File 'window.rb', line 190 def get_long(handle, index) validate(handle) AMS::C.get_window_long(handle, index) end |
+ (Fixnum) get_menu(handle)
Get window menu.
215 216 217 218 |
# File 'window.rb', line 215 def (handle) validate(handle) AMS::C.(handle) end |
+ (Array<Fixnum>) get_origin(handle)
Get window origin.
417 418 419 |
# File 'window.rb', line 417 def get_origin(handle) get_rect(handle)[0,2] end |
+ (Fixnum) get_parent(handle)
Get window's parent window.
124 125 126 127 |
# File 'window.rb', line 124 def get_parent(handle) validate(handle) AMS::C.get_parent_window(handle) end |
+ (Array) get_placement(handle)
Get window placement.
303 304 305 306 |
# File 'window.rb', line 303 def get_placement(handle) validate(handle) AMS::C.get_window_placement(handle) end |
+ (Fixnum) get_process_id(handle)
Get window process ID.
179 180 181 182 |
# File 'window.rb', line 179 def get_process_id(handle) validate(handle) AMS::C.get_window_process_id(handle) end |
+ (Array<Fixnum>) get_rect(handle)
Get upper-left and lower-right coordinates of the window in screen coordinates, relative to the upper-left corner of the screen.
262 263 264 265 |
# File 'window.rb', line 262 def get_rect(handle) validate(handle) AMS::C.get_window_rect(handle) end |
+ (Array<Fixnum>) get_size(handle)
Get window size.
436 437 438 439 |
# File 'window.rb', line 436 def get_size(handle) r = get_rect(handle) [r[2]-r[0], r[3]-r[1]] end |
+ (String) get_text(handle)
Get window caption.
238 239 240 241 |
# File 'window.rb', line 238 def get_text(handle) validate(handle) AMS::C.get_window_text(handle).unpack('C*').pack('U*') end |
+ (Fixnum) get_thread_id(handle)
Get window thread ID.
169 170 171 172 |
# File 'window.rb', line 169 def get_thread_id(handle) validate(handle) AMS::C.get_window_thread_id(handle) end |
+ (Boolean) is_active?(handle)
Determine whether handle is a reference to an active window; the window with which the user is currently working.
29 30 31 32 |
# File 'window.rb', line 29 def is_active?(handle) validate(handle) AMS::C.is_window_active?(handle) end |
+ (Boolean) is_child?(parent_handle, handle)
Determine whether handle is a reference to a child window.
80 81 82 83 84 |
# File 'window.rb', line 80 def is_child?(parent_handle, handle) validate(parent_handle) validate(handle) AMS::C.is_window_child?(parent_handle, handle) end |
+ (Boolean) is_input_enabled?(handle)
Determine whether keyboard and mouse input is enabled to the specified window.
508 509 510 511 |
# File 'window.rb', line 508 def is_input_enabled?(handle) validate(handle) AMS::C.is_window_enabled?(handle) end |
+ (Boolean) is_maximized?(handle)
Determine whether handle is a reference to a maximized window.
49 50 51 52 |
# File 'window.rb', line 49 def is_maximized?(handle) validate(handle) AMS::C.is_window_maximized?(handle) end |
+ (Boolean) is_minimized?(handle)
Determine whether handle is a reference to a minimized window.
59 60 61 62 |
# File 'window.rb', line 59 def is_minimized?(handle) validate(handle) AMS::C.is_window_minimized?(handle) end |
+ (Boolean) is_resizeable?(handle)
Determine whether window is resizeable.
468 469 470 471 |
# File 'window.rb', line 468 def is_resizeable?(handle) style = get_long(handle, -16) (style | 0x00040000 ) == style # WS_SIZEBOX end |
+ (Boolean) is_restored?(handle)
Determine whether handle is a reference to a restored window; a window that is not maximized or minimized.
69 70 71 72 |
# File 'window.rb', line 69 def is_restored?(handle) validate(handle) (!AMS::C.is_window_minimized?(handle) && !AMS::C.is_window_minimized?(handle)) end |
+ (Boolean) is_valid?(handle)
Determine whether handle is a reference to a valid window.
20 21 22 |
# File 'window.rb', line 20 def is_valid?(handle) AMS::C.is_window?(handle) end |
+ (Boolean) is_visible?(handle)
Determine whether handle is a reference to a visible window.
39 40 41 42 |
# File 'window.rb', line 39 def is_visible?(handle) validate(handle) AMS::C.is_window_visible?(handle) end |
+ (Boolean) lock_update(handle)
This method is usually called before and after setting window styles, followed by set_pos to update setting.
Lock window update.
350 351 352 353 |
# File 'window.rb', line 350 def lock_update(handle) validate(handle) if handle != nil AMS::C.lock_window_update(handle) end |
+ (Boolean) move(handle, x, y, width, height, b_repaint = true)
Move window.
387 388 389 390 391 392 393 394 395 |
# File 'window.rb', line 387 def move(handle, x, y, width, height, b_repaint = true) validate(handle) AMS.validate_type(x, Numeric) AMS.validate_type(y, Numeric) AMS.validate_type(width, Numeric) AMS.validate_type(height, Numeric) AMS.validate_type(b_repaint, TrueClass, FalseClass) AMS::C.move_window(handle, x, y, width, height, b_repaint) end |
+ (Object) refresh(handle)
Refresh window.
400 401 402 403 |
# File 'window.rb', line 400 def refresh(handle) validate(handle) AMS::C.refresh_window(handle) end |
+ (nil) send_message(handle, message, wParam, lParam)
Send Message to the specified window.
521 522 523 524 |
# File 'window.rb', line 521 def (handle, , wParam, lParam) validate(handle) AMS::C.(handle, .to_i, wParam.to_i, lParam.to_i) end |
+ (Fixnum) set_active(handle)
Set active window.
111 112 113 114 |
# File 'window.rb', line 111 def set_active(handle) validate(handle) AMS::C.set_active_window(handle) end |
+ (Boolean) set_icon(handle, path)
Modify window icon.
531 532 533 534 535 |
# File 'window.rb', line 531 def set_icon(handle, path) validate(handle) path = path.gsub("/", "\\").unpack('U*').pack('C*') AMS::C.set_window_icon(handle, path) end |
+ (Boolean) set_layered_attributes(handle, color, opacity, flags)
Set layered window attributes.
555 556 557 558 |
# File 'window.rb', line 555 def set_layered_attributes(handle, color, opacity, flags) validate(handle) AMS::C.set_layered_window_attributes(handle, color.to_i, opacity.to_i, flags.to_i) end |
+ (Fixnum) set_long(handle, index, long)
Set window long.
202 203 204 205 206 207 |
# File 'window.rb', line 202 def set_long(handle, index, long) validate(handle) AMS.validate_type(index, Numeric) AMS.validate_type(long, Numeric) AMS::C.set_window_long(handle, index.to_i, long.to_i) end |
+ (Boolean) set_menu(handle, menu_handle)
Set window menu.
227 228 229 230 231 |
# File 'window.rb', line 227 def (handle, ) validate(handle) AMS.validate_type(, Numeric) if != nil AMS::C.(handle, .to_i) end |
+ (Boolean) set_origin(handle, x, y, b_activate = true)
Set window origin.
428 429 430 |
# File 'window.rb', line 428 def set_origin(handle, x, y, b_activate = true) set_pos(handle, 0, x, y, 0, 0, 0x0261 | (b_activate ? 0 : 0x0014)) end |
+ (Fixnum) set_parent(handle, parent_handle)
Set window's parent window.
136 137 138 139 140 |
# File 'window.rb', line 136 def set_parent(handle, parent_handle) validate(handle) validate(parent_handle) AMS::C.set_parent_window(handle, parent_handle) end |
+ (Boolean) set_placement(handle, flags, show_cmd, min_pt, max_pt, rect)
Set Window Placement.
318 319 320 321 322 323 324 325 326 |
# File 'window.rb', line 318 def set_placement(handle, flags, show_cmd, min_pt, max_pt, rect) validate(handle) AMS.validate_type(flags, Numeric) AMS.validate_type(show_cmd, Numeric) AMS.validate_type(min_pt, Enumerable) AMS.validate_type(max_pt, Enumerable) AMS.validate_type(rect, Enumerable) AMS::C.set_window_placement(handle, flags.to_i, show_cmd.to_i, min_pt, max_pt, rect) end |
+ (Boolean) set_pos(handle, handle_insert_after, x, y, cx, cy, flags)
Set window position.
366 367 368 369 370 371 372 373 374 375 |
# File 'window.rb', line 366 def set_pos(handle, handle_insert_after, x, y, cx, cy, flags) validate(handle) AMS.validate_type(handle_insert_after, Fixnum) AMS.validate_type(x, Numeric) AMS.validate_type(y, Numeric) AMS.validate_type(cx, Numeric) AMS.validate_type(cy, Numeric) AMS.validate_type(flags, Numeric) AMS::C.set_window_pos(handle, handle_insert_after, x, y, cx, cy, flags) end |
+ (Boolean) set_rect(handle, x1, y1, x2, y2, b_activate = true)
Set upper-left and lower-right coordinates of the window.
461 462 463 |
# File 'window.rb', line 461 def set_rect(handle, x1, y1, x2, y2, b_activate = true) set_pos(handle, 0, x1, y1, x2-x1, y2-y1, 0x0260 | (b_activate ? 0 : 0x0014)) end |
+ (Boolean) set_resizeable(handle, b_state, b_activate = true)
Set window resizeable.
479 480 481 482 483 484 485 486 487 488 489 |
# File 'window.rb', line 479 def set_resizeable(handle, b_state, b_activate = true) b_state = b_state ? true : false return false if b_state == is_resizeable?(handle) style = get_long(handle, -16) new_style = b_state ? style | 0x00040000 : style & ~0x00040000 lock_update(handle) set_long(handle, -16, new_style) lock_update(nil) set_pos(handle, 0, 0, 0, 0, 0, 0x0267 | (b_activate ? 0 : 0x0014)) true end |
+ (Boolean) set_size(handle, w, h, b_activate = true)
Set window size.
448 449 450 |
# File 'window.rb', line 448 def set_size(handle, w, h, b_activate = true) set_pos(handle, 0, 0, 0, w, h, 0x0262 | (b_activate ? 0 : 0x0014)) end |
+ (Boolean) set_text(handle, caption)
Set window caption.
249 250 251 252 253 |
# File 'window.rb', line 249 def set_text(handle, caption) validate(handle) AMS.validate_type(caption, String) AMS::C.set_window_text(handle, caption.unpack('U*').pack('C*')) end |
+ (Fixnum) show(handle, state)
Set window show state.
92 93 94 95 96 |
# File 'window.rb', line 92 def show(handle, state) validate(handle) AMS.validate_type(state, Numeric) AMS::C.show_window(handle, state) end |
+ (void) validate(handle)
This method returns an undefined value.
Verify that handle is a reference to a valid window.
9 10 11 12 13 |
# File 'window.rb', line 9 def validate(handle) AMS.validate_type(handle, Fixnum) return if AMS::C.is_window?(handle) raise TypeError, "Handle is not a reference to a valid window!", caller end |