Page 1 of 2
OLEWebBrowser / WebView2
Posted: Mon Feb 28, 2022 4:38 pm
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>
OLEWebBrowser / WebView2
Posted: Mon Feb 28, 2022 5:11 pm
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.
Wolfgang
OLEWebBrowser / WebView2
Posted: Mon Feb 28, 2022 6:56 pm
by FFF
Wolfgang,
OOC: why trying to keep IE alive, when finally even MS buried it?
OLEWebBrowser / WebView2
Posted: Mon Feb 28, 2022 7:44 pm
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
OLEWebBrowser / WebView2
Posted: Mon Feb 28, 2022 8:38 pm
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
OLEWebBrowser / WebView2
Posted: Mon Feb 28, 2022 8:56 pm
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)
OLEWebBrowser / WebView2
Posted: Mon Feb 28, 2022 10:42 pm
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
.
OLEWebBrowser / WebView2
Posted: Tue Mar 01, 2022 11:15 am
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
OLEWebBrowser / WebView2
Posted: Tue Mar 01, 2022 11:18 am
by ic2
Hello Chris,
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
OLEWebBrowser / WebView2
Posted: Tue Mar 01, 2022 11:32 am
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