Skip to content

Latest commit

 

History

History
112 lines (92 loc) · 4.42 KB

icorewebview2controller4.md

File metadata and controls

112 lines (92 loc) · 4.42 KB
description title ms.date keywords topic_type api_name api_type api_location
This is the ICoreWebView2Controller4 interface.
WebView2 Win32 C++ ICoreWebView2Controller4
05/20/2024
IWebView2, IWebView2WebView, webview2, webview, win32 apps, win32, edge, ICoreWebView2, ICoreWebView2Controller, browser control, edge html, ICoreWebView2Controller4
APIRef
ICoreWebView2Controller4
ICoreWebView2Controller4.get_AllowExternalDrop
ICoreWebView2Controller4.put_AllowExternalDrop
COM
embeddedbrowserwebview.dll

interface ICoreWebView2Controller4

[!INCLUDE deprecation-note]

interface ICoreWebView2Controller4
  : public ICoreWebView2Controller3

This is the ICoreWebView2Controller4 interface.

Summary

Members Descriptions
get_AllowExternalDrop Gets the AllowExternalDrop property which is used to configure the capability that dragging objects from outside the bounds of webview2 and dropping into webview2 is allowed or disallowed.
put_AllowExternalDrop Sets the AllowExternalDrop property which is used to configure the capability that dragging objects from outside the bounds of webview2 and dropping into webview2 is allowed or disallowed.

The ICoreWebView2Controller4 provides interface to enable/disable external drop.

Applies to

Product Introduced
WebView2 Win32 1.0.1185.39
WebView2 Win32 Prerelease 1.0.1189

Members

get_AllowExternalDrop

Gets the AllowExternalDrop property which is used to configure the capability that dragging objects from outside the bounds of webview2 and dropping into webview2 is allowed or disallowed.

public HRESULT get_AllowExternalDrop(BOOL * value)

The default value is TRUE.

            wil::com_ptr<ICoreWebView2Controller> controller =
                m_appWindow->GetWebViewController();
            wil::com_ptr<ICoreWebView2Controller4> controller4 =
                controller.try_query<ICoreWebView2Controller4>();
            if (controller4)
            {
                BOOL allowExternalDrop;
                CHECK_FAILURE(controller4->get_AllowExternalDrop(&allowExternalDrop));
                if (allowExternalDrop)
                {
                    CHECK_FAILURE(controller4->put_AllowExternalDrop(FALSE));
                    MessageBox(
                        nullptr, L"WebView disallows dropping files now.",
                        L"WebView AllowExternalDrop property changed", MB_OK);
                }
                else
                {
                    CHECK_FAILURE(controller4->put_AllowExternalDrop(TRUE));
                    MessageBox(
                        nullptr, L"WebView allows dropping files now.",
                        L"WebView AllowExternalDrop property changed", MB_OK);
                }
            }

put_AllowExternalDrop

Sets the AllowExternalDrop property which is used to configure the capability that dragging objects from outside the bounds of webview2 and dropping into webview2 is allowed or disallowed.

public HRESULT put_AllowExternalDrop(BOOL value)

            wil::com_ptr<ICoreWebView2Controller> controller =
                m_appWindow->GetWebViewController();
            wil::com_ptr<ICoreWebView2Controller4> controller4 =
                controller.try_query<ICoreWebView2Controller4>();
            if (controller4)
            {
                BOOL allowExternalDrop;
                CHECK_FAILURE(controller4->get_AllowExternalDrop(&allowExternalDrop));
                if (allowExternalDrop)
                {
                    CHECK_FAILURE(controller4->put_AllowExternalDrop(FALSE));
                    MessageBox(
                        nullptr, L"WebView disallows dropping files now.",
                        L"WebView AllowExternalDrop property changed", MB_OK);
                }
                else
                {
                    CHECK_FAILURE(controller4->put_AllowExternalDrop(TRUE));
                    MessageBox(
                        nullptr, L"WebView allows dropping files now.",
                        L"WebView AllowExternalDrop property changed", MB_OK);
                }
            }