cancel
Showing results for 
Search instead for 
Did you mean: 

Integrating web browser links/urls and PB objects

Former Member
0 Kudos

I would like to use PB 12 Classic to display an internal website and when a link on the web page is clicked it fires an action in PB that I can then respond to (and consume) inside the classic application.  I know that the web browser can be embedded inside PB using OLE objects.  Is there a way for PB to interact with the browser?

Example:

A Web Page displays a list of products.  Each product has a link to "Select".  When the "Select" link is clicked in the browser, the PB application is "aware" and can retrieve detail information in a different window (Sheet) about that product.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Matt,

I wrote a PowerBuilder application that does almost exactly what you describe (Mafia Manager), however it was accomplished using the web browser OLE object that you do not want to use.  I may have misunderstood and you DO not mind using the OLE object as long as you can fire PB code from actions within the OLE object and the answer is, yes you can and it isn't too difficult.

You can fire PB code based on actions in the web page being hosted in the OLE object using the InternetData function, which exists in a descendant of the InternetResult class and is called automatically by the context when the user does something (e.g. clicks a url) in the current web page.

Look at InternetResult and Inet classes, and the GetUrl and InternetData functions to get you on the right track. If I remember right there are other events/functions that you can use to determine what the current URL is and what action was taken. IF you need me to dig up my code from that program send me an email and I'll do it.

Hope this helps.

Rich Bianco

http://www.displacedguy.com

PowerBuilder, .NET Blog

Former Member
0 Kudos


Thanks Rich.  This pointed me in the right direction.  I believe I can use the BeforeNavigate2 event on the OLE object and catch the web call.  Then I can either allow the browser to continue to the address or set "cancel = true" and then fire off a different event to interact with my classic PB Windows.

Former Member
0 Kudos

You can also go the other way around by triggering javascript functions from PowerScript.

ole_1.Object.Document.ParentWindow.ExecScript("javascript:funcname('arg');")

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Matt;

   You can use an OLE container and insert the IE active-X (MS Web Browser Control) from the O/S into your PB application. Then, you can direct the IE control to your specific web location by setting the "LocationURL" property.

HTH

Regards ... Chris

Former Member
0 Kudos

How does that allow code in the displayed web page trigger PowerBuilder code?

The simplest way to do this in PowerBuilder is to have the link execute this Javascript:

window.status="cmd:Some text";

This will trigger the statustextchange event which has the text as an argument. You can then have code in the statustextchange event perform whatever it needs to do using the passed text as input.

This event will be also be triggered when the page loads and if the mouse passes over a link. You'll have to have something at the beginning of the text so that you can identify it as a command to process. In the example above I have "cmd:" at the begining of the string.

Former Member
0 Kudos

Thanks Roland.  I will take a look at this.