Module: TT::Win32::Shim

Includes:
Fiddle
Defined in:
TT_Lib2/win32_shim.rb

Overview

Since:

  • 2.5.0

Defined Under Namespace

Modules: Kernel32, User32

Constant Summary

FALSE =

Since:

  • 2.5.0

0
TRUE =

Since:

  • 2.5.0

1
GA_PARENT =

Since:

  • 2.5.0

1
GA_ROOT =

Since:

  • 2.5.0

2
GA_ROOTOWNER =

Since:

  • 2.5.0

3

Class Method Summary collapse

Class Method Details

.get_main_window_handleInteger

TT::Win32.get_main_window_handle

Returns the window handle of the SketchUp window for the input queue of the calling ruby method.

Returns:

  • (Integer)

    Returns a window handle on success or nil on failure

Since:

  • 2.5.0



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'TT_Lib2/win32_shim.rb', line 46

def self.get_main_window_handle
  thread_id = Kernel32.GetCurrentThreadId()
  main_hwnd = 0
  param = 0

  enumWindowsProc = Closure::BlockCaller.new(TYPE_INT,
    [TYPE_VOIDP, TYPE_VOIDP]) { |hwnd, lparam|
      main_hwnd = User32.GetAncestor(hwnd, GA_ROOTOWNER)
      next FALSE
  }

  User32.EnumThreadWindows(thread_id, enumWindowsProc, param)
  main_hwnd
end