Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Sun, 3 Feb 2008 20:59:57 +1000,    group: microsoft.public.inetsdk.programming.webbrowser_ctl        back       


Open in the same window   
Hi all,

I am using an embedded iWebBrowser2 control and I want to keep *all* 
activity in that same browser window, ie I do not want IE6 or 7 to be opened 
when code like the following is executed:

var win;
win=window.open(http://server/thePage.html);

I have implemented DWebBrowser2 events and am intercepting the NewWindow2 
event to try and modify the behaviour.

According to the (very sparse and poorly written) documentation, I should be 
able to provide the target WebBrowser iDispatch object by updating 
pDispParams->rgvarg[1].ppdispVal in the WebEvents Invoke function. When I do 
this, I get a script error on the page.

Having re-read the documentation, I am now wondering if it will only work if 
I provide an iDispatch for a second Webbrowser and not the current one.

Has anyone got any suggestions or even better sample code to ensure pages 
are always opened in the same window. I am using Plain C code
Thanks
Leslie.
date: Sun, 3 Feb 2008 20:59:57 +1000   author:   Leslie Milburn

Re: Open in the same window   
"Leslie Milburn"  wrote in message
news:%23nxmvPlZIHA.2268@TK2MSFTNGP02.phx.gbl
> I am using an embedded iWebBrowser2 control and I want to keep *all*
> activity in that same browser window, ie I do not want IE6 or 7 to be
> opened when code like the following is executed:
>
> var win;
> win=window.open(http://server/thePage.html);
>
> I have implemented DWebBrowser2 events and am intercepting the
> NewWindow2 event to try and modify the behaviour.
>
> According to the (very sparse and poorly written) documentation, I
> should be able to provide the target WebBrowser iDispatch object by
> updating pDispParams->rgvarg[1].ppdispVal in the WebEvents Invoke
> function. When I do this, I get a script error on the page.

NewWindow2 approach does work. You are doing something wrong. See KB 
article KB184876 "How To Use the WebBrowser Control NewWindow2 Event"
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Sun, 3 Feb 2008 09:45:06 -0500   author:   Igor Tandetnik

Re: Open in the same window   
"Igor Tandetnik"  wrote in message 
news:OGqFgNnZIHA.4140@TK2MSFTNGP04.phx.gbl...
> "Leslie Milburn"  wrote in message
> news:%23nxmvPlZIHA.2268@TK2MSFTNGP02.phx.gbl
>> I am using an embedded iWebBrowser2 control and I want to keep *all*
>> activity in that same browser window, ie I do not want IE6 or 7 to be
>> opened when code like the following is executed:
>>
>> var win;
>> win=window.open(http://server/thePage.html);
>>
>> I have implemented DWebBrowser2 events and am intercepting the
>> NewWindow2 event to try and modify the behaviour.
>>
>> According to the (very sparse and poorly written) documentation, I
>> should be able to provide the target WebBrowser iDispatch object by
>> updating pDispParams->rgvarg[1].ppdispVal in the WebEvents Invoke
>> function. When I do this, I get a script error on the page.
>
> NewWindow2 approach does work. You are doing something wrong. See KB 
> article KB184876 "How To Use the WebBrowser Control NewWindow2 Event"
> -- 

Hi Igor,

Thanks for the response. I would not be surprised if I am doing it wrong. 
The code is below, "get_Application Success" is displayed, so hopefully you 
can see something else I have missed. The error message in the browser I get 
is "A runtime error has occurred. Do you wish to debug ? Line: 10 Error: 
Unspecified Error".

void NewWindow2(VIEW                          View,
                                VWFIELD                  HostID,
                                IDispatch                 **ppDisp,
                                VARIANT_BOOL   *Cancel)
{
  IWebBrowser2 *webBrowser2 = NULLPTR;

   /* Get the browser's IWebBrowser2 object. */
  if (vwGetWebPtrs(View, HostID, &webBrowser2, 0) == S_OK)
 {
       HRESULT  rc;

                /* Get the IDispatch Interface. */
        rc = webBrowser2->lpVtbl->get_Application(webBrowser2, ppDisp);

       if (rc != S_OK)
      {
             if (rc == E_FAIL)
                   cm9util_Msg("New Window", "get_Application E_FAIL");

             else if (rc == E_NOINTERFACE)
                   cm9util_Msg("New Window", "get_Application 
E_NOINTERFACE");

             else
                   cm9util_Msg("New Window", "get_Application Error");
       }
       else
             cm9util_Msg("New Window", "get_Application Success");
   }
}


Thanks
Leslie.
date: Mon, 4 Feb 2008 02:04:56 +1000   author:   Leslie Milburn

Re: Open in the same window   
"Leslie Milburn"  wrote in message
news:OWPRR6nZIHA.984@TK2MSFTNGP06.phx.gbl
> Thanks for the response. I would not be surprised if I am doing it
> wrong. The code is below, "get_Application Success" is displayed, so
> hopefully you can see something else I have missed. The error message
> in the browser I get is "A runtime error has occurred. Do you wish to
> debug ? Line: 10 Error: Unspecified Error".
>
> void NewWindow2(VIEW                          View,
>                                VWFIELD                  HostID,
>                                IDispatch                 **ppDisp,
>                                VARIANT_BOOL   *Cancel)

This doesn't look like a correct signature for NewWindow2 event handler. 
What's VIEW and VWFIELD? How is this function called?

> {
>   /* Get the browser's IWebBrowser2 object. */
>  if (vwGetWebPtrs(View, HostID, &webBrowser2, 0) == S_OK)

You seem to be trying to navigate the same browser that fired NewWindow2 
event in the first place. That's not going to work. The documentation 
for NewWindow2 clearly states that ppDisp should be set to refer to a 
new, unnavigated WebBrowser instance.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Sun, 3 Feb 2008 19:42:07 -0500   author:   Igor Tandetnik

Re: Open in the same window   
Hi Igor,

Answers inline......

"Igor Tandetnik"  wrote in message 
news:OIDQIbsZIHA.5980@TK2MSFTNGP04.phx.gbl...
> "Leslie Milburn"  wrote in message
> news:OWPRR6nZIHA.984@TK2MSFTNGP06.phx.gbl
>>
>> void NewWindow2(VIEW                          View,
>>                                VWFIELD                  HostID,
>>                                IDispatch                 **ppDisp,
>>                                VARIANT_BOOL   *Cancel)
>
> This doesn't look like a correct signature for NewWindow2 event handler. 
> What's VIEW and VWFIELD? How is this function called?

I call NewWindow2() from my Invoke Function, the View and HostID are simply 
additonal parameters I provide to retrieve the iWebBrowser2 and other 
interfaces.

>> {
>>   /* Get the browser's IWebBrowser2 object. */
>>  if (vwGetWebPtrs(View, HostID, &webBrowser2, 0) == S_OK)
>
> You seem to be trying to navigate the same browser that fired NewWindow2 
> event in the first place. That's not going to work. The documentation for 
> NewWindow2 clearly states that ppDisp should be set to refer to a new, 
> unnavigated WebBrowser instance.

Thats exactly what I am trying to do - open the new page in the *same* 
window that fired the event (as per the subject line). So what you are 
saying is that for some lame reason this method will not work unless I 
create a second Browser window. What a waste of resources !!

Anyway, I have discovered that another event is available to me, namely 
NewWindow3 which looks like it will be a better option. The only worry is 
that I have read it is only available on XP SP2 (and I guess Vista). Is that 
correct, or is it actually tied to the version of Internet Explorer that is 
installed ie. If Windows 2000 updates to IE7 will this event be available ? 
Is there any documentation which confirms this  ??

Thansk for your help
Leslie.
date: Mon, 4 Feb 2008 15:03:25 +1000   author:   Leslie Milburn

Re: Open in the same window   
"Leslie Milburn"  wrote in message
news:%23PKkLtuZIHA.5976@TK2MSFTNGP05.phx.gbl
> Anyway, I have discovered that another event is available to me,
> namely NewWindow3 which looks like it will be a better option. The
> only worry is that I have read it is only available on XP SP2 (and I
> guess Vista). Is that correct

That is correct.

> or is it actually tied to the version
> of Internet Explorer that is installed ie. If Windows 2000 updates to
> IE7 will this event be available ?

IE7 cannot be installed on Win2K:

http://www.microsoft.com/windows/downloads/ie/sysreq.mspx

-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Mon, 4 Feb 2008 00:49:00 -0500   author:   Igor Tandetnik

Re: Open in the same window   
"Igor Tandetnik"  wrote in message 
news:OvXCnGvZIHA.4440@TK2MSFTNGP06.phx.gbl...
> "Leslie Milburn"  wrote in message
> news:%23PKkLtuZIHA.5976@TK2MSFTNGP05.phx.gbl
>> Anyway, I have discovered that another event is available to me,
>> namely NewWindow3 which looks like it will be a better option. The
>> only worry is that I have read it is only available on XP SP2 (and I
>> guess Vista). Is that correct
>
> That is correct.
>
>> or is it actually tied to the version
>> of Internet Explorer that is installed ie. If Windows 2000 updates to
>> IE7 will this event be available ?
>
> IE7 cannot be installed on Win2K:
>
> http://www.microsoft.com/windows/downloads/ie/sysreq.mspx
>
> -- 
> With best wishes,
>    Igor Tandetnik
>

Hi Igor,

I have decided that NewWindow3 is the easiest option for me as going 
forward, I will only be supporting XP upwards anyway.

Thanks for your help.
date: Mon, 4 Feb 2008 16:14:27 +1000   author:   Leslie Milburn

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us