Calling function from .NET WebBrowser

jamesmcfly

New Member
Hi everybody,

Currently I am developing a program using AppBuilder 10.2B and using OCX namely Microsoft WebBrowser. I am able to access and edit the attributes of the elements (titles, innerHTML of labels, etc.). However, I have not found a way to trigger a function within the WebBrowser. Is it possible from Progress to call a function in a WebBrowser (and possibly sending input parameter and receive output parameter from it?).
 

Osborne

Active Member
I am not sure if it is possible with the OCX WebBrowser but may be possible with the .NET WebBrowser:


This looks to have all kinds of options so hopefully one covers what you require.

A Progress example is here, and if you want to use an AppBuilder designed window then embed this on the .NET form:

 

jamesmcfly

New Member
I am not sure if it is possible with the OCX WebBrowser but may be possible with the .NET WebBrowser:


This looks to have all kinds of options so hopefully one covers what you require.

A Progress example is here, and if you want to use an AppBuilder designed window then embed this on the .NET form:

Thank you for your reply.

I found out that it is possible using this command: chBrowser:WebBrowser:Document:parentWindow:execScript(<command>), since the OCX WebBrowser is using old version of IE. For retrieving return parameter, I write the value in one label and let the progress application access that label to read the return value. I haven't done a lot of testing, but it maybe sufficient for what I need.
 

Cringer

ProgressTalk.com Moderator
Staff member
Not sure if this is of use, but Chrome is now available as an Open Source distributable called Chromium. I'm not sure how well it integrates with OE10, but it should be ok IMO.
Here's a webinar to get you started
 

Cringer

ProgressTalk.com Moderator
Staff member
Considering you can't do OO development in the AppBuilder, probably not.
 

Osborne

Active Member
As Cringer points out AppBuilder does not do OO so not possible directly.

However, if this is correct and Chromium can be used for Winforms then it may be possible:


So what you could try is embed an AppBuilder window onto a .NET form and then the AppBuilder and Chromium will exist in the same window:

 

Cecil

19+ years progress programming and still learning.
I had another crack at the MS WinView2 in the Developer Studio 11.7.11 (64bit). Using the following instructions:


But it shows nothing and no errors. Has anyone been successful in getting this to work?

This is the only code I have used.
Code:
/*------------------------------------------------------------------------------
     Purpose:
     Notes:
    ------------------------------------------------------------------------------*/
    @VisualDesigner.
    METHOD PRIVATE VOID button1_Click( INPUT sender AS System.Object, INPUT e AS System.EventArgs ):
        
        DEFINE VARIABLE obURI AS CLASS System.Uri NO-UNDO.
        
        obURI = NEW System.Uri("https://www.progress.com").
        
        webView21:Source = obURI.
        
                
        webView21:Visible = false.
        webView21:Visible = true.
        
        webView21:Source = obURI.
        
        RETURN.

    END METHOD.
 

Osborne

Active Member
I have never used this control but had a quick look - Progress 11.7.4 - and found the exact same problem. Tried the following as well but nothing:

Code:
webView21:Show().

Checking on the changed events and they never fired:

Code:
METHOD PRIVATE VOID webView21_LocationChanged( INPUT sender AS System.Object, INPUT e AS System.EventArgs ):
        MESSAGE "Location Changed." VIEW-AS ALERT-BOX.
    END METHOD.

    METHOD PRIVATE VOID webView21_NavigationCompleted( INPUT sender AS System.Object, INPUT e AS Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs ):
        MESSAGE "Navigation completed." VIEW-AS ALERT-BOX.
    END METHOD.

    METHOD PRIVATE VOID webView21_SourceChanged( INPUT sender AS System.Object, INPUT e AS Microsoft.Web.WebView2.Core.CoreWebView2SourceChangedEventArgs ):
        MESSAGE "Source changed." VIEW-AS ALERT-BOX.
    END METHOD.

Don't know why it does not work.
 

Cecil

19+ years progress programming and still learning.
It’s almost like that the object is not getting instantiated correctly runtime.
 

Osborne

Active Member
Really good to hear you have got it working. So in the propath you have something like this?:

,C:\Development\Webwiew\WebView2Loader.dll

Just tried that but still find the same in that nothing appears.
 

Cecil

19+ years progress programming and still learning.
I copied WebView2Loader.dll into the working directory with the other three dll:
  • Microsoft.Web.WebView2.Core.dll
  • Microsoft.Web.WebView2.WinForms.dll
  • Microsoft.Web.WebView2.Wpf.dll

I did try and add WebView2Loader.dll to the assembly.xml, but it errored so I guess that was not required.
 

Cecil

19+ years progress programming and still learning.
Update:
I was still experiencing a blank web browser screen after deployment to a Windows 10 PC.

I found out that I needed to download and install the WebVeiw2 Runtime (link below). I chose the Evergreen Standalone Installer.


@Osborne I believe that this will fix your issue.

It seems that if you have Mircosoft Outlook installed, you are not required to install the WebView2.
 
I copied WebView2Loader.dll into the working directory with the other three dll:
  • Microsoft.Web.WebView2.Core.dll
  • Microsoft.Web.WebView2.WinForms.dll
  • Microsoft.Web.WebView2.Wpf.dll

I did try and add WebView2Loader.dll to the assembly.xml, but it errored so I guess that was not required.
Hello @Cecil I'm getting back on the subject. I can't find these DLL . I'm a bit confused. I already install WebView2 runtime .
thanks in advance,

BobyIsProgress
 

Cecil

19+ years progress programming and still learning.
I think I had to disable some security in the properties of the file itself
 
Last edited:
Top