WebBrowser ActiveX control

WebBrowser ActiveX control

Postby Brian Hays » Sat Jul 15, 2006 7:17 pm

I'm pasting here a private msg I sent to Antonio so our discussion can be shared. If anyone else has customized the Shell.InternetExplorer control, I'd love to hear your input.

After much searching in vain on MSDN for docs, Antonio helped me realize the magic keyword is WebBrowser. Here's the link to their docs:

http://msdn.microsoft.com/library/defau ... rowser.asp

Antonio also shared with me his trick to use the Word VBA editor to use their object inspector. What I had not done before is use the Form designer to access all the MS controls; that's where you'll find properties for "Microsoft Web Browser" or something similar. Its name changes with different versions and it appears alphabetically in different places :-(

Here are my hopes for more features:
Meanwhile, there's one Event handler that doesn't seem to be working right. If I can get that, I can use html as a major GUI presentation for all kinds of things :-)
The idea is: How to have the App take actions based on clicks in the webBrowser.

Since BeforeNavigate2() provides the target URL, I could inspect that and do any desired action, including according to the MS docs cancel that navigation. But the trace of params for it shows 7 blank lines and then a number (I presume a pointer), then another 7 blank lines.
Event: BeforeNavigate2
Params:






1798272
...

The MS docs indicate there should be 7 args, and the second one is the URL
Private Sub object_BeforeNavigate2( _
ByVal pDisp As Object, _
ByRef Url As Variant, _
ByRef Flags As Variant, _
ByRef TargetFrameName As Variant, _
ByRef PostData As Variant, _
ByRef Headers As Variant, _
ByRef Cancel As Boolean)

I understand the Variants can make things tricky for a generic routine in your C code to capture, but if there's a way your (or I) could get these accurately it would help a lot.
But then there's the tricky part :-)
The 7th arg "Cancel" is intended to be used "ByRef" to return True to cancel the navigation.
Is there any chance of that value ever being returned back from the PRG level through the C structures to Windows?

What I envision for the best design is to inherit from TActiveX to create TWebBrowser and try to handle specifics there. Do you have any mechanism, as VB does, to route specific Events to a specific PRG method?
Can I help make that happen?

Thanks so much for all your work,

--
Brian Hays
-BH
Brian Hays
 
Posts: 20
Joined: Fri Oct 14, 2005 7:56 am

Postby Antonio Linares » Sun Jul 16, 2006 12:42 am

Brian,

We were not properly routing the events parameters supplied by reference. We are working on it right now.

We will keep you posted about our progress.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Jul 16, 2006 1:46 am

Brian,

>
But the trace of params for it shows 7 blank lines and then a number (I presume a pointer), then another 7 blank lines.
>

Fixed. It was a bug: we were duplicating the amount of received parameters. Now just 7 params arrive :)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Jul 16, 2006 1:49 am

Brian,

See how it looks now:
Event: BeforeNavigate2
Params:
1429328
http://www.google.es/imghp?hl=es&tab=wi&q=
64

Still working on it :)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Jul 16, 2006 9:37 am

Brian,

> Do you have any mechanism, as VB does, to route specific Events to a specific PRG method?

If you inherit from Class TActiveX, all you have to do is modify the Method OnEvent(), and directly call the PRG method that you want from there.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Jul 16, 2006 2:20 pm

Brian,

Is fully working including the Cancel behavior :)

We are going to provide you new libs for your review, thanks.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Brian Hays » Sun Jul 16, 2006 3:07 pm

Wow! Thanks for the incredibly fast turnaround (on a weekend no less! :-)
-BH
Brian Hays
 
Posts: 20
Joined: Fri Oct 14, 2005 7:56 am

Postby Antonio Linares » Sun Jul 16, 2006 5:23 pm

Brian,

We need to know if you need it for Borland or xHB. Thanks,
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Maurilio Viana » Mon Jul 17, 2006 11:57 am

Antonio, can you post a little sample with exe?

Regards
Maurilio
User avatar
Maurilio Viana
 
Posts: 252
Joined: Tue Oct 25, 2005 2:48 pm
Location: Garça/Garza/Heron City - Brazil

Postby Brian Hays » Mon Jul 17, 2006 4:05 pm

Maurilio:

We're currently working with the webexp.prg in Samples.
You can now add something like this to the EventInfo function:
if valType(event) == "C" .AND. event == "BeforeNavigate2"

#define BEFORE_NAV_ARGS_URL 2
#define BEFORE_NAV_ARGS_TargetFrameName 4
#define BEFORE_NAV_ARGS_CANCEL 7

if msgYesNo("User attempted to navigate to "+ CRLF+;
aParams[ BEFORE_NAV_ARGS_URL ]+ CRLF+ ;
"Do you want to STOP navigation?", ;
"BeforeNavigate2")

oActiveX:Do( "Stop")
SetEventParam( pParams, BEFORE_NAV_ARGS_CANCEL, .t. )
endif
endif

It's working great with a straightforward startup page, but if it has frames then using the msgYesNo dialog causes a delay that makes the startup page fail to finish painting. Currently this test will ask about any kind of navigation due to scripts etc. Antonio's looking at whether we can isolate this kind of frame activity (I'm using www.refdesk.com as a "home" page, which does a lot of stuff at startup).

I'll be sure to post the full example when it's done.
-BH
Brian Hays
 
Posts: 20
Joined: Fri Oct 14, 2005 7:56 am

Postby Maurilio Viana » Mon Jul 17, 2006 6:26 pm

Thanks a lot, Brian!

Regards
Maurilio
User avatar
Maurilio Viana
 
Posts: 252
Joined: Tue Oct 25, 2005 2:48 pm
Location: Garça/Garza/Heron City - Brazil

Postby Brian Hays » Mon Jul 17, 2006 10:11 pm

Here's the link to my test and small wrapper class for the WebBrowser:

http://hyperupload.com/download/024244d ... w.zip.html

Now you can do:
oBrowser = TWebBrowser():New( oWnd )
oBrowser:Navigate( "http://www.fivetechsoft.com" )

Notice you can also browse local folders like:
oBrowser:Navigate( "C:\" )
Let me know if you figure out a nice way to handle ShowDetails instead of icons, etc.

It is a partial work, ready for additional ideas :-)
Since it's based on a Fivewin sample, I have no rights to any of it and offer no warranties, use at your own risk, etc.

It will be useful to find a way to avoid processing the BeforeNavigate Event until after the desired starting page has stabilized. Just setting a static flag on ON INIT doesn't work; the navigation hasn't happened yet
and the event is still fired later. SysWait(nSecs) is always troublesome. So it's probably necessary to handle this specifically for each application.
I still have never seen the TargetFrameName argument filled with anything; hopefully that will eventually help with some complcations raised by complex pages.

The main point of the exercise:
By trapping specific hyperlinks, it may be possible to design a web interface (perhaps local html pages) and use this trick to drive the local application from a GUI done in html !
-BH
Brian Hays
 
Posts: 20
Joined: Fri Oct 14, 2005 7:56 am

Postby Antonio Linares » Tue Jul 18, 2006 12:12 am

Brian,

> I still have never seen the TargetFrameName argument filled with anything

It has the same type as Url param, and we properly receive Url, right ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Ari » Wed Jul 19, 2006 5:32 pm

tentei rodar o webbrow deu este erro

Application
===========
Path and name: C:\fwh27\SAMPLES\webbrow.exe (32 bits)
Size: 1,061,376 bytes
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 07/19/06, 14:30:06
Error description: Error BASE/1081 Argument error: +
Args:
[ 1] = C Server or User attempted to navigate to

[ 2] = U

Stack Calls
===========
Called from: => TWEBBROWSER:ONBEFORENAVIGATE(135)
Called from: => TWEBBROWSER:ONEVENT(102)
Called from: => ACTXINVOKE(0)
Called from: => TACTIVEX:DO(0)
Called from: webbrow.prg => __EVAL(0)
Called from: => TWEBBROWSER:NAVIGATE(0)
Called from: webbrow.prg => MAIN(21)

System
======
CPU type: AMD Sempron(tm) 2400+ 1666 Mhz
Hardware memory: 96 megs

Free System resources: 90 %
GDI resources: 90 %
User resources: 90 %

Compiler version: Harbour Alpha build 46.2 Intl. (Flex)
Windows version: 5.1, Build 2600

Windows total applications running: 25
1 TF_FloatingLangBar_WndTitle
2 CiceroUIWndFrame
3 SysFader
4 Menu Iniciar
5 NetDDE Agent
6 FiveWin Web Browser Support
7 Prompt de comando (2)
8 www.FiveTechSoft.com :: View topic - WebBrowser ActiveX control - Microsoft Internet Explorer
9 Programmer's File Editor - [C:\fwh27\SAMPLES\webbrow.prg]
10 SAMPLES
11 Timer
12 Acrobat IEHelper
13 MCI command handling window
14 DDE Server Window
15 WOWExec
16 HiddenFaxWindow
17 Connections Tray
18 Medidor de energia
19 WinMySQLadmin 1.1
20 Interval Query Setup
21 Adding Database
22 WinMySQLadmin Quick Setup
23 WinMySQLadmin 1.0
24 MS_WebcheckMonitor
25 Program Manager

Variables in use
================
Procedure Type Value
==========================
TWEBBROWSER:ONBEFORENAVIGATE
Param 1: A Len: 14
Param 2: U
Local 1: O Class: TWEBBROWSER
Local 2: L .F.
Local 3: S
Local 4: U
Local 5: C "Server or User attempted to navigate to
"
Local 6: U
Local 7: S
Local 8: N 0
TWEBBROWSER:ONEVENT
Param 1: N 250
Param 2: A Len: 14
Local 1: U
Local 2: O Class: TWEBBROWSER
Local 3: N 8
Local 4: C "BeforeNavigate2"
Local 5: L .F.
ACTXINVOKE
Param 1: N 1374376
Param 2: C "Navigate"
Param 3: C "http://www.sisrev.com.br"
TACTIVEX:DO
Param 1: C "Navigate"
Param 2: C "http://www.sisrev.com.br"
Local 1: U
Local 2: U
Local 3: U
Local 4: O Class: TWEBBROWSER
Local 5: U
__EVAL
Param 1: O Class: TWEBBROWSER
Param 2: C "http://www.sisrev.com.br"
TWEBBROWSER:NAVIGATE
Param 1: C "http://www.sisrev.com.br"
MAIN
Local 1: O Class: TWINDOW
Local 2: O Class: TWEBBROWSER

Linked RDDs
===========
DBF
DBFFPT
DBFBLOB
DBFNTX

DataBases in use
================

Classes in use:
===============
1 HBCLASS
2 HBOBJECT
3 TWINDOW
4 TBRUSH
5 TFONT
6 TCONTROL
7 TACTIVEX
8 TWEBBROWSER
9 TREG32
10 ERROR

Memory Analysis
===============
104 Static variables

Dynamic memory consume:
Actual Value: 0 bytes
Highest Value: 0 bytes

User avatar
Ari
 
Posts: 228
Joined: Fri Feb 03, 2006 4:21 pm
Location: São Paulo, SP - Brazil

Postby Brian Hays » Wed Jul 19, 2006 5:45 pm

Ari:

I'm sorry, I just realized Antonio had sent me patched libs to finish testing this, and until those low level changes are available for everybody it won't work.
To be sure that's the problem, could you please trace the definition of CRLF and the array offsets that are concatenated and see which value is nil?
-BH
Brian Hays
 
Posts: 20
Joined: Fri Oct 14, 2005 7:56 am

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 64 guests