CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2011
    Posts
    3

    SHDocVw.InternetExplorerClass visible property to False does not work on some machine

    I have an application whose function is to display a login page on a form load. Once the user logs in to the site, he can close the window. Later on some specified events, the application will pop up URLs from this site using the IE session from the login activity.

    To achieve this, I am launching a parent IE window and making it invisible. I am also launching a child window with the same URL which is visible. The agent will login to the website using this child window. The session is created here. Since the parent window is active, even if this child window is closed, the session will still be active.

    I have tested this feature on few machines and this works. Only the child window is visible. But on some other machines, both the parent and the child window becomes visible. This is the real problem and I am not sure why this happens. Below is the code snippet I use. Also my OS is Windows XP with IE7.

    //Launch Parent window with visible property false

    object oObj = null;

    SHDocVw.InternetExplorer m_IExplorer = new SHDocVw.InternetExplorerClass();

    m_IExplorer.Navigate(sLoginUrl, ref oObj, ref oObj, ref oObj, ref oObj);

    m_IExplorer.Visible = false;



    //Launch a child window. No need to set the visible property since the child window by default opens in Visible mode.

    object oChildWindowFlag = 0x1;

    m_IExplorer.Navigate(sLoginUrl, ref oChildWindowFlag, ref oObj, ref oObj, ref oObj);



    Any help on this is appreciated!

    Thank You,

    -Bhaskar

  2. #2
    Join Date
    May 2011
    Posts
    3

    Re: SHDocVw.InternetExplorerClass visible property to False does not work on some mac

    I have found a solution to the problem.

    Since I just need a hidden browser object to hold the session until the application quits, it is not necessary to call the Navigate method the first time. As I read from the documentation for the InternetExplorer class, the visible property will be false until a Navigate is called.

    What I figure was happening in my case was, the Navigate method is being called and the visible property is being set, but as soon as the page loads, a NavigateComplete event is triggered which makes the first window visible.

    The solution is plain simple. Just comment out the code calling the Navigate method and the Visible Property (optional - since you are not navigating to any page, so there is nothing to make it visible).

    //Launch Parent window with visible property false

    object oObj = null;

    SHDocVw.InternetExplorer m_IExplorer = new SHDocVw.InternetExplorerClass();

    //m_IExplorer.Navigate(sLoginUrl, ref oObj, ref oObj, ref oObj, ref oObj);

    //m_IExplorer.Visible = false;



    //Launch a child window. No need to set the visible property since the child window by default opens in Visible mode.

    object oChildWindowFlag = 0x1;

    m_IExplorer.Navigate(sLoginUrl, ref oChildWindowFlag, ref oObj, ref oObj, ref oObj);



    Thank You,

    -Bhaskar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured