Re: How to bring ActiveX to top?



In article <439fd714.426397275@xxxxxxxxxxxxxxxxxxxx>,
J French <erewhon@xxxxxxxxxx> wrote:
> On Tue, 13 Dec 2005 18:00:12 +0000 (UTC), tony@xxxxxxxxxxxxxxxxxxx
> (Tony Mountifield) wrote:
>
> >I have an application that runs as an ActiveX control within a browser
> >window.
> >
> >It's possible that the user will have opened other windows on top of the
> >window in question, or perhaps minimised it. At a certain point in the
> >program I need to bring the browser window containing the control to the
> >top, in order to get the user's attention. How can I do this?
> >
> >I've tried both Show and SetWindowPos on the ActiveForm with HWND_TOP or
> >HWND_TOPMOST, but it doesn't work - I suspect it's only affecting the
> >control within the context of the broswer, and that I actually need to
> >tell the browser itself to be on top.
> >
> >Any ideas would be gratefully received!
>
> You need to find the Parent Window of the AX control
> - well the HWND of the Form that it is on
> - that may be a bit tricky - you may need to resort to FindWindow

Actually, I discovered that if I work my way up the handles using GetParent(),
I arrive at the browser handle which has a parent of 0.

Using the browser handle works, once I found the right thing to do with it.

> Also under XP a non active window is not supposed to force itself to
> the top, but someone has found a sneaky trick for getting round that.
>
> { Force Window to front
> Credit to: Karl E. Peterson }
> Function ForceForegroundWindow( Const hWnd :DWORD):Boolean;

Thanks for that. It didn't work quite as I wanted, but searchin Google
based on it led me to http://www.swissdelphicenter.ch/torry/showcode.php?id=261
and I found that a combination of "way 2" and "way 3" worked very well
when given the broswer handle I mentioned above.

Cheers
Tony
--
Tony Mountifield
Work: tony@xxxxxxxxxxxxx - http://www.softins.co.uk
Play: tony@xxxxxxxxxxxxxxx - http://tony.mountifield.org
.



Relevant Pages

  • Re: System Tray Application - need hide taskbar icon workaround
    ... I have tried setting the ShowInTaskBar in the Load and activate events ... or the ShowInTaskBar is true then the control will be created correctly. ... >> Problem is that there is an activeX component on the form that I need to ... >> need to create the window somewhere. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: MSIE exploit
    ... You have to give your browser explicit permission to install an ActiveX ... control, unless you lower your security settings too low. ... > executable files and execute them. ...
    (microsoft.public.security)
  • Re: Drawing in CHtmlView
    ... represent the other person's cursor, so this cursor is what I want to draw ... other person's browser. ... All the drawing is done by and in that control. ... In order to draw something in that window you will have to replace that ...
    (microsoft.public.vc.mfc)
  • Re: Drawing in CHtmlView
    ... represent the other person's cursor, so this cursor is what I want to draw ... other person's browser. ... All the drawing is done by and in that control. ... In order to draw something in that window you will have to replace that ...
    (microsoft.public.vc.mfc)
  • Re: Webbrowser control looses sessionid on "newwindow"
    ... I do not have control over the web page. ... are errors then they are output to the window). ... instance of the webbrowser control), ... I haven't gone to the trouble of creating a beresque browser to test your ...
    (microsoft.public.windows.inetexplorer.ie6.browser)