 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Mark Jacobs Guest
|
Posted: Mon Jan 08, 2007 4:01 am Post subject: CppWebBrowser OnNewWindow2 event handling |
|
|
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 |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Mon Jan 08, 2007 4:38 am Post subject: Re: CppWebBrowser OnNewWindow2 event handling |
|
|
Mark Jacobs wrote:
| Quote: | 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. |
|
| Back to top |
|
 |
Mark Jacobs Guest
|
Posted: Mon Jan 08, 2007 4:49 am Post subject: Re: CppWebBrowser OnNewWindow2 event handling |
|
|
"Hans Galema" <notused (AT) notused (DOT) nl> wrote in message
news:45a176de$1 (AT) newsgroups (DOT) borland.com...
| Quote: | 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 |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Mon Jan 08, 2007 6:20 pm Post subject: Re: CppWebBrowser OnNewWindow2 event handling |
|
|
Mark Jacobs wrote:
| Quote: | ...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. |
|
| Back to top |
|
 |
Mark Jacobs Guest
|
Posted: Mon Jan 08, 2007 8:06 pm Post subject: Re: CppWebBrowser OnNewWindow2 event handling |
|
|
Hans Galema wrote:
| Quote: | 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 |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Mon Jan 08, 2007 8:16 pm Post subject: Re: CppWebBrowser OnNewWindow2 event handling |
|
|
Mark Jacobs wrote:
| Quote: | Hans Galema wrote:
By the way: You are not generating the html yourself I suppose.
|
???
Hans. |
|
| Back to top |
|
 |
Mark Jacobs Guest
|
Posted: Mon Jan 08, 2007 8:28 pm Post subject: Re: CppWebBrowser OnNewWindow2 event handling |
|
|
Hans Galema wrote:
| Quote: | 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 |
|
| Back to top |
|
 |
|
|
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
|
|