CreateWebViewSync
Interface AntView
Type: Method
Parameters: Long HResult
Returns: Integer
Instantiates the webview2 control.
If the webview2 control is already instantiated then sending the CreateWebViewSync method again will be ignored.
After executing this method, the parameter HResult contains the windows status if it could not succeed or S_OK (= 0) if it succeeded.
See Common HRESULT Values for some examples.
The function itself returns the following values:
0 if no errors.
21 function is already running (can only run one at a time)
22 function timed out
25 Trying to run a synchronous method from within a WebView2 event
If creating the WebView2 control takes more than 5 seconds, you might want to adjust the time out via SynchronousTimeOut to something else. As SynchronousTimeOut has a default for the AntView interface of 5 seconds.
A sidenote is that because the WebView2 control is created asynchronously and out of process that it is a bit sensitive on when it is getting called.
For example, in VB6 if you call this synchronous version of this method (CreateWebViewSync) during creation of a form in event Form_Initialize() it will not complete and fail to create the WebView2 control. Instead you'll end up with a grey square where the control should be. If however you call the asynchronous version of this method (CreateWebView) from the same Initialize method then it will complete.
If you need the asynchronous version then the solution is to move it to an event that is called later in time, such as calling it from Form_Activate().
This is the Synchronous alternative of the CreateWebView method.
Beware that you cannot issue a synchronous call from within an AntView event, with the exception being the OnCreate event.
Example:
Introduced in AntView release 1.1.236
AntView - The MS Edge WebView2 ActiveX control Date last changed: 09/25/2024