# http://ruby-doc.org/docs/ProgrammingRuby/html/lib_windows.html#Win32API.new require 'Win32API' WS_CAPTION = 0x00C00000 WS_EX_TOOLWINDOW = 0x00000080 GWL_STYLE = -16 GWL_EXSTYLE = -20 # SetWindowPos() flags SWP_NOSIZE = 0x0001 SWP_NOMOVE = 0x0002 SWP_DRAWFRAME = 0x0020 SWP_FRAMECHANGED = 0x0020 SWP_NOREPOSITION = 0x0200 # Windows Functions #FindWindow = Win32API.new("user32.dll" , "FindWindow" , 'PP' , 'L') #FindWindowEx = Win32API.new("user32.dll", "FindWindowEx" , 'LLPP', 'L') SetWindowPos = Win32API.new("user32.dll" , "SetWindowPos" , 'LLIIIII', 'I') SetWindowLong = Win32API.new("user32.dll" , "SetWindowLong", 'LIL', 'L') GetWindowLong = Win32API.new("user32.dll" , "GetWindowLong", 'LI' , 'L') GetActiveWindow = Win32API.new("user32.dll", "GetActiveWindow", '', 'L') #GetForegroundWindow = Win32API.new("user32.dll", "GetForegroundWindow", '', 'L') GetWindowText = Win32API.new("user32.dll", "GetWindowText", 'LPI', 'I') GetWindowTextLength = Win32API.new("user32.dll", "GetWindowTextLength", 'L', 'I') def create_toolbar_window window = UI::WebDialog.new('My Test Window', false) window.set_html(' My very own window
Neato! ') window.show # Find the new window - should get it by GetActiveWindow since wd.show brings # the window to front. hwnd = GetActiveWindow.call #hwnd = GetForegroundWindow.call #hwnd = FindWindow.call(DIALOG_CLASS, window_title) p hwnd puts 'Check Window Text' buf_len = GetWindowTextLength.call(hwnd) str = ' ' * (buf_len + 1) p GetWindowText.call(hwnd, str, str.length) p str p str.strip # Change Window Style style = GetWindowLong.call(hwnd, GWL_EXSTYLE) p style p SetWindowLong.call(hwnd, GWL_EXSTYLE, style | WS_EX_TOOLWINDOW) p SetWindowPos.call(hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE) end