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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Need help with NewWindow3 and IWebBrowse2

Need help with NewWindow3 and IWebBrowse2

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomhelptutorial
21 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.
  • P Paul Groetzner

    That didn't work. The compiler didn't like it one bit :( error C2227: left of '->bstrVal' must point to class/struct/union/generic type type is 'BSTR *'

    D Offline
    D Offline
    David Crow
    wrote on last edited by
    #11

    Show me your code once more. Did you try it with/out the ampersand?


    "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

    "Judge not by the eye but by the heart." - Native American Proverb

    P 1 Reply Last reply
    0
    • D David Crow

      Show me your code once more. Did you try it with/out the ampersand?


      "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

      "Judge not by the eye but by the heart." - Native American Proverb

      P Offline
      P Offline
      Paul Groetzner
      wrote on last edited by
      #12

      Tried it with and without the ampersand. Pretty much the same error: with: error C2227: left of '->bstrVal' must point to class/struct/union/generic type type is 'BSTR *' without: error C2227: left of '->bstrVal' must point to class/struct/union/generic type type is 'BSTR' Here's my code: ON_EVENT(CLoadWebSite, IDC_EXPLORER, 273 /* NewWindow3 */, OnNewWindow3Explorer1, VTS_DISPATCH VTS_PBOOL VTS_BSTR VTS_BSTR VTS_BSTR) void CLoadWebSite::OnNewWindow3Explorer1(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel, BSTR Flags, BSTR URLContext, BSTR URL) { CString url(V_BSTR(URL)); AfxMessageBox(url); *Cancel = TRUE; // Browser.Navigate(url,NULL,NULL,NULL,NULL); }

      D 1 Reply Last reply
      0
      • P Paul Groetzner

        Tried it with and without the ampersand. Pretty much the same error: with: error C2227: left of '->bstrVal' must point to class/struct/union/generic type type is 'BSTR *' without: error C2227: left of '->bstrVal' must point to class/struct/union/generic type type is 'BSTR' Here's my code: ON_EVENT(CLoadWebSite, IDC_EXPLORER, 273 /* NewWindow3 */, OnNewWindow3Explorer1, VTS_DISPATCH VTS_PBOOL VTS_BSTR VTS_BSTR VTS_BSTR) void CLoadWebSite::OnNewWindow3Explorer1(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel, BSTR Flags, BSTR URLContext, BSTR URL) { CString url(V_BSTR(URL)); AfxMessageBox(url); *Cancel = TRUE; // Browser.Navigate(url,NULL,NULL,NULL,NULL); }

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #13

        I messed up (again). :-O Since URL is already a BSTR, as opposed to a VARIANT, it obviously cannot be run through the V_BSTR() macro.


        "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

        "Judge not by the eye but by the heart." - Native American Proverb

        P 1 Reply Last reply
        0
        • D David Crow

          I messed up (again). :-O Since URL is already a BSTR, as opposed to a VARIANT, it obviously cannot be run through the V_BSTR() macro.


          "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

          "Judge not by the eye but by the heart." - Native American Proverb

          P Offline
          P Offline
          Paul Groetzner
          wrote on last edited by
          #14

          I've tried converting the value to CString every which way and it always comes to the same results no matter what, a line of several dozen ? marks. This is getting quite frustrating :(( I have to assume then that it may be a problem with BSTR URL not reporting a proper url. To test the NewWindow3 function I had my default site go to google.com, I searched on a something irrelevant and right-clicked to Open to a new window to trigger the event. In the debugger URL always comes back as a bunch of square shapes (I think because debugger can't display BSTR?, at least there's a doc somewhere on codeproject that said it couldn't, but it might have been for an older version of VS) and converting always results in ? marks... If you want to test this you can do do very easily by going to this link: http://www.codeproject.com/com/webbrowser.asp[^] This is basically something similar to what I have. Just edit the code, change the default site if you wish and add the event for the NewWindow3 compile and have at it to see what you can find...

          D 2 Replies Last reply
          0
          • P Paul Groetzner

            I've tried converting the value to CString every which way and it always comes to the same results no matter what, a line of several dozen ? marks. This is getting quite frustrating :(( I have to assume then that it may be a problem with BSTR URL not reporting a proper url. To test the NewWindow3 function I had my default site go to google.com, I searched on a something irrelevant and right-clicked to Open to a new window to trigger the event. In the debugger URL always comes back as a bunch of square shapes (I think because debugger can't display BSTR?, at least there's a doc somewhere on codeproject that said it couldn't, but it might have been for an older version of VS) and converting always results in ? marks... If you want to test this you can do do very easily by going to this link: http://www.codeproject.com/com/webbrowser.asp[^] This is basically something similar to what I have. Just edit the code, change the default site if you wish and add the event for the NewWindow3 compile and have at it to see what you can find...

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #15

            univega_r304 wrote:

            I think because debugger can't display BSTR

            It might indeed be a Unicode thing. This is the default for VS2003 and VS2005, but not so with VS6 (what I'm using). In the Watch window, the symbol for strings is s while the symbol for Unicode strings is su. See here for more.


            "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

            "Judge not by the eye but by the heart." - Native American Proverb

            P 1 Reply Last reply
            0
            • D David Crow

              univega_r304 wrote:

              I think because debugger can't display BSTR

              It might indeed be a Unicode thing. This is the default for VS2003 and VS2005, but not so with VS6 (what I'm using). In the Watch window, the symbol for strings is s while the symbol for Unicode strings is su. See here for more.


              "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

              "Judge not by the eye but by the heart." - Native American Proverb

              P Offline
              P Offline
              Paul Groetzner
              wrote on last edited by
              #16

              Yeah, I'm using VS2005... Here's a new bit a code that came very close... void CLoadWebSite::OnNewWindow3Explorer1(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel, BSTR Flags, BSTR URLContext, BSTR URL) { BSTR b = URL; _bstr_t orig(b); CString cstring((char *)orig); AfxMessageBox(_T(cstring)); *Cancel = TRUE; Browser.Navigate(cstring,NULL,NULL,NULL,NULL); } When I debug this code the value for cstring is the URL I need! However, when I try to view it with AfxMessageBox or Navigate to it, it still thinks the value is all question marks.... I don't understand why it could show me one thing and do another... I wish there was a way to post a screenshot.... Any ideas?

              D 1 Reply Last reply
              0
              • P Paul Groetzner

                Yeah, I'm using VS2005... Here's a new bit a code that came very close... void CLoadWebSite::OnNewWindow3Explorer1(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel, BSTR Flags, BSTR URLContext, BSTR URL) { BSTR b = URL; _bstr_t orig(b); CString cstring((char *)orig); AfxMessageBox(_T(cstring)); *Cancel = TRUE; Browser.Navigate(cstring,NULL,NULL,NULL,NULL); } When I debug this code the value for cstring is the URL I need! However, when I try to view it with AfxMessageBox or Navigate to it, it still thinks the value is all question marks.... I don't understand why it could show me one thing and do another... I wish there was a way to post a screenshot.... Any ideas?

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #17

                univega_r304 wrote:

                AfxMessageBox(_T(cstring));

                The _T() macro is for string literals.


                "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                "Judge not by the eye but by the heart." - Native American Proverb

                1 Reply Last reply
                0
                • P Paul Groetzner

                  I've tried converting the value to CString every which way and it always comes to the same results no matter what, a line of several dozen ? marks. This is getting quite frustrating :(( I have to assume then that it may be a problem with BSTR URL not reporting a proper url. To test the NewWindow3 function I had my default site go to google.com, I searched on a something irrelevant and right-clicked to Open to a new window to trigger the event. In the debugger URL always comes back as a bunch of square shapes (I think because debugger can't display BSTR?, at least there's a doc somewhere on codeproject that said it couldn't, but it might have been for an older version of VS) and converting always results in ? marks... If you want to test this you can do do very easily by going to this link: http://www.codeproject.com/com/webbrowser.asp[^] This is basically something similar to what I have. Just edit the code, change the default site if you wish and add the event for the NewWindow3 compile and have at it to see what you can find...

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #18

                  univega_r304 wrote:

                  If you want to test this you can do do very easily by going to this link: http://www.codeproject.com/com/webbrowser.asp\[^\] This is basically something similar to what I have. Just edit the code, change the default site if you wish and add the event for the NewWindow3 compile and have at it to see what you can find...

                  I already had an application that uses this control, but for some reason it does not support the NewWindow3 event. What version of shdocvw.dll do you have? Mine is 6.0.2900.2937.


                  "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                  "Judge not by the eye but by the heart." - Native American Proverb

                  P 2 Replies Last reply
                  0
                  • D David Crow

                    univega_r304 wrote:

                    If you want to test this you can do do very easily by going to this link: http://www.codeproject.com/com/webbrowser.asp\[^\] This is basically something similar to what I have. Just edit the code, change the default site if you wish and add the event for the NewWindow3 compile and have at it to see what you can find...

                    I already had an application that uses this control, but for some reason it does not support the NewWindow3 event. What version of shdocvw.dll do you have? Mine is 6.0.2900.2937.


                    "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                    "Judge not by the eye but by the heart." - Native American Proverb

                    P Offline
                    P Offline
                    Paul Groetzner
                    wrote on last edited by
                    #19

                    Unless it's on mulitple locations on my drive the version I have appears to be older... I have 6.0.2900.2919. According to the article on MSDN: NewWindow3 is available only in Microsoft Windows XP Service Pack 2 (SP2) or later. So if you have that, it should work... FYI, after messing around a bit and not getting anywhere I put the code back that was showing me the proper URL in the debugger stopped working again. Same code, but bad results. I have't been able to get it to reproduce the proper URL in the debugger since.:mad:

                    1 Reply Last reply
                    0
                    • D David Crow

                      univega_r304 wrote:

                      If you want to test this you can do do very easily by going to this link: http://www.codeproject.com/com/webbrowser.asp\[^\] This is basically something similar to what I have. Just edit the code, change the default site if you wish and add the event for the NewWindow3 compile and have at it to see what you can find...

                      I already had an application that uses this control, but for some reason it does not support the NewWindow3 event. What version of shdocvw.dll do you have? Mine is 6.0.2900.2937.


                      "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                      "Judge not by the eye but by the heart." - Native American Proverb

                      P Offline
                      P Offline
                      Paul Groetzner
                      wrote on last edited by
                      #20

                      Would you believe I *FINALLY* got it working? Here's the code to make it work.... ON_EVENT(CLoadWebSite, IDC_EXPLORER, 273 /* NewWindow3 */, OnNewWindow3Explorer1, VTS_DISPATCH VTS_PBOOL VTS_BSTR VTS_BSTR VTS_BSTR) void CLoadWebSite::OnNewWindow3Explorer1(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel, BSTR Flags, BSTR URLContext, BSTR URL) { CString strURL; // capture URL of any link clicked that would attempt to open in a new window if (URL != NULL) strURL = (LPCTSTR)URL; *Cancel = TRUE; // prevent IE from spawning Browser.Navigate(strURL,NULL,NULL,NULL,NULL); // loads resulting URL into the web browser control instead of a spawned IE window }

                      D 1 Reply Last reply
                      0
                      • P Paul Groetzner

                        Would you believe I *FINALLY* got it working? Here's the code to make it work.... ON_EVENT(CLoadWebSite, IDC_EXPLORER, 273 /* NewWindow3 */, OnNewWindow3Explorer1, VTS_DISPATCH VTS_PBOOL VTS_BSTR VTS_BSTR VTS_BSTR) void CLoadWebSite::OnNewWindow3Explorer1(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel, BSTR Flags, BSTR URLContext, BSTR URL) { CString strURL; // capture URL of any link clicked that would attempt to open in a new window if (URL != NULL) strURL = (LPCTSTR)URL; *Cancel = TRUE; // prevent IE from spawning Browser.Navigate(strURL,NULL,NULL,NULL,NULL); // loads resulting URL into the web browser control instead of a spawned IE window }

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #21

                        univega_r304 wrote:

                        strURL = (LPCTSTR)URL;

                        This makes sense since a BSTR is really a type of char*. Could you have also done:

                        strURL = URL;

                        as the assignment operator should handle the typecast automatically? If not, oh well.


                        "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                        "Judge not by the eye but by the heart." - Native American Proverb

                        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