🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
7 messages
7 total messages Started by Mark Jacobs Sun, 07 Jan 2007 22:01
CppWebBrowser OnNewWindow2 event handling
#474
Author: Mark Jacobs
Date: Sun, 07 Jan 2007 22:01
19 lines
1551 bytes
I have the following code to handle "pop-ups" and valid new window launches 
inside CppWebBrowser's OnNewWindow2 event :-

//---------------------------------------------------------------------------
void __fastcall TForm1::CppWebBrowser1NewWindow2(TObject *Sender,LPDISPATCH 
*ppDisp,TOLEBOOL *Cancel)
{
  *Cancel=true;
  if (CppWebBrowser1->ReadyState<3) { ppDisp=NULL; return;}
  // Some code to launch the URL in a new window...
}
//---------------------------------------------------------------------------

The problem I am having is deriving the URL that will be launched, if I do 
allow the pop-up. How do I derive this from the arguments handed to the 
event handler?
-- 
Mark Jacobs
www.jacobsm.com 
Re: CppWebBrowser OnNewWindow2 event handling
#475
Author: Hans Galema
Date: Sun, 07 Jan 2007 22:38
16 lines
1520 bytes
Mark Jacobs wrote:

> The problem I am having is deriving the URL that will be launched, if I do 
> allow the pop-up. How do I derive this from the arguments handed to the 
> event handler?

You do not need to know the URL as all you have to provide is a pointer
to an instance of TCppWebBrowser that should display the new page.

So you could instantiate a new form (containing a TCppWebBrowser) here

    TForm1 *Form1 = new TForm1(0,false,0,0);

    *ppDisp = Form1->CppWebBrowser1->Application;

Hans.
Re: CppWebBrowser OnNewWindow2 event handling
#476
Author: Mark Jacobs
Date: Sun, 07 Jan 2007 22:49
17 lines
1802 bytes
"Hans Galema" <notused@notused.nl> wrote in message 
news:45a176de$1@newsgroups.borland.com...
> You do not need to know the URL as all you have to provide is a pointer
> to an instance of TCppWebBrowser that should display the new page.
> So you could instantiate a new form (containing a TCppWebBrowser) here
>    TForm1 *Form1 = new TForm1(0,false,0,0);
>    *ppDisp = Form1->CppWebBrowser1->Application;

Thanks, Hans. However, I am not letting the pop-up launch normally (for 
several reasons) in another IE instance. I want to control the app launching 
the URL. That is why I need the URL. I have seen a solution that invovles 
letting the instance start, but grab the URL and cancel the navigation 
inside the OnBeforeNavigate event, but I don't like that solution. Is there 
any way of getting the intended URL from the LPDISPATCH parameter?
-- 
Mark Jacobs
www.jacobsm.com 
Re: CppWebBrowser OnNewWindow2 event handling
#478
Author: Hans Galema
Date: Mon, 08 Jan 2007 12:20
25 lines
2102 bytes
Mark Jacobs wrote:

> ...I want to control the app launching 
> the URL. That is why I need the URL. I have seen a solution that invovles 
> letting the instance start, but grab the URL and cancel the navigation 
> inside the OnBeforeNavigate event, but I don't like that solution. Is there 
> any way of getting the intended URL from the LPDISPATCH parameter?

At the moment I don't know. What I found was a thread with Subject:
Getting Target in NewWindow2

<quote>
Another approach I've tried is capturing DWebBrowserEvent::NewWindow
instead. Since that handler, unlike NewWindow2, gets the target, as
well as the URL, I could just do cancel the request and create the
window myself. But that breaks the window relations within the
scripting engine, so it was a less than satisfactory solution.
</quote>

Now NewWindow is not public. But maybe you can make a class that
makes it public.

By the way: You are not generating the html yourself I suppose.

Hans.
Re: CppWebBrowser OnNewWindow2 event handling
#482
Author: Mark Jacobs
Date: Mon, 08 Jan 2007 14:06
27 lines
2163 bytes
Hans Galema wrote:
> <quote>
> Another approach I've tried is capturing DWebBrowserEvent::NewWindow
> instead. Since that handler, unlike NewWindow2, gets the target, as
> well as the URL, I could just do cancel the request and create the
> window myself. But that breaks the window relations within the
> scripting engine, so it was a less than satisfactory solution.
> </quote>
>
> Now NewWindow is not public. But maybe you can make a class that
> makes it public.
>
> By the way: You are not generating the html yourself I suppose.

Again, many thanks. Some good ideas here. But it does seem as if M$ have 
sabotaged a really useful pop-up blocker event, and replaced it with something 
much harder to work with!

I have dabbled with the header file shdocvw_ocx.h but I cannot get the 
OnNewWindow event from TCppWebBrowser_V1 into the TCppWebBrowser class 
definition. Any ideas?
-- 

-
Mark Jacobs
DK Computing
http://www.dkcomputing.co.uk 
Re: CppWebBrowser OnNewWindow2 event handling
#484
Author: Hans Galema
Date: Mon, 08 Jan 2007 14:16
8 lines
1322 bytes
Mark Jacobs wrote:
> Hans Galema wrote:

>> By the way: You are not generating the html yourself I suppose.

???

Hans.
Re: CppWebBrowser OnNewWindow2 event handling
#483
Author: Mark Jacobs
Date: Mon, 08 Jan 2007 14:28
15 lines
1577 bytes
Hans Galema wrote:
> Mark Jacobs wrote:
>> Hans Galema wrote:
> 
>>> By the way: You are not generating the html yourself I suppose.
> 
> ???

No, it is just a simple web browser.
-- 
 
-
Mark Jacobs
DK Computing
http://www.dkcomputing.co.uk
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads