BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TCppWebBrowser OnNewWindow2 event

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Patrick Jamieson
Guest





PostPosted: Tue May 17, 2005 1:58 am    Post subject: TCppWebBrowser OnNewWindow2 event Reply with quote



I am using a TCppWebBrowser component to access the web. In some pages,
the links require the target document to appear in a new window.
Instead of displaying the page in the TCppWebBrowser, or a new copy of
it, a new copy of Internet Explorer itself is launched to display the page.

I can block Internet Explorer from opening with the following code:


void __fastcall TBrowserFm::DOTBrwsrNewWindow2(TObject *Sender,
LPDISPATCH *ppDisp, TOLEBOOL *Cancel)
{
Cancel->operator =(true);
}


After blocking Internet Explorer from opening, I would like to display
the page in the TCppWebBrowser. I assume that the URL for the page that
Internet Explorer was going to navigate to is contained in *ppDisp.

Can someone please show me how to extract the URL so that I can pass it
to the TCppWebBrowser.

Thanks,

Patrick J.
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue May 17, 2005 7:44 am    Post subject: Re: TCppWebBrowser OnNewWindow2 event Reply with quote




"Patrick Jamieson" <pdj42591 (AT) earthlink (DOT) net> wrote


Quote:
Cancel->operator =(true);

That should be the following instead:

*Cancel = true;

Quote:
I assume that the URL for the page that Internet Explorer was
going to navigate to is contained in *ppDisp.

You assume incorrectly. ppDisp is initially unassigned. The purpose of the
OnNewWindow2 event is to give you the chance to provide your own web browser
interface to ppDisp for the new URL to then be displayed in. If you do not
provide your own interface, and do not cancel the operation, only then does
the browser create its own window.

If you want to know which URL is being navigated to, you need to use the
OnBeforeNavigate2 event.


Gambit



Back to top
Patrick Jamieson
Guest





PostPosted: Tue May 17, 2005 1:26 pm    Post subject: Re: TCppWebBrowser OnNewWindow2 event Reply with quote



Remy Lebeau (TeamB) wrote:

Quote:
"Patrick Jamieson" wrote in message news:42894fde$1 (AT) newsgroups (DOT) borland.com...


I assume that the URL for the page that Internet Explorer was
going to navigate to is contained in *ppDisp.


You assume incorrectly. ppDisp is initially unassigned. The purpose of the
OnNewWindow2 event is to give you the chance to provide your own web browser
interface to ppDisp for the new URL to then be displayed in. If you do not
provide your own interface, and do not cancel the operation, only then does
the browser create its own window.

If you want to know which URL is being navigated to, you need to use the
OnBeforeNavigate2 event.


Gambit



Thanks for the correct syntax for updating Cancel.


I was already using the OnBeforeNavigate2 event (see below), but the
OnNewWindow2 event is firing before the OnBeforeNavigate2 event.


void __fastcall TBrowserFm::DOTBrwsrBeforeNavigate2(TObject *Sender,
LDISPATCH pDisp, TVariant *URL, TVariant *Flags, TVariant
*TargetFrameName, TVariant *PostData, TVariant *Headers, TOLEBOOL *Cancel)
{
String url = *URL;

...

}

After I stop Internet Explorer from opening, that's the end of the line.
OnBeforeNavigate2 is not firing; the original calling page is
displayed in my CppWebBrowser, not the target page.

Can you show me how to provide the interface to my browser to ppDisp.


Thanks,

Patrick J.

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue May 17, 2005 4:38 pm    Post subject: Re: TCppWebBrowser OnNewWindow2 event Reply with quote


"Patrick Jamieson" <pdj42591 (AT) earthlink (DOT) net> wrote


Quote:
I was already using the OnBeforeNavigate2 event (see below), but
the OnNewWindow2 event is firing before the OnBeforeNavigate2
event.

Yes, because the browser needs a window available for the URL before it can
actually navigate to the URL. There is no point in navigating if there is
nothing to display.

Quote:
Can you show me how to provide the interface to my browser to ppDisp.

Simple cancel the new window. TCppWebBrowser will then try to display the
new URL in the current window that already exists.


Gambit



Back to top
Patrick Jamieson
Guest





PostPosted: Wed May 18, 2005 2:50 am    Post subject: Re: TCppWebBrowser OnNewWindow2 event Reply with quote

Remy Lebeau (TeamB) wrote:
Quote:
"Patrick Jamieson" wrote in message news:4289f0f2$1 (AT) newsgroups (DOT) borland.com...


Can you show me how to provide the interface to my browser to ppDisp.


Simple cancel the new window. TCppWebBrowser will then try to display the
new URL in the current window that already exists.


Gambit




I'm getting closer, but not there yet.


With the following OnNewBrowser2 event handler, I can view pages that require a
new window in a new CppWebBrowser window, instead of a new Internet Explorer window:

void __fastcall TBrowserFm::DOTBrwsrNewWindow2(TObject *Sender,
LPDISPATCH *ppDisp, TOLEBOOL *Cancel)
{
TBrowserFm *pBrowserFm = new TBrowserFm(this);

pBrowserFm->Visible = true;

*ppDisp = pBrowserFm->DOTBrwsr->Application;
}


However, I would prefer to view the target page in the same CppBrowser window as
the source page. I have tried the following event handler without success.

void __fastcall TBrowserFm::DOTBrwsrNewWindow2(TObject *Sender,
LPDISPATCH *ppDisp, TOLEBOOL *Cancel)
{
*ppDisp = DOTBrwsr->Application;
}

Nothing seems to happen after the assignment to ppDisp. The OnBeforeNavigate2
event is not triggered, and the original CppWebBrowser with the source page are
still on the screen.


Have also tried the following without success:

void __fastcall TBrowserFm::DOTBrwsrNewWindow2(TObject *Sender,
LPDISPATCH *ppDisp, TOLEBOOL *Cancel)
{
*Cancel = true;
}

Again, nothing seems to happen after the assignment to Cancel. The
OnBeforeNavigate2 event is not triggered, and the original CppWebBrowser with
the source page are still on the screen.


Can anyone tell me why the last two handlers are not working as advertised, and
what I have to do to get them working. All the documentation and previous posts
I've read on this issue suggest that these handlers will display pages without
launching a new browser window.


Thanks,

Patrick J.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.