interface ICoreWebView2Controller4
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);
}
}
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기