Re: ShowWindow not hiding new window opened by IWebBrowser2



Guys,

Is there no better solution to this?

Interestingly I've just had the same issue. I'm actually using Internet
Explorer for test automation of our web application. This is working really
well however I really want to ensure the browser is invisibible because I'm
launching NUnit tests which are using IE, and the NUnit tests are started
through the cruise control .NET service.

I didn't really want to have to change the options for the service to
"Interact with the desktop" which I presume I'd have to do if the window is
displayed. Do you know why the window certainly becomes visible after
setting it to invisible. I've added trace statements to all IE events which
is shown below

Before Navigate2 to URL
http://localhost/Sprinter3.6.2/General/FindSupplier.asp?SupplierID=-10000&FormID=EditInvoice&FieldID=Supplier
Download begins now
Command State change : Command = -1, Enable = False
OnVisible - Visible
Command State change : Command = 2, Enable = False
Command State change : Command = 1, Enable = False

The code for OnNewWindow is

/// <summary>
/// Fires when a new window is to be created
/// </summary>
/// <param name="newInternetExplorer"></param>
/// <param name="cancelNavigation"></param>
/// <param name="flags"></param>
/// <param name="urlContext">URL of the page opening the new
window</param>
/// <param name="url">URL being opened in the new window</param>
void OnNewWindow( ref Object newInternetExplorer,
ref Boolean cancelNavigation,
uint flags,
String urlContext,
String url)
{
Trace.WriteLineIf( traceSwitch.TraceLevelInfo,
String.Format( "OnNewWindow - URL = '{0}'",
url));

InternetExplorer newWindowInternetExplorer = new
InternetExplorerClass();
newWindowInternetExplorer.RegisterAsBrowser= true;
newWindowInternetExplorer.Visible = initialWindowStateVisible;
newInternetExplorer = newWindowInternetExplorer.Application;

InternetExplorerWrapper ieWrapper = new InternetExplorerWrapper();
ieWrapper.Attach(newWindowInternetExplorer);

newIeWindows[url] = ieWrapper;
}

Any thoughts?

"Igor Tandetnik" <itandetnik@xxxxxxxx> wrote in message
news:%23pB%23T5zEHHA.992@xxxxxxxxxxxxxxxxxxxxxxx
jmpinchot@xxxxxxxxx wrote:
m 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.

Sink DWebBrowserEvents2 from the new window, wait for
OnVisible(VARIANT_TRUE), and _then_ hide the window, either with
ShowWindow or with IWebBrowser2::put_Visible
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925




.



Relevant Pages

  • Re: right mouse key not working properly
    ... right mouse key will close explorer window ... You cannot access the Internet in Safe Mode. ...
    (microsoft.public.windowsxp.hardware)
  • Re: Internet Explorer 6 stops responding
    ... When I first open Internet Explorer, a blank page displays at Internet ... I could only close one browser window and the other would remain ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • RE: internet expolorer will not open up browser windows - help!
    ... Okay, you misguided here by me, sorry!, When I said Windows Explorer I didn't ... my internet explorer does not have the menu bar. ... There click on File Type and scroll down to Internet Shortcut then click Edit. ... and close the editing window the scoll down to this File type: ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Search Assistant Not Working Right - More curious...
    ... || Preferences>Change Internet Search behavior>and saw that it had changed ... || search window, the Customize tab and grayed out Next button. ... Internet Explorer SP2 includes the ability to block pop-up windows. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Search Assistant Not Working Right - More curious...
    ... || Preferences> Change Internet Search behavior>reselected the With Classic ... || search window, the Customize tab and grayed out Next button. ... Internet Explorer SP2 includes the ability to block pop-up windows. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)