Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CWebBrowser - OnWindowClosingBrowser Method..

CWebBrowser - OnWindowClosingBrowser Method..

Scheduled Pinned Locked Moved C / C++ / MFC
toolshelptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 3831761
    wrote on last edited by
    #1

    I have a dialog based application with WebBrower control on it. The URL that i open in the webbrowser uses script having Windows.close() method. When the URL is closing it calls OnWindowClosing Browser Method, and later post a message saying "The webpage you're viewing is trying to close this window. Do you want to close this window? - YES/NO" My issue is on clicking YES the dialog is not closing. What should i do to close the dialog on selecting YES in above dialog. And secondly, i want the application to return 22 on clicking YES. How to may Dialog application return 22 on clicking YES above. Thank you..

    B 1 Reply Last reply
    0
    • U User 3831761

      I have a dialog based application with WebBrower control on it. The URL that i open in the webbrowser uses script having Windows.close() method. When the URL is closing it calls OnWindowClosing Browser Method, and later post a message saying "The webpage you're viewing is trying to close this window. Do you want to close this window? - YES/NO" My issue is on clicking YES the dialog is not closing. What should i do to close the dialog on selecting YES in above dialog. And secondly, i want the application to return 22 on clicking YES. How to may Dialog application return 22 on clicking YES above. Thank you..

      B Offline
      B Offline
      Bacon Ultimate Cheeseburger
      wrote on last edited by
      #2

      Member 3834630 wrote:

      My issue is on clicking YES the dialog is not closing.

      After the browser control is closed are you relaying that event to the dialog or attempting to close the dialog with a call to EndDialog()?

      1300 calories of pure beef goodness can't be wrong!

      U 1 Reply Last reply
      0
      • B Bacon Ultimate Cheeseburger

        Member 3834630 wrote:

        My issue is on clicking YES the dialog is not closing.

        After the browser control is closed are you relaying that event to the dialog or attempting to close the dialog with a call to EndDialog()?

        1300 calories of pure beef goodness can't be wrong!

        U Offline
        U Offline
        User 3831761
        wrote on last edited by
        #3

        Hello, I have not done anything currently. What should i do to get dialog closed when Windows.Close() method is called in script. What to do to close the dialog when YES is selected and return a different value to ExitInstance(). Thank you..

        B 1 Reply Last reply
        0
        • U User 3831761

          Hello, I have not done anything currently. What should i do to get dialog closed when Windows.Close() method is called in script. What to do to close the dialog when YES is selected and return a different value to ExitInstance(). Thank you..

          B Offline
          B Offline
          Bacon Ultimate Cheeseburger
          wrote on last edited by
          #4

          Member 3834630 wrote:

          What should i do to get dialog closed when Windows.Close() method is called in script.

          It really depends on your requirements. One way would be to create a class that implements the DWebBrowserEvents2[^] dispatch interface and register it with the appropriate connection point in the browser control. When the windowClosing() method is invoked (in your dialog) you can cancel the event, display the prompt to close the window and if the user selects yes simply call EndDialog() with the desired error code:

          void CMyDialog::onWindowClosing(
          VARIANT_BOOL IsChildWindow,
          VARIANT_BOOL *Cancel)
          {
          *Cancel = VARIANT_TRUE;

          UINT result = MessageBox("Close window?", "Close Window?", MB\_YESNO);
          if(IDYES == result) {
              EndDialog(23);
          }
          

          }

          I am a lean mean ground beef machine!!!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups