views:

22

answers:

1

Hi! Could you please help me to figure out how to bring Opera's window to front, using class name?! I use the following procedure to bring other applications to front and it works fine. I need to use only a class name and not window's caption. If I use window caption instead, the procedure works. Here is the procedure:

procedure SwitchToThisWindow(h1: hWnd; x: bool); stdcall;
external user32 Name 'SwitchToThisWindow';

procedure Opera;
var
Wnd:HWND;
begin
Wnd:= FindWindow(PChar('OpWindow'),nil);
 if (Wnd <> 0) then SwitchToThisWindow(Wnd, True) ;
////////////////////////////////////////////////////
A: 

Looking at Opera 10.50, there is more than one window with the OpWindow class, the other windows seem to be hidden so you should run FindWindow(Ex) in a loop or use EnumWindows and search until you find a visible OpWindow window. (This will probably cause problems when Opera is in the tray)

So, without actually testing, I'm guessing you would have to look for a visible OpWindow window, or a OpWindow window with a non empty title (Or maybe looking for a OpWindow that has a specific style (WS_OVERLAPPEDWINDOW or WS_EX_WINDOWEDGE))

It should also be noted that all of this is internal opera details and could change in the next version etc.

Anders