@yokesee: I don't know if my answer to your private mail went out. Unfortunately, the number of characters is also limited, so I couldn't write everything there. So here again. I have a test project VBC_UwpWebView.zip on activevb.de in the up/download area. This creates a WebViewControl via WinRT. However, this is still based on the older Edge browser and not on WebView2. The WinRT WebViewControl returns the following UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; WebView/3.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19045. You were concerned with creating multiple browser instances. All you have to do is make a few small changes to the code.
andCode:Option Explicit Private IsGetUserAgent As Boolean ' A WebViewControl array would probably be better here. Private WithEvents WebViewControl As clsWVC Private WithEvents WebViewControl1 As clsWVC ' <- new Private WithEvents WebViewControlProcess As clsWVCP
This creates two WebViewControl instances on the same form (hWnd). You can also use a TabControl where you then assign a WebViewControl instance to each tab.Code:Private Sub Form_Load() Me.ScaleMode = vbPixels cmdGoBack.Enabled = False cmdGoForward.Enabled = False Me.Caption = "WinRT-WebView:" Call lblInfo.Move(0, Me.ScaleHeight - 15, Me.ScaleWidth, 15) Set WebViewControlProcess = New clsWVCP If WebViewControlProcess.Create Then Set WebViewControl = WebViewControlProcess.CreateWebViewControlAsync(Me.hWnd, NewRect(0, 35, Me.ScaleWidth \ 2, Me.ScaleHeight - 50)) ' <- changed Set WebViewControl1 = WebViewControlProcess.CreateWebViewControlAsync(Me.hWnd, NewRect(Me.ScaleWidth \ 2, 35, Me.ScaleWidth \ 2, Me.ScaleHeight - 50)) ' <- new ' WebViewControl.Scaling = 0.8 '1 = 100% Dim UriRuntimeClass As New clsURC If UriRuntimeClass.CreateUri("https://www.google.de/") Then Call WebViewControl.Navigate(UriRuntimeClass) End If ' New Dim UriRuntimeClass1 As New clsURC If UriRuntimeClass1.CreateUri("https://www.vbforums.com/") Then Call WebViewControl1.Navigate(UriRuntimeClass1) End If End If End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) WebViewControl1.Closing ' <- new WebViewControl.Closing WebViewControlProcess.Terminate Set WebViewControl1 = Nothing ' <- new Set WebViewControl = Nothing Set WebViewControlProcess = Nothing End Sub Private Sub Form_Resize() If Me.WindowState <> vbMinimized Then Call lblInfo.Move(0, Me.ScaleHeight - 15, Me.ScaleWidth, 15) WebViewControl.bounds = NewRect(0, 35, Me.ScaleWidth \ 2, Me.ScaleHeight - 50) ' <- changed WebViewControl1.bounds = NewRect(Me.ScaleWidth \ 2, 35, Me.ScaleWidth \ 2, Me.ScaleHeight - 50) ' <- new End If End Sub




Reply With Quote