Visual COBOL and iFrame

We are working with another company to get their product working with ours - and they have written iframes to display their information. 

Is there a way to call those iframes within Visual COBOL.

P.S. We are only on Version 5.0 of the software - we are well aware that we need to upgrade. We just cannot at the moment. 

  • Verified Answer

    +1  

    Hi Amy,

    One method that you can use to display a browser within a Windows Form is to use the NuGet package CefSharp. It looks a bit complex to be able to read the response back from a web request but it is possible. 

    I got it to display the browser using the following code with Visual COBOL 9.0 so I am not sure it will work with 5.0.

          $set ilusing"CefSharp"
          $set ilusing"CefSharp.WinForms"
          $set ilusing"CefSharp.Handler"
           class-id testCefSharp.Form1 is partial
                     inherits type System.Windows.Forms.Form.
    
           working-storage section.
           01 chromeBrowser type ChromiumWebBrowser.
           method-id NEW.
           procedure division.
               invoke self::InitializeComponent
               invoke InitializeChromium.
    
               goback.
           end method.
    
           method-id InitializeChromium.
           procedure division.
               declare settings as type CefSettings = new CefSettings
               set settings::RootCachePath = "C:\\temp"
               invoke settings::CefCommandLineArgs::Add("log-severity", "fatal")
               invoke type Cef::Initialize(settings)
               set chromeBrowser = new type ChromiumWebBrowser("http://ourcodeworld.com")
               invoke self::Controls::Add(chromeBrowser)
               set chromeBrowser::Dock to type DockStyle::Fill.
               
               
           end method.
    
           method-id Form1_FormClosing final private.
           procedure division using by value sender as object e as type System.Windows.Forms.FormClosingEventArgs.
               invoke type Cef::Shutdown
           end method.
            
    
           end class.
    

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • 0 in reply to   

    Well - this did not work with 5.0 and Visual Studio 2017.

    When I try to get the NuGet Package - I get this error message: 

    The 'chromiumembeddedframework.runtime.win-x64 126.2.7' package requires NuGet client version '5.0.0' or above, but the current NuGet version is '4.9.3'. To upgrade NuGet, please go to docs.nuget.org/.../installing-nuget

    My NuGet is updated to the most recent level for Visual Studio 2017.  

    Do you have any other ideas, or am I going to have to upgrade to 9.0?

  • 0   in reply to 

    Hi Amy,

    Sorry, but I have no other ideas at the moment. Both VS2017 and VC 5.0 are no longer supported. I would highly recommend that you upgrade to VC 9.0 and VS2022 anyways so that you are back on a supported platform.

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • 0   in reply to 

      Winforms have a WebBrowser control. Could you try using that? 

    I created a simple Winform, added a WebBrowser control to it and added this to the Load event to show how you might be able to include an iframe.

    method-id Form1_Load final private.
    procedure division using by value sender as object e as type System.EventArgs.
    declare webPage as string =
    "<html>" &
    "<body>" &
    " <iframe" &
    " src='https://www.amazon.com' frameborder='0' height='100%' width='100%'>" &
    " </iframe>" &
    "</body>" &
    "<html>"
    set webBrowser1::DocumentText to webPage
    set webBrowser1::ScriptErrorsSuppressed to true
    end method.