ICoreWebView2Controller2

Undocumented in source.
version(Windows && inline_webview2_bindings && all)
interface ICoreWebView2Controller2 : ICoreWebView2Controller {
static const
GUID iid;
}

Members

Functions

get_DefaultBackgroundColor
HRESULT get_DefaultBackgroundColor(COREWEBVIEW2_COLOR* backgroundColor)

The DefaultBackgroundColor property is the color WebView renders underneath all web content. This means WebView renders this color when there is no web content loaded such as before the initial navigation or between navigations. This also means web pages with undefined css background properties or background properties containing transparent pixels will render their contents over this color. Web pages with defined and opaque background properties that span the page will obscure the DefaultBackgroundColor and display normally. The default value for this property is white to resemble the native browser experience.

put_DefaultBackgroundColor
HRESULT put_DefaultBackgroundColor(COREWEBVIEW2_COLOR backgroundColor)

Sets the DefaultBackgroundColor property.

Inherited Members

From ICoreWebView2Controller

get_IsVisible
HRESULT get_IsVisible(BOOL* isVisible)

The IsVisible property determines whether to show or hide the WebView2. If IsVisible is set to FALSE, the WebView2 is transparent and is not rendered. However, this does not affect the window containing the WebView2 (the HWND parameter that was passed to CreateCoreWebView2Controller). If you want that window to disappear too, run ShowWindow on it directly in addition to modifying the IsVisible property. WebView2 as a child window does not get window messages when the top window is minimized or restored. For performance reasons, developers should set the IsVisible property of the WebView to FALSE when the app window is minimized and back to TRUE when the app window is restored. The app window does this by handling SIZE_MINIMIZED and SIZE_RESTORED command upon receiving WM_SIZE message.

put_IsVisible
HRESULT put_IsVisible(BOOL isVisible)

Sets the IsVisible property.

get_Bounds
HRESULT get_Bounds(RECT* bounds)

The WebView bounds. Bounds are relative to the parent HWND. The app has two ways to position a WebView.

put_Bounds
HRESULT put_Bounds(RECT bounds)

Sets the Bounds property.

get_ZoomFactor
HRESULT get_ZoomFactor(double* zoomFactor)

The zoom factor for the WebView.

put_ZoomFactor
HRESULT put_ZoomFactor(double zoomFactor)

Sets the ZoomFactor property.

add_ZoomFactorChanged
HRESULT add_ZoomFactorChanged(ICoreWebView2ZoomFactorChangedEventHandler eventHandler, EventRegistrationToken* token)

Adds an event handler for the ZoomFactorChanged event. ZoomFactorChanged runs when the ZoomFactor property of the WebView changes. The event may run because the ZoomFactor property was modified, or due to the user manually modifying the zoom. When it is modified using the ZoomFactor property, the internal zoom factor is updated immediately and no ZoomFactorChanged event is triggered. WebView associates the last used zoom factor for each site. It is possible for the zoom factor to change when navigating to a different page. When the zoom factor changes due to a navigation change, the ZoomFactorChanged event runs right after the ContentLoading event.

remove_ZoomFactorChanged
HRESULT remove_ZoomFactorChanged(EventRegistrationToken token)

Remove an event handler previously added with add_ZoomFactorChanged.

SetBoundsAndZoomFactor
HRESULT SetBoundsAndZoomFactor(RECT bounds, double zoomFactor)

Updates Bounds and ZoomFactor properties at the same time. This operation is atomic from the perspective of the host. After returning from this function, the Bounds and ZoomFactor properties are both updated if the function is successful, or neither is updated if the function fails. If Bounds and ZoomFactor are both updated by the same scale (for example, Bounds and ZoomFactor are both doubled), then the page does not display a change in window.innerWidth or window.innerHeight and the WebView renders the content at the new size and zoom without intermediate renderings. This function also updates just one of ZoomFactor or Bounds by passing in the new value for one and the current value for the other.

MoveFocus
HRESULT MoveFocus(COREWEBVIEW2_MOVE_FOCUS_REASON reason)

Moves focus into WebView. WebView gets focus and focus is set to correspondent element in the page hosted in the WebView. For Programmatic reason, focus is set to previously focused element or the default element if no previously focused element exists. For Next reason, focus is set to the first element. For Previous reason, focus is set to the last element. WebView changes focus through user interaction including selecting into a WebView or Tab into it. For tabbing, the app runs MoveFocus with Next or Previous to align with Tab and Shift+Tab respectively when it decides the WebView is the next element that may exist in a tab. Or, the app runs IsDialogMessage as part of the associated message loop to allow the platform to auto handle tabbing. The platform rotates through all windows with WS_TABSTOP. When the WebView gets focus from IsDialogMessage, it is internally put the focus on the first or last element for tab and Shift+Tab respectively.

add_MoveFocusRequested
HRESULT add_MoveFocusRequested(ICoreWebView2MoveFocusRequestedEventHandler eventHandler, EventRegistrationToken* token)

Adds an event handler for the MoveFocusRequested event. MoveFocusRequested runs when user tries to tab out of the WebView. The focus of the WebView has not changed when this event is run.

remove_MoveFocusRequested
HRESULT remove_MoveFocusRequested(EventRegistrationToken token)

Removes an event handler previously added with add_MoveFocusRequested.

add_GotFocus
HRESULT add_GotFocus(ICoreWebView2FocusChangedEventHandler eventHandler, EventRegistrationToken* token)

Adds an event handler for the GotFocus event. GotFocus runs when WebView has focus.

remove_GotFocus
HRESULT remove_GotFocus(EventRegistrationToken token)

Removes an event handler previously added with add_GotFocus.

add_LostFocus
HRESULT add_LostFocus(ICoreWebView2FocusChangedEventHandler eventHandler, EventRegistrationToken* token)

Adds an event handler for the LostFocus event. LostFocus runs when WebView loses focus. In the case where MoveFocusRequested event is run, the focus is still on WebView when MoveFocusRequested event runs. LostFocus only runs afterwards when code of the app or default action of MoveFocusRequested event set focus away from WebView.

remove_LostFocus
HRESULT remove_LostFocus(EventRegistrationToken token)

Removes an event handler previously added with add_LostFocus.

add_AcceleratorKeyPressed
HRESULT add_AcceleratorKeyPressed(ICoreWebView2AcceleratorKeyPressedEventHandler eventHandler, EventRegistrationToken* token)

Adds an event handler for the AcceleratorKeyPressed event. AcceleratorKeyPressed runs when an accelerator key or key combo is pressed or released while the WebView is focused. A key is considered an accelerator if either of the following conditions are true.

remove_AcceleratorKeyPressed
HRESULT remove_AcceleratorKeyPressed(EventRegistrationToken token)

Removes an event handler previously added with add_AcceleratorKeyPressed.

get_ParentWindow
HRESULT get_ParentWindow(HWND* parentWindow)

The parent window provided by the app that this WebView is using to render content. This API initially returns the window passed into CreateCoreWebView2Controller.

put_ParentWindow
HRESULT put_ParentWindow(HWND parentWindow)

Sets the parent window for the WebView. This causes the WebView to re-parent the main WebView window to the newly provided window.

NotifyParentWindowPositionChanged
HRESULT NotifyParentWindowPositionChanged()

This is a notification separate from Bounds that tells WebView that the main WebView parent (or any ancestor) HWND moved. This is needed for accessibility and certain dialogs in WebView to work correctly.

Close
HRESULT Close()

Closes the WebView and cleans up the underlying browser instance. Cleaning up the browser instance releases the resources powering the WebView. The browser instance is shut down if no other WebViews are using it.

get_CoreWebView2
HRESULT get_CoreWebView2(ICoreWebView2* coreWebView2)

Gets the CoreWebView2 associated with this CoreWebView2Controller.

Meta