From: Eric Landuyt Date: 2003-09-26T02:02:34+09:00 Subject: Re: VRuby/Win32 Question > I am trying to bring a VRuby app to be the front most window. I try the following but it doesn't work. Any ideas of what to try next would be appreciated: > > bringWindowToTop = Win32API.new("user32", "BringWindowToTop", ["L"], "L") > bringWindowToTop.Call(self.hWnd) > > I have also tried ["P"] for the argument with no effect. When I inspect self.hWnd it is a Fixnum with a large number in it. I used Spy++ to check the window handle and it > matched. I also thought of trying hParent but that didn't work as hParent is zero. I suppose you want to code something similar to the "window always on top" setting available in various applications. For this, use SetWindowPos() in place of BringWindowToTop(). Try to convert the following C code to Ruby (using Win32API): SetWindowPosl(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE) To disable the "always on top" feature: SetWindowPosl(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE) (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowFunctions/SetWindowPos.asp for more details about this function) Eric Landuyt