共用方式為


CoreWebView2Environment.CreateCoreWebView2CompositionControllerAsync Method

Definition

Overloads

CreateCoreWebView2CompositionControllerAsync(IntPtr)

Asynchronously creates a new WebView for use with visual hosting.

CreateCoreWebView2CompositionControllerAsync(IntPtr, CoreWebView2ControllerOptions)

Create a new WebView in visual hosting mode with options.

CreateCoreWebView2CompositionControllerAsync(IntPtr)

Asynchronously creates a new WebView for use with visual hosting.

public System.Threading.Tasks.Task<Microsoft.Web.WebView2.Core.CoreWebView2CompositionController> CreateCoreWebView2CompositionControllerAsync (IntPtr ParentWindow);
member this.CreateCoreWebView2CompositionControllerAsync : nativeint -> System.Threading.Tasks.Task<Microsoft.Web.WebView2.Core.CoreWebView2CompositionController>
Public Function CreateCoreWebView2CompositionControllerAsync (ParentWindow As IntPtr) As Task(Of CoreWebView2CompositionController)

Parameters

ParentWindow
IntPtr

nativeint

The HWND in which the app will connect the visual tree of the WebView.

Returns

Remarks

ParentWindow will be the HWND that the app will receive pointer/mouse input meant for the WebView (and will need to use SendMouseInput(CoreWebView2MouseEventKind, CoreWebView2MouseEventVirtualKeys, UInt32, Point) or SendPointerInput(CoreWebView2PointerEventKind, CoreWebView2PointerInfo) to forward). If the app moves the WebView visual tree to underneath a different window, then it needs to set ParentWindow to update the new parent HWND of the visual tree.

Set RootVisualTarget property on the created CoreWebView2CompositionController to provide a visual to host the browser's visual tree.

It is recommended that the application set Application User Model ID for the process or the application window. If none is set, during WebView creation a generated Application User Model ID is set to root window of ParentWindow.

It can also accept a CoreWebView2ControllerOptions which is created by CreateCoreWebView2ControllerOptions() as the second parameter for multiple profiles support.

CreateCoreWebView2CompositionController is supported in the following versions of Windows:

- Windows 11 - Windows 10 - Windows Server 2019 - Windows Server 2016

Applies to

CreateCoreWebView2CompositionControllerAsync(IntPtr, CoreWebView2ControllerOptions)

Create a new WebView in visual hosting mode with options.

public System.Threading.Tasks.Task<Microsoft.Web.WebView2.Core.CoreWebView2CompositionController> CreateCoreWebView2CompositionControllerAsync (IntPtr ParentWindow, Microsoft.Web.WebView2.Core.CoreWebView2ControllerOptions options);
member this.CreateCoreWebView2CompositionControllerAsync : nativeint * Microsoft.Web.WebView2.Core.CoreWebView2ControllerOptions -> System.Threading.Tasks.Task<Microsoft.Web.WebView2.Core.CoreWebView2CompositionController>
Public Function CreateCoreWebView2CompositionControllerAsync (ParentWindow As IntPtr, options As CoreWebView2ControllerOptions) As Task(Of CoreWebView2CompositionController)

Parameters

ParentWindow
IntPtr

nativeint

The HWND in which the WebView should be displayed and from which receive input.

options
CoreWebView2ControllerOptions

The options contains profileName and inPrivate parameters that could be used to create CoreWebView2Profile, and it can be used to create multiple WebViews with multiple profiles under a single user data directory.

Returns

Remarks

Multiple profiles under single user data directory can share some system resources including memory, CPU footprint, disk space (such as compiled shaders and safebrowsing data) etc.

Applies to