CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: Knowing when a web page has been opened or close

  1. #1
    Join Date
    Jan 2009
    Posts
    365

    Knowing when a web page has been opened or closed

    Is there any way to know for sure when a web page (let say www.test.com) has been opened, and when this page has been closed ? I need this feature for a VC++/MFC project.
    Last edited by mesajflaviu; June 4th, 2020 at 08:48 AM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,758

    Re: Knowing when a web page has been opened or close

    And how this "web page" is about to use in your VC++/MFC project?
    Victor Nijegorodov

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,316

    Re: Knowing when a web page has been opened or close

    There is a way if your app is acting like a browser and displays the web oage (there is a browser control that lets you do this).

    If your app doesn't display the web page, there is no way.

    Btw, why does your app care if a web page is opened?

  4. #4
    Join Date
    Jan 2009
    Posts
    365

    Re: Knowing when a web page has been opened or close

    Quote Originally Posted by VictorN View Post
    And how this "web page" is about to use in your VC++/MFC project?
    From a button is starting a web page in default browser.

  5. #5
    Join Date
    Jan 2009
    Posts
    365

    Re: Knowing when a web page has been opened or close

    Quote Originally Posted by Arjay View Post
    There is a way if your app is acting like a browser and displays the web oage (there is a browser control that lets you do this).

    If your app doesn't display the web page, there is no way.

    Btw, why does your app care if a web page is opened?
    Because a part of application job is made it online, in a web page.

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,316

    Re: Knowing when a web page has been opened or close

    Quote Originally Posted by mesajflaviu View Post
    Because a part of application job is made it online, in a web page.
    I still don't know what you are taking about. Help me to understand where the web page is hosted.

    Is it hosted on a web server (like google.com would be)?
    Is it hosted locally by the C++ application (i.e. in a browser control within the C++ app like some apps do to display local help files).

    If you answer these questions I may be able to help further.

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,316

    Re: Knowing when a web page has been opened or close

    Based on you reply to Victor, "From a button is starting a web page in default browser" it isn't possible.

    The reason is the default browser is a separate process and you can't 'hook' into its events.

    On the other hand is if rather than using the default browser, you load up the page in a browser control hosted inside your app, then you will have access to the browser control's event and be able to handle the page load completed event.

  8. #8
    Join Date
    Jan 2009
    Posts
    365

    Re: Knowing when a web page has been opened or close

    Quote Originally Posted by Arjay View Post
    I still don't know what you are taking about. Help me to understand where the web page is hosted.

    Is it hosted on a web server (like google.com would be)?
    Is it hosted locally by the C++ application (i.e. in a browser control within the C++ app like some apps do to display local help files).

    If you answer these questions I may be able to help further.
    Yes, a part of app job is hosted on a foreign site, as you said, google.com. I'll try to host this web page as part of my app. Thank you.

  9. #9
    Join Date
    Jan 2009
    Posts
    365

    Re: Knowing when a web page has been opened or close

    I was thinking to trace the history folder for default browser. But I guess this is not the easy thing ... how can I identify this folder ?

  10. #10
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,316

    Re: Knowing when a web page has been opened or close

    Quote Originally Posted by mesajflaviu View Post
    I was thinking to trace the history folder for default browser. But I guess this is not the easy thing ... how can I identify this folder ?
    Um, are we now onto solving a different problem?

  11. #11
    Join Date
    Jan 2009
    Posts
    365

    Re: Knowing when a web page has been opened or close

    Quote Originally Posted by Arjay View Post
    Um, are we now onto solving a different problem?
    Sorry, I thought aloud. I guess is not a good idea.

  12. #12
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,597

    Re: Knowing when a web page has been opened or close

    Quote Originally Posted by mesajflaviu View Post
    I was thinking to trace the history folder for default browser. But I guess this is not the easy thing ... how can I identify this folder ?
    Not every browser maintains history. Perhaps you could do something with EnumWindows.

  13. #13
    Join Date
    Jan 2009
    Posts
    365

    Re: Knowing when a web page has been opened or close

    Quote Originally Posted by GCDEF View Post
    Not every browser maintains history. Perhaps you could do something with EnumWindows.
    Not a bad idea, but the browser can have already has opened tabs, and when I open a new tab from my app, or when user close the tab which has been open within my app, EnumWindows doesn't help me ...
    Last edited by mesajflaviu; June 12th, 2020 at 01:42 AM.

  14. #14
    Join Date
    Nov 2018
    Posts
    36

    Re: Knowing when a web page has been opened or close

    > Because a part of application job is made it online, in a web page.
    So, are you expecting the user to do something (more than just look at something) when they get to the website?

    If so, then perhaps you can just launch the browser with some URL from within your app, then asynchronously poll the website to look for some state change that the user performs.

    Is this your website, or some third party?
    If it's third party, are you doing anything which is against their terms of service?

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)