- ShowWindow not hiding new window opened by IWebBrowser2
- Posted by jmpinchot@gmail.com on November 28th, 2006
Im writing an application that automates internet explorer, and am
integrating a mode that lets IE run invisibly to the user. I start
Internet Explorer with CreateProcess and the wShowWindow flag set to
SW_HIDE and everything works wonderfully. The problem arises when IE
tries to open a new window either as a result of a javascript open or
the target being set in a A tag.
Currently I'm creating the new instance of IE with CoCreateInstance,
and then calling ShowWindow(HWND, SW_HIDE) but the window still shows
up as visible.
Here's the code the creates the new window:
The caller:
IWebBrowser2 * newIE = IEBrowserControllerUtil::createBrowser(NULL,
headless);
if (newIE) {
IEBrowserControllerUtil::addNewEventSink(newIE, false,
_windowName);
*ppDisp = (IDispatch*)newIE;
}
The code the above call goes through
if (!SUCCEEDED(CoCreateInstance(CLSID_InternetExplore r, 0,
CLSCTX_SERVER, IID_IWebBrowser2,
(LPVOID*) &newIE))) {
<error cleanup code>
}
I've also tried calling CreateProcess to create the new window instead,
and setting the Visible property of the IWebBrowser2 instance; I get
the same result, the window is still visible to the user.
Is there something I'm missing? Any help would be greatly appreciated.
- Posted by Lucian Wischik on November 29th, 2006
jmpinchot@gmail.com wrote:
I don't have any good ideas. But there are a heck of a lot of
different things you can do to control the interface of IWebBrowser2:
* IOleInPlaceSite/...OnUIActivate
* IOleClientSite/ShowWindow
* DWebBrowserEvents2
* DISPID_AMBIENT_DLCONTROL
* IDocHostUIHandler
* IDocHostShowUI
(The first two only apply if you're the OLE container of an
IWebBrowser2 instance, but presumably you are, since you said you
created an IWebBrowser2 with CoCreateInstance).
Anyway, I'm posting this message in case you weren't yet aware of all
these things, and in case any of them help. I've written some example
code that hosts an IWebBrowser2 control (without using ATL/MFC), and
shows how to hook into all the above:
http://www.wischik.com/lu/Programmer/Webform
--
Lucian
- New Opened Window Loosing Focus in Windwos XP Pro. Dell Inspiron 1 (Microsoft Windows) by PavanGayakwad
- Link opened search window (Microsoft Windows) by Joachim
- [MFC] Using IWebBrowser2 => Navigate with TargetFrameName (Development Resources) by Emin Tarajan
- Accidentaly opened I-Bagle - and then opened virus vault ?? (Computers & Technology) by Morph
- How to print XSL formatted XML in MFC using IWebBrowser2 (Development Resources) by Paresh

