OLEWebBrowser / WebView2

This forum is meant for questions and discussions about the X# language and tools
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

OLEWebBrowser / WebView2

Post by ic2 »

Franks conversion project currently has the issue that the places where the OleWebBrowser is used give this error:

The type or namespace name 'OLEWEBBROWSER' could not be found (are you missing a using directive or an assembly reference?)

Not sure what is missing? I think about everything is included in the references.

A better alternative would be WebView2 (an Edge based component). I use it in a WPF window, see below.

Can it be used in a VOform in X#? If so, how?

Dick

Code: Select all

<Window x:Class="WebView2Browser.WebWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WebView2Browser"
		xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
        mc:Ignorable="d"
        Title="WebWindow" Height="800" Width="1000">
	<DockPanel>
		<DockPanel DockPanel.Dock="Top">
			<Button x:Name="PrintPage"  Width="25"  FontWeight="Bold" FontSize="14" Click="ButtonPrint_Click" Height="25" ToolTip="Print" HorizontalAlignment="Right">
            <Image Source="Printer.jpg" Width="25    "></Image>
			</Button>
		</DockPanel>
		<wv2:WebView2 Name = "webView"
                  Source = "https://xsharp.eu"
    />
	</DockPanel>

</Window>
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

OLEWebBrowser / WebView2

Post by wriedmann »

Hi Dick,
WebView2 works also from Windows Forms, so you don't need WPF.
And therefore it should also work on a VOForm.
But I have managed it to use Windows Internet Explorer on a converted VOapplication.
You can find here a sample application and the respective library - as XIDE export file.
IEDialog.zip
(7.44 KiB) Downloaded 27 times
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FFF
Posts: 1521
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

OLEWebBrowser / WebView2

Post by FFF »

Wolfgang,
OOC: why trying to keep IE alive, when finally even MS buried it?
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

OLEWebBrowser / WebView2

Post by wriedmann »

Hi Karl,
oh no, I don't try to keep it alive.... I need this window for my migrated VO applications.
In new application I don't use it at all.
Wolfgang
P.S. in Windows 11 the WebView2 control is installed as part of the OS
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

OLEWebBrowser / WebView2

Post by ic2 »

Hello Wolfgang,

Thanks for the effort but unfortunately I never get something working in Xide.

I can open any of the 2 viaef files in Xide. I then select Application/Compile followed by Application/Run. In none of the cases anything happens.

As the name suggests the files are windows I selected Tools/Form Designer which gives the remarkable error Designers can be created only in X#/Vulcan.Net applications..

I thought this was an X# application....

Apart from that I think, with Karl, that we would prefer to start working with the current Olewebrowser; I hope that someone can tell us why it doesn't work.

Then the next logical step is using the WebView2. It is not difficult to get this working on a WPF application, for Winforms it shouldn't be too difficult either. And then I realized we can implement the WebView2 control the same way as Frank Müßner showed for the WinForms picturebox. Add a custom control to the VOForm and code the WebView2. Here's the WinfForms sample on Github from Microsoft:

https://github.com/MicrosoftEdge/WebVie ... rmsBrowser

https://www.xsharp.eu/forum/public-prod ... form#21516

PS: I wanted to quickly try this on an existing VO forms based program, the SSA sample from VO which we XPorted as an exercise. However, exactly as with Frank's PictureBox sample none of the forms open when I doubleclick. any of the forms, nothing happens. Eventually I reinstalled 2.10c and now it worked. I think the betaversion I still had installed may have been the cause. It did not solve the XIDE issue btw.

Dick
FFF
Posts: 1521
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

OLEWebBrowser / WebView2

Post by FFF »

Dick,
Wolfgang forgot to add his WLib2 to the IDDialog export, so it will not work.

Apart from this, i download the zip, extract to a folder, open Xide, select my playground project, rightclick on project name, import application, e voila. (Xide warns about the missing lib...)

A double on an viaef in explorer starts my Xide and shows the content as a file (not sure, if i had configured this, as i very rarely use this)
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

OLEWebBrowser / WebView2

Post by Chris »

Hi Dick,

In addition to what the guys already said, there's info about how to put OCX controls in VO windows in X# in the help file:

https://www.xsharp.eu/help/example-4-th ... t-exa.html

.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

OLEWebBrowser / WebView2

Post by ic2 »

Hello Karl,
FFF wrote: Apart from this, i download the zip, extract to a folder, open Xide, select my playground project, rightclick on project name, import application, e voila. (Xide warns about the missing lib...)

A double on an viaef in explorer starts my Xide and shows the content as a file (not sure, if i had configured this, as i very rarely use this)
Of course. It's like clicking on an AEF (which in my Pc opens that in VoPP). Xide is closer to VO than VS but if you don't use it it's more difficult to get working than VS solution which (most of the times) open & run by double clicking the .sln or project file.

Dick
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

OLEWebBrowser / WebView2

Post by ic2 »

Hello Chris,
Chris wrote: In addition to what the guys already said, there's info about how to put OCX controls in VO windows in X# in the help file:
https://www.xsharp.eu/help/example-4-th ... t-exa.html
.
Ah, yes, this describes the problem and the solution.

Frank has to decide what the quickest solution is. For the long term adding a custom control and assigning a WebView2 is more future proof.

Dick
FFF
Posts: 1521
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

OLEWebBrowser / WebView2

Post by FFF »

ic2 wrote:Of course. It's like clicking on an AEF (which in my Pc opens that in VoPP). Xide is closer to VO than VS but if you don't use it it's more difficult to get working than VS solution which (most of the times) open & run by double clicking the .sln or project file.
Yes. IIRC Xide sets no registry entries at all, so its a bit tricky to control the reaction on a ViAEF-doubleclick. If i rightclick, then "open with", i might "select standard app to open" and could point to Xide. But at that point XIDE would need an import dlg in front to target the project i wish to use. One could imagine writing a tiny app as "go between", to handle this... But probably Chris has a better idea ;-)
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
Post Reply