interface ICoreWebView2Experimental26

Note

This an experimental API that is shipped with our prerelease SDK. See WebView2 release notes.

interface ICoreWebView2Experimental26
  : public IUnknown

This interface is an extension of ICoreWebView2 that supports the ScreenCaptureStarting event.

Summary

Members Descriptions
add_ScreenCaptureStarting Adds an event handler for the ScreenCaptureStarting event.
remove_ScreenCaptureStarting Removes an event handler previously added with add_ScreenCaptureStarting.

Applies to

Product Introduced
WebView2 Win32 N/A
WebView2 Win32 Prerelease

Members

add_ScreenCaptureStarting

Adds an event handler for the ScreenCaptureStarting event.

public HRESULT add_ScreenCaptureStarting(ICoreWebView2ExperimentalScreenCaptureStartingEventHandler * eventHandler, EventRegistrationToken * token)

Add an event handler for the ScreenCaptureStarting event. ScreenCaptureStarting event is raised when the Screen Capture API is requested by the user using getDisplayMedia().

    m_webViewExperimental26 = m_webView.try_query<ICoreWebView2Experimental26>();
    if (m_webViewExperimental26)
    {
        m_webViewExperimental26->add_ScreenCaptureStarting(
            Callback<ICoreWebView2ExperimentalScreenCaptureStartingEventHandler>(
                [this](
                    ICoreWebView2* sender,
                    ICoreWebView2ExperimentalScreenCaptureStartingEventArgs* args) -> HRESULT
                {
                    // Get Frame Info
                    wil::com_ptr<ICoreWebView2FrameInfo> frameInfo;
                    CHECK_FAILURE(args->get_OriginalSourceFrameInfo(&frameInfo));

                    wil::com_ptr<ICoreWebView2FrameInfo2> frameInfo2;
                    CHECK_FAILURE(frameInfo->QueryInterface(IID_PPV_ARGS(&frameInfo2)));

                    UINT32 source_frameId;
                    CHECK_FAILURE(frameInfo2->get_FrameId(&source_frameId));

                    BOOL cancel = m_mainFramePermission == FALSE;
                    CHECK_FAILURE(args->put_Cancel(cancel));
                    return S_OK;
                })
                .Get(),
            &m_screenCaptureStartingToken);
    }

remove_ScreenCaptureStarting

Removes an event handler previously added with add_ScreenCaptureStarting.

public HRESULT remove_ScreenCaptureStarting(EventRegistrationToken token)