Module: AMS::Window

Defined in:
window.rb

Class Method Summary (collapse)

Class Method Details

+ (Array<Fixnum>) adjust_rect(rect, style, style_ex, b_menu)

Adjust window rect.

Parameters:

  • rect (Array<Fixnum>)
  • style (Fixnum)
  • style_ex (Fixnum)
  • b_menu (Boolean)

Returns:

  • (Array<Fixnum>)

    New rect: [x1,y1, x2,y2].

See Also:

Since:

  • 2.0.0



289
290
291
292
293
294
295
# File 'window.rb', line 289

def adjust_rect(rect, style, style_ex, b_menu)
  AMS.validate_type(rect, Enumerable)
  AMS.validate_type(style, Numeric)
  AMS.validate_type(style_ex, Numeric)
  AMS.validate_type(b_menu, TrueClass, FalseClass)
  AMS::C.adjust_window_rect(rect, style.to_i, style_ex.to_i, b_menu)
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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



542
543
544
545
# File 'window.rb', line 542

def draw_menu_bar(handle)
  validate(handle)
  AMS::C.draw_menu_bar(handle)
end

+ (Boolean) enable_input(handle, b_state)

Enable/Disable keyboard and mouse input to the specified window.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • b_state (Boolean)

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



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.

Returns:

  • (Fixnum)

    A handle to the active window.

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (String)

See Also:

Since:

  • 2.0.0



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).

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Array<Fixnum>)

    An array of four numeric values, representing upper-left and lower-right coordinates: [x1,y1, x2,y2].

See Also:

Since:

  • 2.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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • index (Fixnum)

Returns:

  • (Fixnum)

    Window long.

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Fixnum)

    A handle to the menu. If the specified window has no menu, the return value is zero.

See Also:

Since:

  • 2.0.0



215
216
217
218
# File 'window.rb', line 215

def get_menu(handle)
  validate(handle)
  AMS::C.get_window_menu(handle)
end

+ (Array<Fixnum>) get_origin(handle)

Get window origin.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Array<Fixnum>)
    x,y

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Fixnum)

    If the window is a child window, the return value is a handle to the parent window. If the window is a top-level window with the WS_POPUP style, the return value is a handle to the owner window. Otherwise, the return value is zero.

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Array)

    An array of 6 objects representing window placement: [length, flags, show_cmd, min_pt, max_pt, rect].

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Fixnum)

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Array<Fixnum>)

    An array of four numeric values, representing upper-left and lower-right coordinates: [x1,y1, x2,y2].

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Array<Fixnum>)
    w,h

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (String)

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Fixnum)

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Boolean)

Since:

  • 2.0.0



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.

Parameters:

  • parent_handle (Fixnum)
  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0.0



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.

Returns:

  • (Boolean)

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Boolean)

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A window handle to be tested.

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0.0



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)

Note:

This method is usually called before and after setting window styles, followed by set_pos to update setting.

Lock window update.

Examples:

Remove caption from the active window.

handle = AMS::Window.get_active
long = AMS::Window.get_long(handle, -16)
AMS::Window.lock_update(handle)
AMS::Window.set_long(handle, -16, long & ~0x00C00000)
AMS::Window.lock_update(nil)
AMS::Window.set_pos(handle, 0, 0, 0, 0, 0, 0x0277)

Set caption to the active window.

handle = AMS::Window.get_active
long = AMS::Window.get_long(handle, -16)
AMS::Window.lock_update(handle)
AMS::Window.set_long(handle, -16, long | 0x00C00000)
AMS::Window.lock_update(nil)
AMS::Window.set_pos(handle, 0, 0, 0, 0, 0, 0x0277)

Parameters:

  • handle (Fixnum, nil)

    A handle to the valid window to be locked. If this parameter is nil, the window is unlocked.

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • x (Fixnum)
  • y (Fixnum)
  • width (Fixnum)
  • height (Fixnum)
  • b_repaint (Boolean) (defaults to: true)

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • message (Fixnum, Bignum)
  • wParam (Fixnum, Bignum)
  • lParam (Fixnum, Bignum)

Returns:

  • (nil)

See Also:

Since:

  • 2.0.0



521
522
523
524
# File 'window.rb', line 521

def send_message(handle, message, wParam, lParam)
  validate(handle)
  AMS::C.send_message(handle, message.to_i, wParam.to_i, lParam.to_i)
end

+ (Fixnum) set_active(handle)

Set active window.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

Returns:

  • (Fixnum)

    A handle to the original active window.

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • path (String)

    Path to whether the icon is located.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • color (Fixnum, Bignum)
  • opacity (Fixnum)
  • flags (Fixnum)

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • index (Fixnum)
  • long (Fixnum)

Returns:

  • (Fixnum)

    Previous window long.

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • menu_handle (Fixnum, nil)

    A handle to the new menu. If this parameter is nil, the window's current menu is removed.

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



227
228
229
230
231
# File 'window.rb', line 227

def set_menu(handle, menu_handle)
  validate(handle)
  AMS.validate_type(menu_handle, Numeric) if menu_handle != nil
  AMS::C.set_window_menu(handle, menu_handle.to_i)
end

+ (Boolean) set_origin(handle, x, y, b_activate = true)

Set window origin.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • x (Fixnum)
  • y (Fixnum)
  • b_activate (Boolean) (defaults to: true)

    Whether to activate the window.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • parent_handle (Fixnum)

    A handle to the valid parent window.

Returns:

  • (Fixnum)

    If the functions succeeds, the return values is a handle to the previous parent window. Otherwise, the return value is zero.

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • flags (Fixnum)
  • show_cmd (Fixnum)
  • min_pt (Array<Fixnum>)

    (x,y)

  • max_pt (Array<Fixnum>)

    (x,y)

  • rect (Array<Fixnum>)

    (x1,y1, x2,y2)

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • handle_insert_after (Fixnum)
  • x (Fixnum)
  • y (Fixnum)
  • cx (Fixnum)
  • cy (Fixnum)
  • flags (Fixnum)

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • x1 (Fixnum)
  • y1 (Fixnum)
  • x2 (Fixnum)
  • y2 (Fixnum)
  • b_activate (Boolean) (defaults to: true)

    Whether to activate the window.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • b_state (Boolean)
  • b_activate (Boolean) (defaults to: true)

    Whether to activate the window.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • w (Fixnum)
  • h (Fixnum)
  • b_activate (Boolean) (defaults to: true)

    Whether to activate the window.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • caption (String)

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

    A handle to the valid window.

  • state (Fixnum)

Returns:

  • (Fixnum)

    Previous show state.

See Also:

Since:

  • 2.0.0



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.

Parameters:

  • handle (Fixnum)

Raises:

  • (TypeError)

    if handle is not a reference to the valid window.

Since:

  • 2.0.0



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