[PATCH] Add IShellDetails support for notification handler, clean it up
Nikolay Sivov
nsivov at codeweavers.com
Sun Apr 25 04:57:31 CDT 2010
---
dlls/shell32/shlview.c | 479 +++++++++++++++++++++++-------------------------
1 files changed, 227 insertions(+), 252 deletions(-)
diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c
index b3d300a..c30da18 100644
--- a/dlls/shell32/shlview.c
+++ b/dlls/shell32/shlview.c
@@ -1295,307 +1295,282 @@ static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dw
*/
static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
-{ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
- NMLVDISPINFOW *lpdi = (NMLVDISPINFOW *)lpnmh;
- LPITEMIDLIST pidl;
-
- TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code);
-
- switch(lpnmh->code)
- {
- case NM_SETFOCUS:
- TRACE("-- NM_SETFOCUS %p\n",This);
- ShellView_OnSetFocus(This);
- break;
-
- case NM_KILLFOCUS:
- TRACE("-- NM_KILLFOCUS %p\n",This);
- ShellView_OnDeactivate(This);
- /* Notify the ICommDlgBrowser interface */
- OnStateChange(This,CDBOSC_KILLFOCUS);
- break;
+{
+ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
+ NMLVDISPINFOW *lpdi = (NMLVDISPINFOW *)lpnmh;
+ LPITEMIDLIST pidl;
- case NM_CUSTOMDRAW:
- TRACE("-- NM_CUSTOMDRAW %p\n",This);
- return CDRF_DODEFAULT;
+ TRACE("%p CtlID=%u lpnmh->code=0x%08x\n", This, CtlID, lpnmh->code);
- case NM_RELEASEDCAPTURE:
- TRACE("-- NM_RELEASEDCAPTURE %p\n",This);
- break;
+ switch (lpnmh->code)
+ {
+ case NM_SETFOCUS:
+ ShellView_OnSetFocus(This);
+ break;
- case NM_CLICK:
- TRACE("-- NM_CLICK %p\n",This);
- break;
+ case NM_KILLFOCUS:
+ ShellView_OnDeactivate(This);
+ /* Notify the ICommDlgBrowser interface */
+ OnStateChange(This, CDBOSC_KILLFOCUS);
+ break;
- case NM_RCLICK:
- TRACE("-- NM_RCLICK %p\n",This);
- break;
+ case NM_CUSTOMDRAW:
+ return CDRF_DODEFAULT;
- case NM_DBLCLK:
- TRACE("-- NM_DBLCLK %p\n",This);
+ case NM_DBLCLK:
if (OnDefaultCommand(This) != S_OK) ShellView_OpenSelectedItems(This);
break;
- case NM_RETURN:
- TRACE("-- NM_RETURN %p\n",This);
+ case NM_RETURN:
if (OnDefaultCommand(This) != S_OK) ShellView_OpenSelectedItems(This);
break;
- case HDN_ENDTRACKW:
- TRACE("-- HDN_ENDTRACKW %p\n",This);
- /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
- nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
- break;
-
- case LVN_DELETEITEM:
- TRACE("-- LVN_DELETEITEM %p\n",This);
- SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/
- break;
+ case LVN_DELETEITEM:
+ /* delete the pidl because we made a copy of it */
+ SHFree((LPITEMIDLIST)lpnmlv->lParam);
+ break;
- case LVN_DELETEALLITEMS:
- TRACE("-- LVN_DELETEALLITEMS %p\n",This);
- return FALSE;
+ case LVN_DELETEALLITEMS:
+ return FALSE;
- case LVN_INSERTITEM:
- TRACE("-- LVN_INSERTITEM (STUB)%p\n",This);
- break;
+ case LVN_ITEMACTIVATE:
+ /* the browser will get the IDataObject now */
+ OnStateChange(This, CDBOSC_SELCHANGE);
+ break;
- case LVN_ITEMACTIVATE:
- TRACE("-- LVN_ITEMACTIVATE %p\n",This);
- OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
- break;
+ case LVN_COLUMNCLICK:
+ This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem;
- case LVN_COLUMNCLICK:
- This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem;
- if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID)
- {
- This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending;
- }
- else
- {
- This->ListViewSortInfo.bIsAscending = TRUE;
- }
- This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
+ if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID)
+ {
+ This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending;
+ }
+ else
+ {
+ This->ListViewSortInfo.bIsAscending = TRUE;
+ }
+ This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
- SendMessageW(lpnmlv->hdr.hwndFrom, LVM_SORTITEMS, (WPARAM) &This->ListViewSortInfo, (LPARAM)ShellView_ListViewCompareItems);
- break;
+ SendMessageW(lpnmlv->hdr.hwndFrom, LVM_SORTITEMS, (WPARAM)&This->ListViewSortInfo, (LPARAM)ShellView_ListViewCompareItems);
+ break;
- case LVN_GETDISPINFOA:
- case LVN_GETDISPINFOW:
- TRACE("-- LVN_GETDISPINFO %p\n",This);
- pidl = (LPITEMIDLIST)lpdi->item.lParam;
+ case LVN_GETDISPINFOA:
+ case LVN_GETDISPINFOW:
+ pidl = (LPITEMIDLIST)lpdi->item.lParam;
- if(lpdi->item.mask & LVIF_TEXT) /* text requested */
+ if(lpdi->item.mask & LVIF_TEXT) /* text requested */
{
- if (This->pSF2Parent)
- {
- SHELLDETAILS sd;
- IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
- if (lpnmh->code == LVN_GETDISPINFOA)
+ IShellDetails *details;
+ SHELLDETAILS sd;
+ HRESULT hr;
+
+ if (This->pSF2Parent)
{
- /* shouldn't happen */
- NMLVDISPINFOA *lpdiA = (NMLVDISPINFOA *)lpnmh;
- StrRetToStrNA( lpdiA->item.pszText, lpdiA->item.cchTextMax, &sd.str, NULL);
- TRACE("-- text=%s\n",lpdiA->item.pszText);
+ IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
}
- else /* LVN_GETDISPINFOW */
+ else
+ {
+ hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IShellDetails, (void**)&details);
+ if (hr != S_OK)
+ {
+ WARN("IShellFolder2/IShellDetails not supported\n");
+ return 0;
+ }
+ IShellDetails_GetDetailsOf(details, pidl, lpdi->item.iSubItem, &sd);
+ IShellDetails_Release(details);
+ }
+
+ if (lpnmh->code == LVN_GETDISPINFOW)
{
StrRetToStrNW( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
TRACE("-- text=%s\n",debugstr_w(lpdi->item.pszText));
}
- }
- else
- {
- FIXME("no SF2\n");
- }
- }
- if(lpdi->item.mask & LVIF_IMAGE) /* image requested */
- {
- lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
- }
- break;
-
- case LVN_ITEMCHANGED:
- TRACE("-- LVN_ITEMCHANGED %p\n",This);
- OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
- break;
+ else
+ {
+ /* shouldn't happen too often */
+ NMLVDISPINFOA *lpdiA = (NMLVDISPINFOA *)lpnmh;
+ StrRetToStrNA( lpdiA->item.pszText, lpdiA->item.cchTextMax, &sd.str, NULL);
+ TRACE("-- text=%s\n",lpdiA->item.pszText);
+ }
+ }
- case LVN_BEGINDRAG:
- case LVN_BEGINRDRAG:
- TRACE("-- LVN_BEGINDRAG\n");
+ /* image requested */
+ if (lpdi->item.mask & LVIF_IMAGE)
+ {
+ lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
+ }
+ break;
- if (ShellView_GetSelections(This))
- {
- IDataObject * pda;
- DWORD dwAttributes = SFGAO_CANLINK;
- DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
+ case LVN_ITEMCHANGED:
+ /* the browser will get the IDataObject now */
+ OnStateChange(This, CDBOSC_SELCHANGE);
+ break;
- if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
- {
- IDropSource * pds = (IDropSource*)&(This->lpvtblDropSource); /* own DropSource interface */
+ case LVN_BEGINDRAG:
+ case LVN_BEGINRDRAG:
- if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, (LPCITEMIDLIST*)This->apidl, &dwAttributes)))
- {
- if (dwAttributes & SFGAO_CANLINK)
- {
- dwEffect |= DROPEFFECT_LINK;
- }
- }
+ if (ShellView_GetSelections(This))
+ {
+ DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
+ DWORD dwAttributes = SFGAO_CANLINK;
+ IDataObject * pda;
+ HRESULT hr;
- if (pds)
- {
- DWORD dwEffect2;
- DoDragDrop(pda, pds, dwEffect, &dwEffect2);
- }
- IDataObject_Release(pda);
- }
+ hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, &IID_IDataObject, 0, (void**)&pda);
+ if (hr == S_OK)
+ {
+ /* own DropSource interface */
+ IDropSource * pds = (IDropSource*)&(This->lpvtblDropSource);
+
+ hr = IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, (LPCITEMIDLIST*)This->apidl, &dwAttributes);
+ if (hr == S_OK && (dwAttributes & SFGAO_CANLINK))
+ {
+ dwEffect |= DROPEFFECT_LINK;
+ }
+
+ if (pds)
+ {
+ DWORD dwEffect2;
+ DoDragDrop(pda, pds, dwEffect, &dwEffect2);
+ }
+
+ IDataObject_Release(pda);
+ }
}
break;
- case LVN_BEGINLABELEDITW:
- {
- DWORD dwAttr = SFGAO_CANRENAME;
- pidl = (LPITEMIDLIST)lpdi->item.lParam;
+ case LVN_BEGINLABELEDITW:
+ {
+ DWORD attr = SFGAO_CANRENAME;
+ pidl = (LPITEMIDLIST)lpdi->item.lParam;
- TRACE("-- LVN_BEGINLABELEDITW %p\n",This);
+ IShellFolder_GetAttributesOf(This->pSFParent, 1, (LPCITEMIDLIST*)&pidl, &attr);
+ return (SFGAO_CANRENAME & attr) ? FALSE : TRUE;
+ }
- IShellFolder_GetAttributesOf(This->pSFParent, 1, (LPCITEMIDLIST*)&pidl, &dwAttr);
- if (SFGAO_CANRENAME & dwAttr)
- {
- return FALSE;
- }
- return TRUE;
- }
+ case LVN_ENDLABELEDITW:
+ {
+ if (lpdi->item.pszText)
+ {
+ HRESULT hr;
+ LVITEMW lvItem;
- case LVN_ENDLABELEDITW:
- {
- TRACE("-- LVN_ENDLABELEDITA %p\n",This);
- if (lpdi->item.pszText)
- {
- HRESULT hr;
- LVITEMW lvItem;
+ lvItem.iItem = lpdi->item.iItem;
+ lvItem.iSubItem = 0;
+ lvItem.mask = LVIF_PARAM;
+ SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
- lvItem.iItem = lpdi->item.iItem;
- lvItem.iSubItem = 0;
- lvItem.mask = LVIF_PARAM;
- SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
+ pidl = (LPITEMIDLIST)lpdi->item.lParam;
+ hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, lpdi->item.pszText, SHGDN_INFOLDER, &pidl);
- pidl = (LPITEMIDLIST)lpdi->item.lParam;
- hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, lpdi->item.pszText, SHGDN_INFOLDER, &pidl);
+ if (hr == S_OK && pidl)
+ {
+ lvItem.mask = LVIF_PARAM;
+ lvItem.lParam = (LPARAM)pidl;
+ SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM)&lvItem);
+ return TRUE;
+ }
+ }
- if(SUCCEEDED(hr) && pidl)
- {
- lvItem.mask = LVIF_PARAM;
- lvItem.lParam = (LPARAM)pidl;
- SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem);
- return TRUE;
- }
- }
- return FALSE;
- }
+ return FALSE;
+ }
+ case LVN_KEYDOWN:
+ {
+ LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
- case LVN_KEYDOWN:
- {
- /* MSG msg;
- msg.hwnd = This->hWnd;
- msg.message = WM_KEYDOWN;
- msg.wParam = plvKeyDown->wVKey;
- msg.lParam = 0;
- msg.time = 0;
- msg.pt = 0;*/
-
- LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
-
- /* initiate a rename of the selected file or directory */
- if(plvKeyDown->wVKey == VK_F2)
- {
+ switch (plvKeyDown->wVKey)
+ {
+ case VK_F2:
+ {
+ /* initiate a rename of the selected file or directory */
/* see how many files are selected */
- int i = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0);
+ INT i = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0);
/* get selected item */
- if(i == 1)
+ if (i == 1)
{
- /* get selected item */
- i = SendMessageW(This->hWndList, LVM_GETNEXTITEM, -1, MAKELPARAM (LVNI_SELECTED, 0));
+ /* get selected item */
+ i = SendMessageW(This->hWndList, LVM_GETNEXTITEM, -1, MAKELPARAM (LVNI_SELECTED, 0));
- SendMessageW(This->hWndList, LVM_ENSUREVISIBLE, i, 0);
- SendMessageW(This->hWndList, LVM_EDITLABELW, i, 0);
+ SendMessageW(This->hWndList, LVM_ENSUREVISIBLE, i, 0);
+ SendMessageW(This->hWndList, LVM_EDITLABELW, i, 0);
}
- }
-#if 0
- TranslateAccelerator(This->hWnd, This->hAccel, &msg)
-#endif
- else if(plvKeyDown->wVKey == VK_DELETE)
- {
- UINT i;
- int item_index;
- LVITEMA item;
- LPITEMIDLIST* pItems;
- ISFHelper *psfhlp;
-
- IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper,
- (LPVOID*)&psfhlp);
-
- if (psfhlp == NULL)
- break;
-
- if(!(i = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0)))
- break;
-
- /* allocate memory for the pidl array */
- pItems = HeapAlloc(GetProcessHeap(), 0,
- sizeof(LPITEMIDLIST) * i);
-
- /* retrieve all selected items */
- i = 0;
- item_index = -1;
- while(SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0) > i)
- {
- /* get selected item */
- item_index = SendMessageW(This->hWndList, LVM_GETNEXTITEM, item_index,
- MAKELPARAM (LVNI_SELECTED, 0));
- item.iItem = item_index;
- item.mask = LVIF_PARAM;
- SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &item);
-
- /* get item pidl */
- pItems[i] = (LPITEMIDLIST)item.lParam;
-
- i++;
- }
-
- /* perform the item deletion */
- ISFHelper_DeleteItems(psfhlp, i, (LPCITEMIDLIST*)pItems);
-
- /* free pidl array memory */
- HeapFree(GetProcessHeap(), 0, pItems);
- }
-
- /* Initiate a refresh */
- else if(plvKeyDown->wVKey == VK_F5)
- {
- IShellView_Refresh((IShellView*)This);
- }
+ break;
+ }
+ case VK_DELETE:
+ {
+ LPITEMIDLIST* pItems;
+ ISFHelper *psfhlp;
+ INT item_index;
+ LVITEMW item;
+ UINT i, count;
+
+ psfhlp = NULL;
+ IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (void**)&psfhlp);
+ if (psfhlp == NULL) return 0;
+
+ if(!(count = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0)))
+ return 0;
+
+ /* allocate memory for the pidl array */
+ pItems = HeapAlloc(GetProcessHeap(), 0, sizeof(LPITEMIDLIST) * count);
+
+ /* retrieve all selected items */
+ i = 0;
+ item_index = -1;
+ while (i < count)
+ {
+ /* get selected item */
+ item_index = SendMessageW(This->hWndList, LVM_GETNEXTITEM, item_index,
+ MAKELPARAM (LVNI_SELECTED, 0));
+ item.iItem = item_index;
+ item.mask = LVIF_PARAM;
+ SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &item);
+
+ /* get item pidl */
+ pItems[i] = (LPITEMIDLIST)item.lParam;
+
+ i++;
+ }
+
+ /* perform the item deletion */
+ ISFHelper_DeleteItems(psfhlp, i, (LPCITEMIDLIST*)pItems);
+
+ /* free pidl array memory */
+ HeapFree(GetProcessHeap(), 0, pItems);
+ break;
+ }
+ case VK_F5:
+ IShellView_Refresh((IShellView*)This);
+ break;
+ case VK_BACK:
+ {
+ LPSHELLBROWSER lpSb;
+
+ if((lpSb = (LPSHELLBROWSER)SendMessageW(This->hWndParent, CWM_GETISHELLBROWSER, 0, 0)))
+ {
+ IShellBrowser_BrowseObject(lpSb, NULL, SBSP_PARENT);
+ }
+ break;
+ }
+ default:
+ FIXME("LVN_KEYDOWN key=0x%08x\n", plvKeyDown->wVKey);
+ }
+ break;
+ }
- else if(plvKeyDown->wVKey == VK_BACK)
- {
- LPSHELLBROWSER lpSb;
- if((lpSb = (LPSHELLBROWSER)SendMessageW(This->hWndParent, CWM_GETISHELLBROWSER, 0, 0)))
- {
- IShellBrowser_BrowseObject(lpSb, NULL, SBSP_PARENT);
- }
- }
+ case NM_RELEASEDCAPTURE:
+ case NM_CLICK:
+ case NM_RCLICK:
+ case HDN_ENDTRACKW:
+ case LVN_INSERTITEM:
+ break;
- else
- FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey);
- }
- break;
+ default:
+ TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code);
+ }
- default:
- TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code);
- break;
- }
- return 0;
+ return 0;
}
/**********************************************************
--
1.5.6.5
--=-5q9C3RW9asDfanPPI1mA--
More information about the wine-patches
mailing list