Re: vb6 webview2 by IUnknown WebView2Loader.dll-Edge-Chromium
i see the positive progress ..
however this code require the (installed) SDK + is limited to x32 due to the usage of the 32 Bit version of WebView2Loader.dll
In case the goal is e.g usage within Office:
* did you check office root folder ?
there is WebView2Host.dll and WebView2Loader.dll (within the correct bitness)
the first offer the entry CreateOfficeWebView2Environment and *Options (to configure the userfolder, and additional parms)
Now this Vtbl approach "just" need to be converted into x64 .. with some (conditional) LongPtr conversions and usage of the both within ".\Microsoft Office\root\Office16"
Re: vb6 webview2 by IUnknown WebView2Loader.dll-Edge-Chromium
@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.
Code:
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
and
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
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.
Hi,I am running a script which allows me to extract information from a website and view it directly in the Google Chrome console. Now I want to extract said information or store it in a variable but I can't find a way since according to what I have consulted I require one of these 3 options but I don't know how to implement it directly in my code since the function declarations do not appear
Re: vb6 edge webview demo by IUnknown,without rc6.dll
Originally Posted by yokesee
Very good work.
Is it possible to add extensions?
thanks
WebView 2 support extends Part of what WebView 2 has been missing is support for extensions, and today I saw on its github that it already supports extensions APIs: experimental extensions APIs Although it is only a preview function at present, the probability of formal inclusion is still relatively large. Try it when you are free.
Re: vb6 webview2 by IUnknown WebView2Loader.dll-Edge-Chromium
I got a hard time to run the codes in excel x64. Can any one provide a x64 version defination of CreateCoreWebView2EnvironmentWithOptions and a sample code to call? And do I need to put the correct loader into the same folder?
Re: vb6 edge webview2 demo by IUnknown?without rc6.dll
Originally Posted by xiaoyao
add some webviewe method
Code:
Function OpenUrl(ByVal Url As String)
If Left(LCase(Url), 4) <> "http" Then Url = "http://" & Url
v = VTableCallEx("Navigate", webviewWindow, 3, StrPtr(Url))
End Function
Function OpenDevToolsWindow()
v = VTableCallEx("OpenDevToolsWindow", webviewWindow, 49)
End Function
Function ExecuteScript(JS As String)
v = VTableCallEx("ExecuteScript", webviewWindow, 27, StrPtr(JS), 0&)
End Function
Function AddHostObjectToScript(ObjName As String, Obj1 As Object)
v = VTableCallEx("AddHostObjectToScript", webviewWindow, 47, StrPtr(ObjName), ObjPtr(Obj1))
AddHostObjectToScript = hResult = 0
End Function
Function WebReSize() As Boolean
Dim RECT1 As RECT
GetClientRect webHostHwnd, RECT1
'webviewController->put_Bounds(bounds);
v = VTableCallEx("put_Bounds", webviewController, 4, RECT1.Left, RECT1.Top, RECT1.Right, RECT1.Bottom)
WebReSize = hResult = 0
End Function
HI xiaoyao,
Very nice work , your solution is very helpful .
Please help me if possible , in my case i need to get return value/result from javascript function , I tried using ExecuteScript function but no luck .
Re: vb6 edge webview2 demo by IUnknown?without rc6.dll
Thanks @xiaoyao
The demo works well as a simple application with one form but I found two related problems if the code is used with multiple forms.
1. The form using Webview2 can be opened and used once but if closed and reopened the program crashes. A workaround is to hide the form instead of closing it then show again when required.
2. For the same reason it is impossible to have more than one form using Webview2. No workaround for this.
Re: vb6 edge webview2 demo by IUnknown?without rc6.dll
Originally Posted by PrashantS
I tried this solution , but unfortunately it is still crashing .
Not sure if this is of use to anyone, but got this working with the aid of Claude. Now does not crash if closed if running in IDE, or the compiled exe is closed. It will crash if [STOP] pressed within the IDE.