Class: DFC::Window

Inherits:
Object show all

Overview

WIN32窗口相关操作

Class Method Summary # collapse

Class Method Details

.close(handle) ⇒ Boolean

Note:

This function behaves the same way as clicking the ‘X’ button.

Close window.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (Boolean)

    success

.cmd_exec(cmdline) ⇒ Boolean

同步执行cmd命令 隐藏窗口

Parameters:

  • cmdline (String)

    命令行

Returns:

  • (Boolean)

    success

.get_caption(handle) ⇒ String

Get window text.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (String)

See Also:

Since:

  • 3.0.0

.get_class_long(handle, index) ⇒ Fixnum

Get class long.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

  • index (Fixnum)

Returns:

  • (Fixnum)

    Window long.

See Also:

Since:

  • 3.6.0

.get_cursor_colorArray

获取当前鼠标位置屏幕RGB

Examples:

DFC::Window.get_cursor_color

Returns:

  • (Array)

.get_layered_attributes(handle) ⇒ Array<(Array<Fixnum>, Fixnum, Fixnum)>

Get layered attributes of a window.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (Array<(Array<Fixnum>, Fixnum, Fixnum)>)

    An array of three values: [rgb_color, opacity, flags]

Since:

  • 3.0.0

.get_long(handle, index) ⇒ Fixnum

Get window long.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

  • index (Fixnum)

Returns:

  • (Fixnum)

    Window long.

See Also:

.get_menu(handle) ⇒ Fixnum?

Get window menu.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (Fixnum, nil)

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

See Also:

.get_origin(handle) ⇒ Array<Fixnum>

Get coordinates of the upper-left corner of a window.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (Array<Fixnum>)
    x,y

.get_rect(handle) ⇒ Array<Fixnum>

Get upper-left and lower-right coordinates of a window in screen coordinates, relative to the upper-left corner of the screen.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (Array<Fixnum>)

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

See Also:

.get_size(handle) ⇒ Array<Fixnum>

Get size of a window.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (Array<Fixnum>)
    width, height

.get_unique_codeString

获取电脑唯一码

Examples:

DFC::Window.get_unique_code

Returns:

  • (String)

.is_active?(handle) ⇒ Boolean

Determine whether window is active.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (Boolean)

.is_child?(handle, parent_handle) ⇒ Boolean

Determine whether window is a child window of a specific parent window.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

  • parent_handle (Fixnum)

    Handle to a valid parent window.

Returns:

  • (Boolean)

See Also:

Since:

  • 3.0.0

.is_maximized?(handle) ⇒ Boolean

Determine whether window is maximized.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (Boolean)

See Also:

.is_minimized?(handle) ⇒ Boolean

Determine whether window is minimized.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (Boolean)

See Also:

.is_restored?(handle) ⇒ Boolean

Determine whether window is restored; not maximized nor minimized.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (Boolean)

.is_unicode?(handle) ⇒ Boolean

Determine whether window is unicode.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (Boolean)

See Also:

Since:

  • 3.0.0

.is_valid?(handle) ⇒ Boolean

Determine whether handle is a reference to a valid window.

Parameters:

  • handle (Fixnum)

    A handle to be tested.

Returns:

  • (Boolean)

See Also:

.is_visible?(handle) ⇒ Boolean

Determine whether window is visible.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

Returns:

  • (Boolean)

See Also:

.open_panel(path, is_mul = false, flter = "所有文件|*.*||", title = nil, parent = DFC::SketchupUtil.get_main_window) ⇒ Hash Also known as: mul_file_choose

文件打开多选对话框

Examples:

DFC::Window.open_panel "C:/",true,"图片|*.png;*.jpg;*.gif;*.bmp;*.tiff;|","asdfas",nil

Parameters:

  • path (String)

    打开路径

  • is_mul (Boolean) (defaults to: false)

    是否多选 默认为单选

  • flter (String) (defaults to: "所有文件|*.*||")

    文件筛选格式 fiflter = “图片|.png;.jpg;.gif;.bmp;*.tiff;|”

  • title (String) (defaults to: nil)

    窗口标题

  • parent (Object) (defaults to: DFC::SketchupUtil.get_main_window)

    父级窗口 默认为Sketchup 主窗口

Returns:

  • (Hash)

    “parentPath”=>“”,“files”=>[]

.peek_message(handle, msg_filter_min, msg_filter_max, remove_flag) ⇒ Array?

Peek message of a specific window.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

  • msg_filter_min (Fixnum, Bignum)
  • msg_filter_max (Fixnum, Bignum)
  • remove_flag (Fixnum, Bignum)

Returns:

  • (Array, nil)

    An array containing peeked message data or nil if no messages are available.

See Also:

Since:

  • 3.5.0

.post_message(handle, message, wParam, lParam) ⇒ Boolean

Post message to a specific window.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

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

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 3.0.0

.save_panel(path, flter = "所有文件|*.*||", title = nil, parent = DFC::SketchupUtil.get_main_window) ⇒ String

文件保存对话框

Examples:

DFC::Window.save_panel "C:/","图片|*.png;*.jpg;*.gif;*.bmp;*.tiff;|",nil

Parameters:

  • path (String)

    保存路径

  • flter (String) (defaults to: "所有文件|*.*||")

    文件筛选格式 fiflter = “图片|.png;.jpg;.gif;.bmp;*.tiff;|”

  • title (String) (defaults to: nil)

    窗口标题

  • parent (Object) (defaults to: DFC::SketchupUtil.get_main_window)

    父级窗口 默认为Sketchup 主窗口

Returns:

  • (String)

    文件路径

.send_message(handle, message, wParam, lParam) ⇒ Fixnum

Send message to a specific window.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

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

Returns:

  • (Fixnum)

    Message processing result.

See Also:

.set_caption(handle, caption) ⇒ Boolean

Set window text.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

  • caption (String)

Returns:

  • (Boolean)

    success

See Also:

Since:

  • 3.0.0

.set_class_long(handle, index, long) ⇒ Fixnum

Set class long.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

  • index (Fixnum)
  • long (Fixnum)

Returns:

  • (Fixnum)

    Previous window long.

See Also:

Since:

  • 3.6.0

.set_layered_attributes(handle, color, opacity, flags) ⇒ Boolean

Set layered attributes of a window.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

  • color (Fixnum, Bignum, Array<Fixnum>)

    A number or an array representing color in RGB form. Note: An array is not acceptible in library versions prior to 3.0.0.

  • opacity (Fixnum)

    A value between 0 (transparent) and 255 (opaque).

  • flags (Fixnum)

Returns:

  • (Boolean)

    success

See Also:

.set_long(handle, index, long) ⇒ Fixnum

Set window long.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

  • index (Fixnum)
  • long (Fixnum)

Returns:

  • (Fixnum)

    Previous window long.

See Also:

.set_menu(handle, menu_handle) ⇒ Boolean

Set window menu.

Parameters:

  • handle (Fixnum)

    Handle to a 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:

.set_origin(handle, x, y, b_activate = true) ⇒ Boolean

Set coordinates of the upper-left corner of a window.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

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

    Whether to activate the window.

Returns:

  • (Boolean)

    success

.set_pos(handle, handle_insert_after, x, y, cx, cy, flags) ⇒ Boolean

Set window position.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

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

Returns:

  • (Boolean)

    success

See Also:

.set_rect(handle, x1, y1, x2, y2, b_activate = true) ⇒ Boolean

Set upper-left and lower-right coordinates of a window.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

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

    Whether to activate the window.

Returns:

  • (Boolean)

    success

.show(handle, state) ⇒ Boolean

Set show state of a window.

Parameters:

  • handle (Fixnum)

    Handle to a valid window.

  • state (Fixnum)

Returns:

  • (Boolean)

    True if window was previously visible; false if window was previously hidden.

See Also: