WebBrowser ActiveX control
-
- Posts: 20
- Joined: Fri Oct 14, 2005 7:56 am
WebBrowser ActiveX control
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
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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
See how it looks now:
Event: BeforeNavigate2
Params:
1429328
http://www.google.es/imghp?hl=es&tab=wi&q=
64
Still working on it
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
-
- Posts: 20
- Joined: Fri Oct 14, 2005 7:56 am
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Maurilio Viana
- Posts: 252
- Joined: Tue Oct 25, 2005 2:48 pm
- Location: Garça/Garza/Heron City - Brazil
- Contact:
-
- Posts: 20
- Joined: Fri Oct 14, 2005 7:56 am
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.
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
- Maurilio Viana
- Posts: 252
- Joined: Tue Oct 25, 2005 2:48 pm
- Location: Garça/Garza/Heron City - Brazil
- Contact:
-
- Posts: 20
- Joined: Fri Oct 14, 2005 7:56 am
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 !
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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
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
-
- Posts: 20
- Joined: Fri Oct 14, 2005 7:56 am
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?
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