Compartir a través de


interface ICoreWebView2CompositionControllerInterop2

interface ICoreWebView2CompositionControllerInterop2
  : public ICoreWebView2CompositionControllerInterop

This interface is the continuation of the ICoreWebView2CompositionControllerInterop 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.

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.

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};
    // Convert the screen point to client coordinates add the WebView's offset.
    m_viewComponent->OffsetPointToWebView(&point);
    return m_webViewCompositionController3->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.

HRESULT DropTarget::DragLeave()
{
    return m_webViewCompositionController3->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.

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};
    // 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_webViewCompositionController3->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.

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};
    // 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_webViewCompositionController3->Drop(dataObject, keyState, point, effect);
}