interface ICoreWebView2ExperimentalCompositionController3

Note

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

interface ICoreWebView2ExperimentalCompositionController3
  : public IUnknown

This interface is continuation of the ICoreWebView2CompositionController interface to manage drag and drop.

Summary

Members Descriptions
DragEnter This function corresponds to IDropTarget::DragEnter.
DragLeave This function corresponds to IDropTarget::DragLeave.
DragOver This function corresponds to IDropTarget::DragOver.
Drop This function corresponds to IDropTarget::Drop.

Applies to

Product Introduced
WebView2 Win32 N/A
WebView2 Win32 Prerelease 1.0.721

Members

DragEnter

This function corresponds to IDropTarget::DragEnter.

public HRESULT DragEnter(IDataObject * dataObject, DWORD keyState, POINT point, DWORD * effect)

This function has a dependency on AllowExternalDrop property of CoreWebView2Controller and return E_FAIL to callers to indicate this operation is not allowed if AllowExternalDrop property is set to false.

The hosting application must register as an IDropTarget and implement and forward DragEnter calls to this function.

In addition, the hosting application needs to create an IDropTargetHelper and call the corresponding IDropTargetHelper::DragEnter function on that object before forwarding the call to WebView.

point parameter must be modified to include the WebView's offset and be in the WebView's client coordinates (Similar to how SendMouseInput works).

HRESULT DropTarget::DragEnter(
    IDataObject* dataObject, DWORD keyState, POINTL cursorPosition, DWORD* effect)
{
    POINT point = { cursorPosition.x, cursorPosition.y};
    // Tell the helper that we entered so it can update the drag image and get
    // the correct effect.
    wil::com_ptr<IDropTargetHelper> dropHelper = DropHelper();
    if (dropHelper)
    {
        dropHelper->DragEnter(GetHWND(), dataObject, &point, *effect);
    }

    // Convert the screen point to client coordinates add the WebView's offset.
    m_viewComponent->OffsetPointToWebView(&point);
    return m_webViewExperimentalCompositionController3->DragEnter(
        dataObject, keyState, point, effect);
}

DragLeave

This function corresponds to IDropTarget::DragLeave.

public HRESULT DragLeave()

This function has a dependency on AllowExternalDrop property of CoreWebView2Controller and return E_FAIL to callers to indicate this operation is not allowed if AllowExternalDrop property is set to false.

The hosting application must register as an IDropTarget and implement and forward DragLeave calls to this function.

In addition, the hosting application needs to create an IDropTargetHelper and call the corresponding IDropTargetHelper::DragLeave function on that object before forwarding the call to WebView.

HRESULT DropTarget::DragLeave()
{
    // Tell the helper that we moved out of it so it can update the drag image.
    wil::com_ptr<IDropTargetHelper> dropHelper = DropHelper();
    if (dropHelper)
    {
        dropHelper->DragLeave();
    }

    return m_webViewExperimentalCompositionController3->DragLeave();
}

DragOver

This function corresponds to IDropTarget::DragOver.

public HRESULT DragOver(DWORD keyState, POINT point, DWORD * effect)

This function has a dependency on AllowExternalDrop property of CoreWebView2Controller and return E_FAIL to callers to indicate this operation is not allowed if AllowExternalDrop property is set to false.

The hosting application must register as an IDropTarget and implement and forward DragOver calls to this function.

In addition, the hosting application needs to create an IDropTargetHelper and call the corresponding IDropTargetHelper::DragOver function on that object before forwarding the call to WebView.

point parameter must be modified to include the WebView's offset and be in the WebView's client coordinates (Similar to how SendMouseInput works).

HRESULT DropTarget::DragOver(DWORD keyState, POINTL cursorPosition, DWORD* effect)
{
    POINT point = { cursorPosition.x, cursorPosition.y};
    // Tell the helper that we moved over it so it can update the drag image
    // and get the correct effect.
    wil::com_ptr<IDropTargetHelper> dropHelper = DropHelper();
    if (dropHelper)
    {
        dropHelper->DragOver(&point, *effect);
    }

    // Convert the screen point to client coordinates add the WebView's offset.
    // This returns whether the resultant point is over the WebView visual.
    m_viewComponent->OffsetPointToWebView(&point);
    return m_webViewExperimentalCompositionController3->DragOver(
        keyState, point, effect);
}

Drop

This function corresponds to IDropTarget::Drop.

public HRESULT Drop(IDataObject * dataObject, DWORD keyState, POINT point, DWORD * effect)

This function has a dependency on AllowExternalDrop property of CoreWebView2Controller and return E_FAIL to callers to indicate this operation is not allowed if AllowExternalDrop property is set to false.

The hosting application must register as an IDropTarget and implement and forward Drop calls to this function.

In addition, the hosting application needs to create an IDropTargetHelper and call the corresponding IDropTargetHelper::Drop function on that object before forwarding the call to WebView.

point parameter must be modified to include the WebView's offset and be in the WebView's client coordinates (Similar to how SendMouseInput works).

HRESULT DropTarget::Drop(
    IDataObject* dataObject, DWORD keyState, POINTL cursorPosition, DWORD* effect)
{
    POINT point = { cursorPosition.x, cursorPosition.y};
    // Tell the helper that we dropped onto it so it can update the drag image and
    // get the correct effect.
    wil::com_ptr<IDropTargetHelper> dropHelper = DropHelper();
    if (dropHelper)
    {
        dropHelper->Drop(dataObject, &point, *effect);
    }

    // Convert the screen point to client coordinates add the WebView's offset.
    // This returns whether the resultant point is over the WebView visual.
    m_viewComponent->OffsetPointToWebView(&point);
    return m_webViewExperimentalCompositionController3->Drop(dataObject, keyState, point, effect);
}