Author: gadamopoulos
Date: Wed Feb 1 14:22:45 2017
New Revision: 73661
URL:
http://svn.reactos.org/svn/reactos?rev=73661&view=rev
Log:
[SHELL32] - CDefView: Implement rudimentary support for drag icons. For now we only show
the icon of the first item (no caption or other icons yet).
Modified:
trunk/reactos/dll/win32/shell32/CDefView.cpp
Modified: trunk/reactos/dll/win32/shell32/CDefView.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/CDefView…
==============================================================================
--- trunk/reactos/dll/win32/shell32/CDefView.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/CDefView.cpp [iso-8859-1] Wed Feb 1 14:22:45 2017
@@ -1740,6 +1740,8 @@
if (SUCCEEDED(m_pSFParent->GetUIObjectOf(m_hWnd, m_cidl, m_apidl,
IID_NULL_PPV_ARG(IDataObject, &pda))))
{
+ LPNMLISTVIEW params = (LPNMLISTVIEW)lParam;
+
if (SUCCEEDED(m_pSFParent->GetAttributesOf(m_cidl, m_apidl,
&dwAttributes)))
{
if (dwAttributes & SFGAO_CANLINK)
@@ -1757,8 +1759,17 @@
DWORD dwEffect2;
m_pSourceDataObject = pda;
- m_ptFirstMousePos = ((LPNMLISTVIEW)lParam)->ptAction;
+ m_ptFirstMousePos = params->ptAction;
ClientToScreen(&m_ptFirstMousePos);
+
+ HIMAGELIST big_icons, small_icons;
+ Shell_GetImageLists(&big_icons, &small_icons);
+ PCUITEMID_CHILD pidl = _PidlByItem(params->iItem);
+ int iIcon = SHMapPIDLToSystemImageListIndex(m_pSFParent, pidl, 0);
+ POINT ptItem;
+ m_ListView.GetItemPosition(params->iItem, &ptItem);
+
+ ImageList_BeginDrag(big_icons, iIcon, m_ptFirstMousePos.x - ptItem.x,
m_ptFirstMousePos.y - ptItem.y);
DoDragDrop(pda, this, dwEffect, &dwEffect2);
@@ -2913,34 +2924,44 @@
/* If anything failed, m_pCurDropTarget should be NULL now, which ought to be a save
state. */
if (FAILED(hr))
+ {
+ *pdwEffect = DROPEFFECT_NONE;
return hr;
+ }
+
+ if (m_iDragOverItem != -1)
+ {
+ SelectItem(m_iDragOverItem, SVSI_SELECT);
+ }
/* Notify the item just entered via DragEnter. */
- hr = m_pCurDropTarget->DragEnter(m_pCurDataObject, grfKeyState, pt, pdwEffect);
-
- if (m_iDragOverItem != -1 && pdwEffect != DROPEFFECT_NONE)
- {
- SelectItem(m_iDragOverItem, SVSI_SELECT);
- }
-
- return hr;
+ return m_pCurDropTarget->DragEnter(m_pCurDataObject, grfKeyState, pt, pdwEffect);
}
HRESULT WINAPI CDefView::DragEnter(IDataObject *pDataObject, DWORD grfKeyState, POINTL
pt, DWORD *pdwEffect)
{
+ POINT ptClient = {pt.x, pt.y};
+ ScreenToClient(&ptClient);
+
/* Get a hold on the data object for later calls to DragEnter on the sub-folders */
m_pCurDataObject = pDataObject;
+ ImageList_DragEnter(m_hWnd, ptClient.x, ptClient.y);
return drag_notify_subitem(grfKeyState, pt, pdwEffect);
}
HRESULT WINAPI CDefView::DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
{
+ POINT ptClient = {pt.x, pt.y};
+ ScreenToClient(&ptClient);
+ ImageList_DragMove(ptClient.x, ptClient.y);
return drag_notify_subitem(grfKeyState, pt, pdwEffect);
}
HRESULT WINAPI CDefView::DragLeave()
{
+ ImageList_DragLeave(m_hWnd);
+
if (m_pCurDropTarget)
{
m_pCurDropTarget->DragLeave();
@@ -2960,6 +2981,8 @@
HRESULT WINAPI CDefView::Drop(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt,
DWORD *pdwEffect)
{
ERR("GetKeyState(VK_LBUTTON): %d\n", GetKeyState(VK_LBUTTON));
+
+ ImageList_EndDrag();
if ((m_iDragOverItem == -1 || m_pCurDropTarget == NULL) &&
(*pdwEffect & DROPEFFECT_MOVE) &&