本文整理汇总了C++中COMPtr::doDragDrop方法的典型用法代码示例。如果您正苦于以下问题:C++ COMPtr::doDragDrop方法的具体用法?C++ COMPtr::doDragDrop怎么用?C++ COMPtr::doDragDrop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COMPtr
的用法示例。
在下文中一共展示了COMPtr::doDragDrop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startDrag
void WebDragClient::startDrag(DragImageRef image, const IntPoint& imageOrigin, const IntPoint& dragPoint, DataTransfer& dataTransfer, Frame& frame, bool isLink)
{
//FIXME: Allow UIDelegate to override behaviour <rdar://problem/5015953>
//We liberally protect everything, to protect against a load occurring mid-drag
RefPtr<Frame> frameProtector = &frame;
COMPtr<IDragSourceHelper> helper;
COMPtr<IDataObject> dataObject;
COMPtr<WebView> viewProtector = m_webView;
COMPtr<IDropSource> source;
if (FAILED(WebDropSource::createInstance(m_webView, &source)))
return;
dataObject = dataTransfer.pasteboard().dataObject();
if (source && (image || dataObject)) {
if (image) {
if(SUCCEEDED(CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER,
IID_IDragSourceHelper,(LPVOID*)&helper))) {
BITMAP b;
GetObject(image, sizeof(BITMAP), &b);
SHDRAGIMAGE sdi;
sdi.sizeDragImage.cx = b.bmWidth;
sdi.sizeDragImage.cy = b.bmHeight;
sdi.crColorKey = 0xffffffff;
sdi.hbmpDragImage = image;
sdi.ptOffset.x = dragPoint.x() - imageOrigin.x();
sdi.ptOffset.y = dragPoint.y() - imageOrigin.y();
if (isLink)
sdi.ptOffset.y = b.bmHeight - sdi.ptOffset.y;
helper->InitializeFromBitmap(&sdi, dataObject.get());
}
}
DWORD okEffect = draggingSourceOperationMaskToDragCursors(m_webView->page()->dragController().sourceDragOperation());
DWORD effect = DROPEFFECT_NONE;
COMPtr<IWebUIDelegate> ui;
HRESULT hr = E_NOTIMPL;
if (SUCCEEDED(m_webView->uiDelegate(&ui))) {
COMPtr<IWebUIDelegatePrivate> uiPrivate;
if (SUCCEEDED(ui->QueryInterface(IID_IWebUIDelegatePrivate, (void**)&uiPrivate)))
hr = uiPrivate->doDragDrop(m_webView, dataObject.get(), source.get(), okEffect, &effect);
}
if (hr == E_NOTIMPL)
hr = DoDragDrop(dataObject.get(), source.get(), okEffect, &effect);
DragOperation operation = DragOperationNone;
if (hr == DRAGDROP_S_DROP) {
if (effect & DROPEFFECT_COPY)
operation = DragOperationCopy;
else if (effect & DROPEFFECT_LINK)
operation = DragOperationLink;
else if (effect & DROPEFFECT_MOVE)
operation = DragOperationMove;
}
frame.eventHandler().dragSourceEndedAt(generateMouseEvent(m_webView, false), operation);
}
}
示例2: startDrag
void WebDragClient::startDrag(DragImageRef image, const IntPoint& imageOrigin, const IntPoint& dragPoint, Clipboard* clipboard, Frame* frame, bool isLink)
{
//FIXME: Allow UIDelegate to override behaviour <rdar://problem/5015953>
//We liberally protect everything, to protect against a load occurring mid-drag
RefPtr<Frame> frameProtector = frame;
COMPtr<IDragSourceHelper> helper;
COMPtr<IDataObject> dataObject;
COMPtr<WebView> viewProtector = m_webView;
COMPtr<IDropSource> source;
if (FAILED(WebDropSource::createInstance(m_webView, &source)))
return;
dataObject = static_cast<ClipboardWin*>(clipboard)->dataObject();
if (source && (image || dataObject)) {
if (image) {
if(SUCCEEDED(CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER,
IID_IDragSourceHelper,(LPVOID*)&helper))) {
BITMAP b;
GetObject(image, sizeof(BITMAP), &b);
SHDRAGIMAGE sdi;
sdi.sizeDragImage.cx = b.bmWidth;
sdi.sizeDragImage.cy = b.bmHeight;
sdi.crColorKey = 0xffffffff;
sdi.hbmpDragImage = image;
sdi.ptOffset.x = dragPoint.x() - imageOrigin.x();
sdi.ptOffset.y = dragPoint.y() - imageOrigin.y();
if (isLink)
sdi.ptOffset.y = b.bmHeight - sdi.ptOffset.y;
helper->InitializeFromBitmap(&sdi, dataObject.get());
}
}
//FIXME: Ensure correct drag ops are available <rdar://problem/5015957>
DWORD okEffect = DROPEFFECT_COPY | DROPEFFECT_LINK | DROPEFFECT_MOVE;
DWORD effect;
COMPtr<IWebUIDelegate> ui;
if (SUCCEEDED(m_webView->uiDelegate(&ui))) {
COMPtr<IWebUIDelegatePrivate> uiPrivate;
if (SUCCEEDED(ui->QueryInterface(IID_IWebUIDelegatePrivate, (void**)&uiPrivate)))
if (SUCCEEDED(uiPrivate->doDragDrop(m_webView, dataObject.get(), source.get(), okEffect, &effect)))
return;
}
DoDragDrop(dataObject.get(), source.get(), okEffect, &effect);
}
}