| Home | Previous Lesson: Course 3:: Session 29 :: Page 180 Next Lesson: Course 3:: Session 29 :: Page 200 |
Displaying HTML Pages using IE's ActiveX Automation Server from PowerBuilder's Window ActiveX Control
If you are running your window ActiveX control in Internet Explorer version 3.0 or greater, your application can communicate with the ActiveX automation server (your window ActiveX control is running in this server), and access its attributes and methods. For example, your window ActiveX control can ask the ActiveX automation server to go back/next/home page, refresh, display the specified HTML page from the same or a different web server or close the browser.
You need to instantiate
ContextInformation class and get a reference to the IwebBrowserApp (ActiveX automation server) by calling the GetHostObject() function with an uninitialized OLEObject variable. The following code demonstrates the same technique and displays the home page of http://www.applied-software.com site:// Object: cb_html_using_activeX CommandButton in w_context
window
// Library: product-web.pbl
// Event: Clicked
String ls_ShortName
ContextInformation lcx_Info
ContextKeyword lcx_EnvInfo
OLEObject lOLE
This.GetContextService(
"ContextInformation", lcx_Info )
lcx_Info.GetShortName( ls_ShortName )
// Check whether the context is
ActiveX control
If Left(Upper( ls_ShortName ),4) <> "PBRX" Then
MessageBox( "Show HTML Page", "Displaying HTML Page using
" + &
"ActiveX
Automation is available only in IE" )
Return 0
End If
lcx_Info.GetHostObject( lOLE )
If IsValid( lOLE ) Then
lOLE.Navigate( "http://www.applied-software.com",0,0,0)
Else
MessageBox( "Show HTML Page", "Error while initializing
ActiveX Object" )
Return 0
End If
Once we get the reference to IwebBrowserApp, you need to call Navigate() function with the
URL address. The following picture is the result of the above code:
| Home | Previous Lesson: Course 3:: Session 29 :: Page 180 Next Lesson: Course 3:: Session 29 :: Page 200 |