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. CHtmlView Windows 7 issue

CHtmlView Windows 7 issue

Scheduled Pinned Locked Moved C / C++ / MFC
helphtmlcryptography
15 Posts 4 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.
  • M Offline
    M Offline
    Member 8109560
    wrote on last edited by
    #1

    Hello, I have a (maybe small) problem that is driving me mad. I am using a CHtmlView derived class to display a html file that is stored locally on the PC. I'm using Navigate2() for that. On Windows XP machines everything works fine but Windows 7 always opens a new IExplorer window instead of displaying the file in my view. I tried to override OnNewWindow2() but the according event does not occur. I use the following code in the OnInitialUpdate() function of the view:

    CString fileName = theApp.m_sSettingsPath + CString("Certificate\\certificate.htm");
    Navigate2(fileName);

    I've also tried the "file://" syntax, but same behaviour. Thank's for your help, Ralf

    L X R 3 Replies Last reply
    0
    • M Member 8109560

      Hello, I have a (maybe small) problem that is driving me mad. I am using a CHtmlView derived class to display a html file that is stored locally on the PC. I'm using Navigate2() for that. On Windows XP machines everything works fine but Windows 7 always opens a new IExplorer window instead of displaying the file in my view. I tried to override OnNewWindow2() but the according event does not occur. I use the following code in the OnInitialUpdate() function of the view:

      CString fileName = theApp.m_sSettingsPath + CString("Certificate\\certificate.htm");
      Navigate2(fileName);

      I've also tried the "file://" syntax, but same behaviour. Thank's for your help, Ralf

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You need to use the extra options (dwFlags and lpszTargetFrameName) in the Navigate2()[^] call, as described here[^].

      Unrequited desire is character building. OriginalGriff

      M 1 Reply Last reply
      0
      • L Lost User

        You need to use the extra options (dwFlags and lpszTargetFrameName) in the Navigate2()[^] call, as described here[^].

        Unrequited desire is character building. OriginalGriff

        M Offline
        M Offline
        Member 8109560
        wrote on last edited by
        #3

        Thanks for your suggestions but I don't get it working. I've tried with all of the TargetFrameNames ("_self", "_top", "_parent") - no effect. For the BrowserNavConstants therer are several flags to open the file in a new window, tab ... but no one that prevents a new window explicitly. Another strange observation: when trying to open a URL (http://www.google.de/) it wont't show the rendered site but the source of the site in notepad.

        L R 2 Replies Last reply
        0
        • M Member 8109560

          Thanks for your suggestions but I don't get it working. I've tried with all of the TargetFrameNames ("_self", "_top", "_parent") - no effect. For the BrowserNavConstants therer are several flags to open the file in a new window, tab ... but no one that prevents a new window explicitly. Another strange observation: when trying to open a URL (http://www.google.de/) it wont't show the rendered site but the source of the site in notepad.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Sorry but I cannot suggest anything further if the Microsoft code does not work. Unfortunately I don't have MFC so can't try reproducing the problem.

          Unrequited desire is character building. OriginalGriff

          1 Reply Last reply
          0
          • M Member 8109560

            Hello, I have a (maybe small) problem that is driving me mad. I am using a CHtmlView derived class to display a html file that is stored locally on the PC. I'm using Navigate2() for that. On Windows XP machines everything works fine but Windows 7 always opens a new IExplorer window instead of displaying the file in my view. I tried to override OnNewWindow2() but the according event does not occur. I use the following code in the OnInitialUpdate() function of the view:

            CString fileName = theApp.m_sSettingsPath + CString("Certificate\\certificate.htm");
            Navigate2(fileName);

            I've also tried the "file://" syntax, but same behaviour. Thank's for your help, Ralf

            X Offline
            X Offline
            xrg_soft 163 com
            wrote on last edited by
            #5
            1. how about Navigate2("http://www.xxx.com"...)? 2) try OnNewWindow3 please.
            M 1 Reply Last reply
            0
            • X xrg_soft 163 com
              1. how about Navigate2("http://www.xxx.com"...)? 2) try OnNewWindow3 please.
              M Offline
              M Offline
              Member 8109560
              wrote on last edited by
              #6

              Thanks for your help, but still no luck. Implemented a handler for the NewWindow3 event but it seems that the event is not fired. Tried with Navigate2("http://www.codeproject.com") but same behaviour (source code shown in notepad). When trying to open local file it is downloaded to temporary internet files and then opened in IE.

              X 1 Reply Last reply
              0
              • M Member 8109560

                Thanks for your help, but still no luck. Implemented a handler for the NewWindow3 event but it seems that the event is not fired. Tried with Navigate2("http://www.codeproject.com") but same behaviour (source code shown in notepad). When trying to open local file it is downloaded to temporary internet files and then opened in IE.

                X Offline
                X Offline
                xrg_soft 163 com
                wrote on last edited by
                #7

                The behavior sounds like that the Win7 default shell operation not correctly set. Can you check the registry for the default value of HKEY_CLASSES_ROOT\htmlfile\shell [HKEY_CLASSES_ROOT\htmlfile\shell] @="opennew" or you can try on another Win7 machine?

                M 1 Reply Last reply
                0
                • X xrg_soft 163 com

                  The behavior sounds like that the Win7 default shell operation not correctly set. Can you check the registry for the default value of HKEY_CLASSES_ROOT\htmlfile\shell [HKEY_CLASSES_ROOT\htmlfile\shell] @="opennew" or you can try on another Win7 machine?

                  M Offline
                  M Offline
                  Member 8109560
                  wrote on last edited by
                  #8

                  Thanks again. Checked the registry value: was OK. Checked on another Win7 system: same behaviour. Created a new blank SDI-App with a CHtmlView derived View. Same code like in my original app:

                  CHtmlViewTest::OnInitialUpdate()
                  {
                  CHtmlView::OnInitialUpdate();
                  Navigate2(_T("http://www.codeproject.com"));
                  }

                  The source code of the page is opened in notepad. If I use a local html file, it is displayed correctly.

                  X 1 Reply Last reply
                  0
                  • M Member 8109560

                    Hello, I have a (maybe small) problem that is driving me mad. I am using a CHtmlView derived class to display a html file that is stored locally on the PC. I'm using Navigate2() for that. On Windows XP machines everything works fine but Windows 7 always opens a new IExplorer window instead of displaying the file in my view. I tried to override OnNewWindow2() but the according event does not occur. I use the following code in the OnInitialUpdate() function of the view:

                    CString fileName = theApp.m_sSettingsPath + CString("Certificate\\certificate.htm");
                    Navigate2(fileName);

                    I've also tried the "file://" syntax, but same behaviour. Thank's for your help, Ralf

                    R Offline
                    R Offline
                    Rage
                    wrote on last edited by
                    #9

                    Wild guess:

                    CHtmlView::Navigate2(fileName);

                    Just in case there is another Navigate2 around.

                    1 Reply Last reply
                    0
                    • M Member 8109560

                      Thanks for your suggestions but I don't get it working. I've tried with all of the TargetFrameNames ("_self", "_top", "_parent") - no effect. For the BrowserNavConstants therer are several flags to open the file in a new window, tab ... but no one that prevents a new window explicitly. Another strange observation: when trying to open a URL (http://www.google.de/) it wont't show the rendered site but the source of the site in notepad.

                      R Offline
                      R Offline
                      Rage
                      wrote on last edited by
                      #10

                      Member 8109560 wrote:

                      I've tried with all of the TargetFrameNames ("_self", "_top", "_parent") - no effect

                      Also tried with your window name, or only the cited predefined strings ?

                      M 1 Reply Last reply
                      0
                      • M Member 8109560

                        Thanks again. Checked the registry value: was OK. Checked on another Win7 system: same behaviour. Created a new blank SDI-App with a CHtmlView derived View. Same code like in my original app:

                        CHtmlViewTest::OnInitialUpdate()
                        {
                        CHtmlView::OnInitialUpdate();
                        Navigate2(_T("http://www.codeproject.com"));
                        }

                        The source code of the page is opened in notepad. If I use a local html file, it is displayed correctly.

                        X Offline
                        X Offline
                        xrg_soft 163 com
                        wrote on last edited by
                        #11

                        It's really very strange... Because CHtmlView::Navigate2 just a wrapper of IWebBrowser2::Navigate2 Maybe you need to step into the Navigate2 call. or just call IWebBrowser2::Navigate2 directly and see what will happened. Unfortunately I does not have Win7 on hand. So, can not help you more.

                        M 1 Reply Last reply
                        0
                        • X xrg_soft 163 com

                          It's really very strange... Because CHtmlView::Navigate2 just a wrapper of IWebBrowser2::Navigate2 Maybe you need to step into the Navigate2 call. or just call IWebBrowser2::Navigate2 directly and see what will happened. Unfortunately I does not have Win7 on hand. So, can not help you more.

                          M Offline
                          M Offline
                          Member 8109560
                          wrote on last edited by
                          #12

                          I've just tried to call Navigate2 in the CHtmlView and the IWebBrowser2 with all the same behavior. I come to think that it might be some user permissions thing on Windows 7. Maybe my app is not allowed to open websites? Does anyone know which permissions have to be granted? I've checked the I[Internet Explorer\Main\FEATURE_...] stuff but did not find something appropriate. I had a look on the process creation and following happened: After my Navigate2 call an iexplore process was created and this one created another iexplore process that then showed my page.

                          modified on Thursday, August 25, 2011 3:16 AM

                          1 Reply Last reply
                          0
                          • R Rage

                            Member 8109560 wrote:

                            I've tried with all of the TargetFrameNames ("_self", "_top", "_parent") - no effect

                            Also tried with your window name, or only the cited predefined strings ?

                            M Offline
                            M Offline
                            Member 8109560
                            wrote on last edited by
                            #13

                            How do I get my window name? Is it the one in the title bar?

                            R 1 Reply Last reply
                            0
                            • M Member 8109560

                              How do I get my window name? Is it the one in the title bar?

                              R Offline
                              R Offline
                              Rage
                              wrote on last edited by
                              #14

                              Member 8109560 wrote:

                              Is it the one in the title bar

                              Not necessarily; you can find it out using Spy++, or programmatically with, for instance:Get a handle on your window and use GetWindowText().

                              M 1 Reply Last reply
                              0
                              • R Rage

                                Member 8109560 wrote:

                                Is it the one in the title bar

                                Not necessarily; you can find it out using Spy++, or programmatically with, for instance:Get a handle on your window and use GetWindowText().

                                M Offline
                                M Offline
                                Member 8109560
                                wrote on last edited by
                                #15

                                Same behavior when specifying my window as target. X|

                                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