interface ICoreWebView2Controller4
Note
This reference is no longer being maintained. For the latest API reference, see WebView2 API Reference.
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 | N/A |
WebView2 Win32 Prerelease |
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);
}
}
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應