4 * Copyright 1998,1999 <juergen.schmied@debitel.net>
6 * This is the view visualizing the data provied by the shellfolder.
7 * No direct access to data from pidls should be done from here.
9 * FIXME: There is not jet a official interface defined to manipulate
10 * the objects shown in the view (rename, move...). This should be
11 * implemented as additional interface to IShellFolder.
13 * FIXME: The order by part of the background context menu should be
14 * buily according to the columns shown.
16 * FIXME: Load/Save the view state from/into the stream provied by
19 * FIXME: CheckToolbar: handle the "new folder" and "folder up" button
21 * FIXME: ShellView_FillList: consider sort orders
23 * FIXME: implement the drag and drop in the old (msg-based) way
25 * FIXME: when the ShellView_WndProc gets a WM_NCDESTROY should we do a
33 #include "wine/obj_base.h"
34 #include "wine/obj_shellfolder.h"
35 #include "wine/obj_shellview.h"
36 #include "wine/obj_oleview.h"
37 #include "wine/obj_commdlgbrowser.h"
38 #include "wine/obj_shellbrowser.h"
39 #include "wine/obj_dockingwindowframe.h"
40 #include "wine/obj_extracticon.h"
41 #include "wine/obj_dragdrop.h"
42 #include "wine/undocshell.h"
45 #include "debugtools.h"
47 #include "wine/winestring.h"
51 #include "shell32_main.h"
53 DEFAULT_DEBUG_CHANNEL(shell)
59 }LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO;
62 { ICOM_VFIELD(IShellView);
64 ICOM_VTABLE(IOleCommandTarget)* lpvtblOleCommandTarget;
65 ICOM_VTABLE(IDropTarget)* lpvtblDropTarget;
66 ICOM_VTABLE(IDropSource)* lpvtblDropSource;
67 ICOM_VTABLE(IViewObject)* lpvtblViewObject;
68 IShellFolder* pSFParent;
69 IShellFolder2* pSF2Parent;
70 IShellBrowser* pShellBrowser;
71 ICommDlgBrowser* pCommDlgBrowser;
72 HWND hWnd; /* SHELLDLL_DefView */
73 HWND hWndList; /* ListView control */
75 FOLDERSETTINGS FolderSettings;
80 LISTVIEW_SORT_INFO ListViewSortInfo;
81 HANDLE hNotify; /* change notification handle */
85 static struct ICOM_VTABLE(IShellView) svvt;
87 static struct ICOM_VTABLE(IOleCommandTarget) ctvt;
88 #define _IOleCommandTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblOleCommandTarget)))
89 #define _ICOM_THIS_From_IOleCommandTarget(class, name) class* This = (class*)(((char*)name)-_IOleCommandTarget_Offset);
91 static struct ICOM_VTABLE(IDropTarget) dtvt;
92 #define _IDropTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropTarget)))
93 #define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
95 static struct ICOM_VTABLE(IDropSource) dsvt;
96 #define _IDropSource_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropSource)))
97 #define _ICOM_THIS_From_IDropSource(class, name) class* This = (class*)(((char*)name)-_IDropSource_Offset);
99 static struct ICOM_VTABLE(IViewObject) vovt;
100 #define _IViewObject_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblViewObject)))
101 #define _ICOM_THIS_From_IViewObject(class, name) class* This = (class*)(((char*)name)-_IViewObject_Offset);
103 /* ListView Header ID's */
104 #define LISTVIEW_COLUMN_NAME 0
105 #define LISTVIEW_COLUMN_SIZE 1
106 #define LISTVIEW_COLUMN_TYPE 2
107 #define LISTVIEW_COLUMN_TIME 3
108 #define LISTVIEW_COLUMN_ATTRIB 4
111 #define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500)
112 #define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501)
113 #define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502)
115 #define ID_LISTVIEW 2000
117 #define SHV_CHANGE_NOTIFY WM_USER + 0x1111
119 #define TOOLBAR_ID (L"SHELLDLL_DefView")
121 #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
122 #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
123 #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
125 #define WM_SETTINGCHANGE WM_WININICHANGE
126 extern void WINAPI _InsertMenuItem (HMENU hmenu, UINT indexMenu, BOOL fByPosition,
127 UINT wID, UINT fType, LPSTR dwTypeData, UINT fState);
130 Items merged into the toolbar and and the filemenu
139 } MYTOOLINFO, *LPMYTOOLINFO;
143 { FCIDM_SHVIEW_BIGICON, 0, 0, IDS_VIEW_LARGE, TBSTATE_ENABLED, TBSTYLE_BUTTON },
144 { FCIDM_SHVIEW_SMALLICON, 0, 0, IDS_VIEW_SMALL, TBSTATE_ENABLED, TBSTYLE_BUTTON },
145 { FCIDM_SHVIEW_LISTVIEW, 0, 0, IDS_VIEW_LIST, TBSTATE_ENABLED, TBSTYLE_BUTTON },
146 { FCIDM_SHVIEW_REPORTVIEW, 0, 0, IDS_VIEW_DETAILS, TBSTATE_ENABLED, TBSTYLE_BUTTON },
150 typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
152 /**********************************************************
153 * IShellView_Constructor
155 IShellView * IShellView_Constructor( IShellFolder * pFolder)
156 { IShellViewImpl * sv;
157 sv=(IShellViewImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl));
160 sv->lpvtblOleCommandTarget=&ctvt;
161 sv->lpvtblDropTarget=&dtvt;
162 sv->lpvtblDropSource=&dsvt;
163 sv->lpvtblViewObject=&vovt;
165 sv->pSFParent = pFolder;
166 if(pFolder) IShellFolder_AddRef(pFolder);
167 IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (LPVOID*)&sv->pSF2Parent);
169 TRACE("(%p)->(%p)\n",sv, pFolder);
171 return (IShellView *) sv;
174 /**********************************************************
176 * ##### helperfunctions for communication with ICommDlgBrowser #####
178 static BOOL IsInCommDlg(IShellViewImpl * This)
179 { return(This->pCommDlgBrowser != NULL);
182 static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl)
186 if ( IsInCommDlg(This) )
188 TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
189 ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView*)This, pidl);
190 TRACE("--0x%08lx\n", ret);
195 static HRESULT OnDefaultCommand(IShellViewImpl * This)
197 HRESULT ret = S_FALSE;
199 if (IsInCommDlg(This))
201 TRACE("ICommDlgBrowser::OnDefaultCommand\n");
202 ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView*)This);
208 static HRESULT OnStateChange(IShellViewImpl * This, UINT uFlags)
210 HRESULT ret = S_FALSE;
212 if (IsInCommDlg(This))
214 TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags);
215 ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView*)This, uFlags);
220 /**********************************************************
221 * set the toolbar of the filedialog buttons
223 * - activates the buttons from the shellbrowser according to
226 static void CheckToolbar(IShellViewImpl * This)
232 if (IsInCommDlg(This))
234 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
235 FCIDM_TB_SMALLICON, (This->FolderSettings.ViewMode==FVM_LIST)? TRUE : FALSE, &result);
236 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
237 FCIDM_TB_REPORTVIEW, (This->FolderSettings.ViewMode==FVM_DETAILS)? TRUE : FALSE, &result);
238 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
239 FCIDM_TB_SMALLICON, TRUE, &result);
240 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
241 FCIDM_TB_REPORTVIEW, TRUE, &result);
245 /**********************************************************
247 * ##### helperfunctions for initializing the view #####
249 /**********************************************************
250 * change the style of the listview control
252 static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove)
256 TRACE("(%p)\n", This);
258 tmpstyle = GetWindowLongA(This->hWndList, GWL_STYLE);
259 SetWindowLongA(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove));
262 /**********************************************************
263 * ShellView_CreateList()
265 * - creates the list view window
267 static BOOL ShellView_CreateList (IShellViewImpl * This)
272 dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
273 LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_AUTOARRANGE;
275 switch (This->FolderSettings.ViewMode)
277 case FVM_ICON: dwStyle |= LVS_ICON; break;
278 case FVM_DETAILS: dwStyle |= LVS_REPORT; break;
279 case FVM_SMALLICON: dwStyle |= LVS_SMALLICON; break;
280 case FVM_LIST: dwStyle |= LVS_LIST; break;
281 default: dwStyle |= LVS_LIST; break;
284 if (This->FolderSettings.fFlags & FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE;
285 /*if (This->FolderSettings.fFlags && FWF_DESKTOP); used from explorer*/
286 if (This->FolderSettings.fFlags & FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL;
288 This->hWndList=CreateWindowExA( WS_EX_CLIENTEDGE,
301 This->ListViewSortInfo.bIsAscending = TRUE;
302 This->ListViewSortInfo.nHeaderID = -1;
303 This->ListViewSortInfo.nLastHeaderID = -1;
305 /* UpdateShellSettings(); */
309 /**********************************************************
310 * ShellView_InitList()
312 * - adds all needed columns to the shellview
314 static BOOL ShellView_InitList(IShellViewImpl * This)
323 ListView_DeleteAllItems(This->hWndList);
325 lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
326 lvColumn.pszText = szTemp;
328 if (This->pSF2Parent)
332 if (!SUCCEEDED(IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, i, &sd)))
334 lvColumn.fmt = sd.fmt;
335 lvColumn.cx = sd.cxChar*8; /* chars->pixel */
336 StrRetToStrNA( szTemp, 50, &sd.str, NULL);
337 ListView_InsertColumnA(This->hWndList, i, &lvColumn);
345 ListView_SetImageList(This->hWndList, ShellSmallIconList, LVSIL_SMALL);
346 ListView_SetImageList(This->hWndList, ShellBigIconList, LVSIL_NORMAL);
350 /**********************************************************
351 * ShellView_CompareItems()
354 * internal, CALLBACK for DSA_Sort
356 static INT CALLBACK ShellView_CompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
359 TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1, lParam2, (LPVOID) lpData);
361 if(!lpData) return 0;
363 ret = (SHORT) SCODE_CODE(IShellFolder_CompareIDs((LPSHELLFOLDER)lpData, 0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2));
364 TRACE("ret=%i\n",ret);
368 /*************************************************************************
369 * ShellView_ListViewCompareItems
371 * Compare Function for the Listview (FileOpen Dialog)
374 * lParam1 [I] the first ItemIdList to compare with
375 * lParam2 [I] the second ItemIdList to compare with
376 * lpData [I] The column ID for the header Ctrl to process
379 * A negative value if the first item should precede the second,
380 * a positive value if the first item should follow the second,
381 * or zero if the two items are equivalent
384 * FIXME: function does what ShellView_CompareItems is supposed to do.
385 * unify it and figure out how to use the undocumented first parameter
386 * of IShellFolder_CompareIDs to do the job this function does and
387 * move this code to IShellFolder.
388 * make LISTVIEW_SORT_INFO obsolete
389 * the way this function works is only usable if we had only
390 * filesystemfolders (25/10/99 jsch)
392 static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
396 char strName1[MAX_PATH], strName2[MAX_PATH];
397 BOOL bIsFolder1, bIsFolder2,bIsBothFolder;
398 LPITEMIDLIST pItemIdList1 = (LPITEMIDLIST) lParam1;
399 LPITEMIDLIST pItemIdList2 = (LPITEMIDLIST) lParam2;
400 LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData;
403 bIsFolder1 = _ILIsFolder(pItemIdList1);
404 bIsFolder2 = _ILIsFolder(pItemIdList2);
405 bIsBothFolder = bIsFolder1 && bIsFolder2;
407 /* When sorting between a File and a Folder, the Folder gets sorted first */
408 if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder)
410 nDiff = bIsFolder1 ? -1 : 1;
414 /* Sort by Time: Folders or Files can be sorted */
416 if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)
418 _ILGetFileDateTime(pItemIdList1, &fd1);
419 _ILGetFileDateTime(pItemIdList2, &fd2);
420 nDiff = CompareFileTime(&fd2, &fd1);
422 /* Sort by Attribute: Folder or Files can be sorted */
423 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB)
425 _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH);
426 _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH);
427 nDiff = strcasecmp(strName1, strName2);
429 /* Sort by FileName: Folder or Files can be sorted */
430 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder)
433 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
434 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
435 nDiff = strcasecmp(strName1, strName2);
437 /* Sort by File Size, Only valid for Files */
438 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)
440 nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0));
442 /* Sort by File Type, Only valid for Files */
443 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)
446 _ILGetFileType(pItemIdList1, strName1, MAX_PATH);
447 _ILGetFileType(pItemIdList2, strName2, MAX_PATH);
448 nDiff = strcasecmp(strName1, strName2);
451 /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
455 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
456 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
457 nDiff = strcasecmp(strName1, strName2);
460 if(!pSortInfo->bIsAscending)
469 /**********************************************************
470 * LV_FindItemByPidl()
472 static int LV_FindItemByPidl(
473 IShellViewImpl * This,
477 ZeroMemory(&lvItem, sizeof(LVITEMA));
478 lvItem.mask = LVIF_PARAM;
479 for(lvItem.iItem = 0; ListView_GetItemA(This->hWndList, &lvItem); lvItem.iItem++)
481 LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam;
482 HRESULT hr = IShellFolder_CompareIDs(This->pSFParent, 0, pidl, currentpidl);
483 if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
491 /**********************************************************
494 static BOOLEAN LV_AddItem(IShellViewImpl * This, LPITEMIDLIST pidl)
498 FIXME("(%p)(pidl=%p)\n", This, pidl);
500 ZeroMemory(&lvItem, sizeof(lvItem)); /* create the listview item*/
501 lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; /*set the mask*/
502 lvItem.iItem = ListView_GetItemCount(This->hWndList); /*add the item to the end of the list*/
503 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidl)); /*set the item's data*/
504 lvItem.pszText = LPSTR_TEXTCALLBACKA; /*get text on a callback basis*/
505 lvItem.iImage = I_IMAGECALLBACK; /*get the image on a callback basis*/
506 return (-1==ListView_InsertItemA(This->hWndList, &lvItem))? FALSE: TRUE;
509 /**********************************************************
512 static BOOLEAN LV_DeleteItem(IShellViewImpl * This, LPITEMIDLIST pidl)
516 FIXME("(%p)(pidl=%p)\n", This, pidl);
518 nIndex = LV_FindItemByPidl(This, ILFindLastID(pidl));
519 return (-1==ListView_DeleteItem(This->hWndList, nIndex))? FALSE: TRUE;
522 /**********************************************************
525 static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPITEMIDLIST pidlOld, LPITEMIDLIST pidlNew )
530 FIXME("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew);
532 nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld));
535 ZeroMemory(&lvItem, sizeof(lvItem)); /* create the listview item*/
536 lvItem.mask = LVIF_PARAM; /* only the pidl */
537 lvItem.iItem = nItem;
538 ListView_GetItemA(This->hWndList, &lvItem);
540 SHFree((LPITEMIDLIST)lvItem.lParam);
541 lvItem.mask = LVIF_PARAM;
542 lvItem.iItem = nItem;
543 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew)); /* set the item's data */
544 ListView_SetItemA(This->hWndList, &lvItem);
545 ListView_Update(This->hWndList, nItem);
546 return TRUE; /* fixme: better handling */
550 /**********************************************************
551 * ShellView_FillList()
553 * - gets the objectlist from the shellfolder
555 * - fills the list into the view
558 static HRESULT ShellView_FillList(IShellViewImpl * This)
560 LPENUMIDLIST pEnumIDList;
569 /* get the itemlist from the shfolder*/
570 hRes = IShellFolder_EnumObjects(This->pSFParent,This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList);
578 /* create a pointer array */
579 hdpa = pDPA_Create(16);
582 return(E_OUTOFMEMORY);
585 /* copy the items into the array*/
586 while((S_OK == IEnumIDList_Next(pEnumIDList,1, &pidl, &dwFetched)) && dwFetched)
588 if (pDPA_InsertPtr(hdpa, 0x7fff, pidl) == -1)
595 pDPA_Sort(hdpa, ShellView_CompareItems, (LPARAM)This->pSFParent);
597 /*turn the listview's redrawing off*/
598 SendMessageA(This->hWndList, WM_SETREDRAW, FALSE, 0);
600 for (i=0; i < DPA_GetPtrCount(hdpa); ++i) /* DPA_GetPtrCount is a macro*/
602 pidl = (LPITEMIDLIST)DPA_GetPtr(hdpa, i);
604 /* in a commdlg This works as a filemask*/
605 if ( IncludeObject(This, pidl)==S_OK )
607 if(! LV_AddItem(This, pidl)) SHFree(pidl); /* insert failed: PIDL not owned by the LV */
611 SHFree(pidl); /* not inserted */
615 /*turn the listview's redrawing back on and force it to draw*/
616 SendMessageA(This->hWndList, WM_SETREDRAW, TRUE, 0);
618 IEnumIDList_Release(pEnumIDList); /* destroy the list*/
624 /**********************************************************
625 * ShellView_OnCreate()
627 static LRESULT ShellView_OnCreate(IShellViewImpl * This)
630 NOTIFYREGISTER ntreg;
631 IPersistFolder2 * ppf2 = NULL;
635 if(ShellView_CreateList(This))
637 if(ShellView_InitList(This))
639 ShellView_FillList(This);
645 if (SUCCEEDED(IShellFolder_CreateViewObject(This->pSFParent, This->hWnd, &IID_IDropTarget, (LPVOID*)&pdt)))
647 pRegisterDragDrop(This->hWnd, pdt);
648 IDropTarget_Release(pdt);
652 /* register for receiving notifications */
653 IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2);
656 IPersistFolder2_GetCurFolder(ppf2, &ntreg.pidlPath);
657 ntreg.bWatchSubtree = FALSE;
658 This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNF_IDLIST, SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg);
659 SHFree(ntreg.pidlPath);
660 IPersistFolder2_Release(ppf2);
663 This->hAccel = LoadAcceleratorsA(shell32_hInstance, "shv_accel");
668 /**********************************************************
669 * #### Handling of the menus ####
672 /**********************************************************
673 * ShellView_BuildFileMenu()
675 static HMENU ShellView_BuildFileMenu(IShellViewImpl * This)
676 { CHAR szText[MAX_PATH];
681 TRACE("(%p)\n",This);
683 hSubMenu = CreatePopupMenu();
685 { /*get the number of items in our global array*/
686 for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){}
688 /*add the menu items*/
689 for(i = 0; i < nTools; i++)
691 LoadStringA(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH);
693 ZeroMemory(&mii, sizeof(mii));
694 mii.cbSize = sizeof(mii);
695 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
697 if(TBSTYLE_SEP != Tools[i].bStyle) /* no seperator*/
699 mii.fType = MFT_STRING;
700 mii.fState = MFS_ENABLED;
701 mii.dwTypeData = szText;
702 mii.wID = Tools[i].idCommand;
706 mii.fType = MFT_SEPARATOR;
708 /* tack This item onto the end of the menu */
709 InsertMenuItemA(hSubMenu, (UINT)-1, TRUE, &mii);
712 TRACE("-- return (menu=0x%x)\n",hSubMenu);
715 /**********************************************************
716 * ShellView_MergeFileMenu()
718 static void ShellView_MergeFileMenu(IShellViewImpl * This, HMENU hSubMenu)
719 { TRACE("(%p)->(submenu=0x%08x) stub\n",This,hSubMenu);
722 { /*insert This item at the beginning of the menu */
723 _InsertMenuItem(hSubMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
724 _InsertMenuItem(hSubMenu, 0, TRUE, IDM_MYFILEITEM, MFT_STRING, "dummy45", MFS_ENABLED);
730 /**********************************************************
731 * ShellView_MergeViewMenu()
734 static void ShellView_MergeViewMenu(IShellViewImpl * This, HMENU hSubMenu)
737 TRACE("(%p)->(submenu=0x%08x)\n",This,hSubMenu);
740 { /*add a separator at the correct position in the menu*/
741 _InsertMenuItem(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
743 ZeroMemory(&mii, sizeof(mii));
744 mii.cbSize = sizeof(mii);
745 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;;
746 mii.fType = MFT_STRING;
747 mii.dwTypeData = "View";
748 mii.hSubMenu = LoadMenuA(shell32_hInstance, "MENU_001");
749 InsertMenuItemA(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
753 /**********************************************************
754 * ShellView_GetSelections()
756 * - fills the this->apidl list with the selected objects
759 * number of selected items
761 static UINT ShellView_GetSelections(IShellViewImpl * This)
771 This->cidl = ListView_GetSelectedCount(This->hWndList);
772 This->apidl = (LPITEMIDLIST*)SHAlloc(This->cidl * sizeof(LPITEMIDLIST));
774 TRACE("selected=%i\n", This->cidl);
778 TRACE("-- Items selected =%u\n", This->cidl);
780 ZeroMemory(&lvItem, sizeof(lvItem));
781 lvItem.mask = LVIF_STATE | LVIF_PARAM;
782 lvItem.stateMask = LVIS_SELECTED;
784 while(ListView_GetItemA(This->hWndList, &lvItem) && (i < This->cidl))
786 if(lvItem.state & LVIS_SELECTED)
788 This->apidl[i] = (LPITEMIDLIST)lvItem.lParam;
790 TRACE("-- selected Item found\n");
798 /**********************************************************
799 * ShellView_DoContextMenu()
801 static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL bDefault)
805 BOOL fExplore = FALSE;
807 LPCONTEXTMENU pContextMenu = NULL;
808 IContextMenu * pCM = NULL;
809 CMINVOKECOMMANDINFO cmi;
811 TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, bDefault);
813 /* look, what's selected and create a context menu object of it*/
814 if( ShellView_GetSelections(This) )
816 IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, This->apidl,
817 (REFIID)&IID_IContextMenu, NULL, (LPVOID *)&pContextMenu);
821 TRACE("-- pContextMenu\n");
822 hMenu = CreatePopupMenu();
826 /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
827 if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree)
829 TRACE("-- explore mode\n");
833 /* build the flags depending on what we can do with the selected item */
834 wFlags = CMF_NORMAL | (This->cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0);
836 /* let the ContextMenu merge its items in */
837 if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags )))
841 TRACE("-- get menu default command\n");
842 uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS);
846 TRACE("-- track popup\n");
847 uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
852 TRACE("-- uCommand=%u\n", uCommand);
853 if (IsInCommDlg(This) && ((uCommand==FCIDM_SHVIEW_EXPLORE) || (uCommand==FCIDM_SHVIEW_OPEN)))
855 TRACE("-- dlg: OnDefaultCommand\n");
856 OnDefaultCommand(This);
860 TRACE("-- explore -- invoke command\n");
861 ZeroMemory(&cmi, sizeof(cmi));
862 cmi.cbSize = sizeof(cmi);
863 cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */
864 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
865 IContextMenu_InvokeCommand(pContextMenu, &cmi);
872 IContextMenu_Release(pContextMenu);
875 else /* background context menu */
877 hMenu = CreatePopupMenu();
879 pCM = ISvBgCm_Constructor(This->pSFParent);
880 IContextMenu_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
882 uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
885 TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand);
887 ZeroMemory(&cmi, sizeof(cmi));
888 cmi.cbSize = sizeof(cmi);
889 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
890 cmi.hwnd = This->hWndParent;
891 IContextMenu_InvokeCommand(pCM, &cmi);
893 IContextMenu_Release(pCM);
897 /**********************************************************
898 * ##### message handling #####
901 /**********************************************************
904 static LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight)
906 TRACE("%p width=%u height=%u\n",This, wWidth,wHeight);
908 /*resize the ListView to fit our window*/
911 MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE);
916 /**********************************************************
917 * ShellView_OnDeactivate()
922 static void ShellView_OnDeactivate(IShellViewImpl * This)
926 if(This->uState != SVUIA_DEACTIVATE)
930 IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0);
931 IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu);
932 DestroyMenu(This->hMenu);
936 This->uState = SVUIA_DEACTIVATE;
940 /**********************************************************
941 * ShellView_OnActivate()
943 static LRESULT ShellView_OnActivate(IShellViewImpl * This, UINT uState)
944 { OLEMENUGROUPWIDTHS omw = { {0, 0, 0, 0, 0, 0} };
946 CHAR szText[MAX_PATH];
948 TRACE("%p uState=%x\n",This,uState);
950 /*don't do anything if the state isn't really changing */
951 if(This->uState == uState)
956 ShellView_OnDeactivate(This);
958 /*only do This if we are active */
959 if(uState != SVUIA_DEACTIVATE)
962 This->hMenu = CreateMenu();
966 IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw);
967 TRACE("-- after fnInsertMenusSB\n");
969 /*build the top level menu get the menu item's text*/
970 strcpy(szText,"dummy 31");
972 ZeroMemory(&mii, sizeof(mii));
973 mii.cbSize = sizeof(mii);
974 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
975 mii.fType = MFT_STRING;
976 mii.fState = MFS_ENABLED;
977 mii.dwTypeData = szText;
978 mii.hSubMenu = ShellView_BuildFileMenu(This);
980 /*insert our menu into the menu bar*/
983 InsertMenuItemA(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii);
986 /*get the view menu so we can merge with it*/
987 ZeroMemory(&mii, sizeof(mii));
988 mii.cbSize = sizeof(mii);
989 mii.fMask = MIIM_SUBMENU;
991 if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii))
993 ShellView_MergeViewMenu(This, mii.hSubMenu);
996 /*add the items that should only be added if we have the focus*/
997 if(SVUIA_ACTIVATE_FOCUS == uState)
999 /*get the file menu so we can merge with it */
1000 ZeroMemory(&mii, sizeof(mii));
1001 mii.cbSize = sizeof(mii);
1002 mii.fMask = MIIM_SUBMENU;
1004 if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii))
1006 ShellView_MergeFileMenu(This, mii.hSubMenu);
1009 TRACE("-- before fnSetMenuSB\n");
1010 IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd);
1013 This->uState = uState;
1018 /**********************************************************
1019 * ShellView_OnSetFocus()
1022 static LRESULT ShellView_OnSetFocus(IShellViewImpl * This)
1026 /* Tell the browser one of our windows has received the focus. This
1027 should always be done before merging menus (OnActivate merges the
1028 menus) if one of our windows has the focus.*/
1030 IShellBrowser_OnViewWindowActive(This->pShellBrowser,(IShellView*) This);
1031 ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS);
1033 /* Set the focus to the listview */
1034 SetFocus(This->hWndList);
1036 /* Notify the ICommDlgBrowser interface */
1037 OnStateChange(This,CDBOSC_SETFOCUS);
1042 /**********************************************************
1043 * ShellView_OnKillFocus()
1045 static LRESULT ShellView_OnKillFocus(IShellViewImpl * This)
1047 TRACE("(%p) stub\n",This);
1049 ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS);
1050 /* Notify the ICommDlgBrowser */
1051 OnStateChange(This,CDBOSC_KILLFOCUS);
1056 /**********************************************************
1057 * ShellView_OnCommand()
1060 * the CmdID's are the ones from the context menu
1062 static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd)
1064 TRACE("(%p)->(0x%08lx 0x%08lx 0x%08x) stub\n",This, dwCmdID, dwCmd, hwndCmd);
1068 case FCIDM_SHVIEW_SMALLICON:
1069 This->FolderSettings.ViewMode = FVM_SMALLICON;
1070 SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK);
1074 case FCIDM_SHVIEW_BIGICON:
1075 This->FolderSettings.ViewMode = FVM_ICON;
1076 SetStyle (This, LVS_ICON, LVS_TYPEMASK);
1080 case FCIDM_SHVIEW_LISTVIEW:
1081 This->FolderSettings.ViewMode = FVM_LIST;
1082 SetStyle (This, LVS_LIST, LVS_TYPEMASK);
1086 case FCIDM_SHVIEW_REPORTVIEW:
1087 This->FolderSettings.ViewMode = FVM_DETAILS;
1088 SetStyle (This, LVS_REPORT, LVS_TYPEMASK);
1092 /* the menu-ID's for sorting are 0x30... see shrec.rc */
1097 This->ListViewSortInfo.nHeaderID = (LPARAM) (dwCmdID - 0x30);
1098 This->ListViewSortInfo.bIsAscending = TRUE;
1099 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1100 ListView_SortItems(This->hWndList, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1104 TRACE("-- COMMAND 0x%04lx unhandled\n", dwCmdID);
1109 /**********************************************************
1110 * ShellView_OnNotify()
1113 static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
1114 { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
1115 NMLVDISPINFOA *lpdi = (NMLVDISPINFOA *)lpnmh;
1118 TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code);
1123 TRACE("-- NM_SETFOCUS %p\n",This);
1124 ShellView_OnSetFocus(This);
1128 TRACE("-- NM_KILLFOCUS %p\n",This);
1129 ShellView_OnDeactivate(This);
1130 /* Notify the ICommDlgBrowser interface */
1131 OnStateChange(This,CDBOSC_KILLFOCUS);
1135 TRACE("-- HDN_ENDTRACKA %p\n",This);
1136 /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
1137 nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
1140 case LVN_DELETEITEM:
1141 TRACE("-- LVN_DELETEITEM %p\n",This);
1142 SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/
1145 case LVN_ITEMACTIVATE:
1146 TRACE("-- LVN_ITEMACTIVATE %p\n",This);
1147 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1148 ShellView_DoContextMenu(This, 0, 0, TRUE);
1151 case LVN_COLUMNCLICK:
1152 This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem;
1153 if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID)
1155 This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending;
1159 This->ListViewSortInfo.bIsAscending = TRUE;
1161 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1163 ListView_SortItems(lpnmlv->hdr.hwndFrom, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1166 case LVN_GETDISPINFOA:
1167 TRACE("-- LVN_GETDISPINFOA %p\n",This);
1168 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1170 if(lpdi->item.mask & LVIF_TEXT) /* text requested */
1172 if (This->pSF2Parent)
1175 IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
1176 StrRetToStrNA( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1177 TRACE("-- text=%s\n",lpdi->item.pszText);
1184 if(lpdi->item.mask & LVIF_IMAGE) /* image requested */
1186 lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
1190 case LVN_ITEMCHANGED:
1191 TRACE("-- LVN_ITEMCHANGED %p\n",This);
1192 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1196 case LVN_BEGINRDRAG:
1197 TRACE("-- LVN_BEGINDRAG\n");
1199 if (ShellView_GetSelections(This))
1203 DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
1207 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
1209 IDropSource * pds = (IDropSource*)&(This->lpvtblDropSource); /* own DropSource interface */
1211 if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, This->apidl, &dwAttributes)))
1213 if (dwAttributes & SFGAO_CANLINK)
1215 dwEffect |= DROPEFFECT_LINK;
1222 pDoDragDrop(pda, pds, dwEffect, &dwEffect);
1224 IDataObject_Release(pda);
1230 case LVN_BEGINLABELEDITA:
1232 DWORD dwAttr = SFGAO_CANRENAME;
1233 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1235 TRACE("-- LVN_BEGINLABELEDITA %p\n",This);
1237 IShellFolder_GetAttributesOf(This->pSFParent, 1, &pidl, &dwAttr);
1238 if (SFGAO_CANRENAME & dwAttr)
1246 case LVN_ENDLABELEDITA:
1248 TRACE("-- LVN_ENDLABELEDITA %p\n",This);
1249 if (lpdi->item.pszText)
1252 WCHAR wszNewName[MAX_PATH];
1255 ZeroMemory(&lvItem, sizeof(LVITEMA));
1256 lvItem.iItem = lpdi->item.iItem;
1257 lvItem.mask = LVIF_PARAM;
1258 ListView_GetItemA(This->hWndList, &lvItem);
1260 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1261 lstrcpynAtoW(wszNewName, lpdi->item.pszText, MAX_PATH);
1262 hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, wszNewName, SHGDN_INFOLDER, &pidl);
1264 if(SUCCEEDED(hr) && pidl)
1266 lvItem.mask = LVIF_PARAM;
1267 lvItem.lParam = (LPARAM)pidl;
1268 ListView_SetItemA(This->hWndList, &lvItem);
1279 msg.hwnd = This->hWnd;
1280 msg.message = WM_KEYDOWN;
1281 msg.wParam = plvKeyDown->wVKey;
1286 LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
1287 // TranslateAccelerator(This->hWnd, This->hAccel, &msg)
1288 FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey);
1292 TRACE("-- %p WM_COMMAND %s unhandled\n", This, SPY_GetMsgName(lpnmh->code));
1298 /**********************************************************
1299 * ShellView_OnChange()
1302 static LRESULT ShellView_OnChange(IShellViewImpl * This, LPITEMIDLIST * Pidls, LONG wEventId)
1305 TRACE("(%p)(%p,%p,0x%08lx)\n", This, Pidls[0], Pidls[1], wEventId);
1310 LV_AddItem(This, Pidls[0]);
1314 LV_DeleteItem(This, Pidls[0]);
1316 case SHCNE_RENAMEFOLDER:
1317 case SHCNE_RENAMEITEM:
1318 LV_RenameItem(This, Pidls[0], Pidls[1]);
1320 case SHCNE_UPDATEITEM:
1325 /**********************************************************
1329 static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1331 IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongA(hWnd, GWL_USERDATA);
1332 LPCREATESTRUCTA lpcs;
1334 TRACE("(hwnd=%x msg=%x wparm=%x lparm=%lx)\n",hWnd, uMessage, wParam, lParam);
1339 lpcs = (LPCREATESTRUCTA)lParam;
1340 pThis = (IShellViewImpl*)(lpcs->lpCreateParams);
1341 SetWindowLongA(hWnd, GWL_USERDATA, (LONG)pThis);
1342 pThis->hWnd = hWnd; /*set the window handle*/
1345 case WM_SIZE: return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam));
1346 case WM_SETFOCUS: return ShellView_OnSetFocus(pThis);
1347 case WM_KILLFOCUS: return ShellView_OnKillFocus(pThis);
1348 case WM_CREATE: return ShellView_OnCreate(pThis);
1349 case WM_ACTIVATE: return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS);
1350 case WM_NOTIFY: return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam);
1351 case WM_COMMAND: return ShellView_OnCommand(pThis,
1352 GET_WM_COMMAND_ID(wParam, lParam),
1353 GET_WM_COMMAND_CMD(wParam, lParam),
1354 GET_WM_COMMAND_HWND(wParam, lParam));
1355 case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (LPITEMIDLIST*)wParam, (LONG)lParam);
1357 case WM_CONTEXTMENU: ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE);
1360 case WM_SHOWWINDOW: UpdateWindow(pThis->hWndList);
1363 case WM_GETDLGCODE: return SendMessageA(pThis->hWndList,uMessage,0,0);
1365 case WM_DESTROY: if(GetShellOle())
1367 pRevokeDragDrop(pThis->hWnd);
1369 SHChangeNotifyDeregister(pThis->hNotify);
1373 return DefWindowProcA (hWnd, uMessage, wParam, lParam);
1375 /**********************************************************
1378 * The INTERFACE of the IShellView object
1381 **********************************************************
1382 * IShellView_QueryInterface
1384 static HRESULT WINAPI IShellView_fnQueryInterface(IShellView * iface,REFIID riid, LPVOID *ppvObj)
1386 ICOM_THIS(IShellViewImpl, iface);
1388 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1392 if(IsEqualIID(riid, &IID_IUnknown))
1396 else if(IsEqualIID(riid, &IID_IShellView))
1398 *ppvObj = (IShellView*)This;
1400 else if(IsEqualIID(riid, &IID_IOleCommandTarget))
1402 *ppvObj = (IOleCommandTarget*)&(This->lpvtblOleCommandTarget);
1404 else if(IsEqualIID(riid, &IID_IDropTarget))
1406 *ppvObj = (IDropTarget*)&(This->lpvtblDropTarget);
1408 else if(IsEqualIID(riid, &IID_IDropSource))
1410 *ppvObj = (IDropSource*)&(This->lpvtblDropSource);
1412 else if(IsEqualIID(riid, &IID_IViewObject))
1414 *ppvObj = (IViewObject*)&(This->lpvtblViewObject);
1419 IUnknown_AddRef( (IUnknown*)*ppvObj );
1420 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1423 TRACE("-- Interface: E_NOINTERFACE\n");
1424 return E_NOINTERFACE;
1427 /**********************************************************
1430 static ULONG WINAPI IShellView_fnAddRef(IShellView * iface)
1432 ICOM_THIS(IShellViewImpl, iface);
1434 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1437 return ++(This->ref);
1439 /**********************************************************
1440 * IShellView_Release
1442 static ULONG WINAPI IShellView_fnRelease(IShellView * iface)
1444 ICOM_THIS(IShellViewImpl, iface);
1446 TRACE("(%p)->()\n",This);
1452 TRACE(" destroying IShellView(%p)\n",This);
1455 IShellFolder_Release(This->pSFParent);
1457 if(This->pSF2Parent)
1458 IShellFolder2_Release(This->pSF2Parent);
1461 SHFree(This->apidl);
1463 if (This->pCommDlgBrowser)
1464 ICommDlgBrowser_Release(This->pCommDlgBrowser);
1466 HeapFree(GetProcessHeap(),0,This);
1472 /**********************************************************
1473 * ShellView_GetWindow
1475 static HRESULT WINAPI IShellView_fnGetWindow(IShellView * iface,HWND * phWnd)
1477 ICOM_THIS(IShellViewImpl, iface);
1479 TRACE("(%p)\n",This);
1481 *phWnd = This->hWnd;
1486 static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView * iface,BOOL fEnterMode)
1488 ICOM_THIS(IShellViewImpl, iface);
1490 FIXME("(%p) stub\n",This);
1495 /**********************************************************
1496 * IShellView_TranslateAccelerator
1499 * use the accel functions
1501 static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg)
1504 ICOM_THIS(IShellViewImpl, iface);
1506 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1509 if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST))
1511 TRACE("-- key=0x04%x",lpmsg->wParam) ;
1513 return S_FALSE; /* not handled */
1516 static HRESULT WINAPI IShellView_fnEnableModeless(IShellView * iface,BOOL fEnable)
1518 ICOM_THIS(IShellViewImpl, iface);
1520 FIXME("(%p) stub\n",This);
1525 static HRESULT WINAPI IShellView_fnUIActivate(IShellView * iface,UINT uState)
1527 ICOM_THIS(IShellViewImpl, iface);
1530 CHAR szName[MAX_PATH];
1533 int nPartArray[1] = {-1};
1535 TRACE("(%p)->(state=%x) stub\n",This, uState);
1537 /*don't do anything if the state isn't really changing*/
1538 if(This->uState == uState)
1543 /*OnActivate handles the menu merging and internal state*/
1544 ShellView_OnActivate(This, uState);
1546 /*only do This if we are active*/
1547 if(uState != SVUIA_DEACTIVATE)
1551 GetFolderPath is not a method of IShellFolder
1552 IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1554 /* set the number of parts */
1555 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1556 (LPARAM)nPartArray, &lResult);
1558 /* set the text for the parts */
1560 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1561 0, (LPARAM)szName, &lResult);
1568 static HRESULT WINAPI IShellView_fnRefresh(IShellView * iface)
1570 ICOM_THIS(IShellViewImpl, iface);
1572 TRACE("(%p)\n",This);
1574 ListView_DeleteAllItems(This->hWndList);
1575 ShellView_FillList(This);
1580 static HRESULT WINAPI IShellView_fnCreateViewWindow(
1582 IShellView *lpPrevView,
1583 LPCFOLDERSETTINGS lpfs,
1584 IShellBrowser * psb,
1588 ICOM_THIS(IShellViewImpl, iface);
1594 TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This, lpPrevView,lpfs, psb, prcView, phWnd);
1595 TRACE("-- vmode=%x flags=%x left=%i top=%i right=%i bottom=%i\n",lpfs->ViewMode, lpfs->fFlags ,prcView->left,prcView->top, prcView->right, prcView->bottom);
1597 /*set up the member variables*/
1598 This->pShellBrowser = psb;
1599 This->FolderSettings = *lpfs;
1601 /*get our parent window*/
1602 IShellBrowser_AddRef(This->pShellBrowser);
1603 IShellBrowser_GetWindow(This->pShellBrowser, &(This->hWndParent));
1605 /* try to get the ICommDlgBrowserInterface, adds a reference !!! */
1606 This->pCommDlgBrowser=NULL;
1607 if ( SUCCEEDED (IShellBrowser_QueryInterface( This->pShellBrowser,
1608 (REFIID)&IID_ICommDlgBrowser, (LPVOID*) &This->pCommDlgBrowser)))
1610 TRACE("-- CommDlgBrowser\n");
1613 /*if our window class has not been registered, then do so*/
1614 if(!GetClassInfoA(shell32_hInstance, SV_CLASS_NAME, &wc))
1616 ZeroMemory(&wc, sizeof(wc));
1617 wc.style = CS_HREDRAW | CS_VREDRAW;
1618 wc.lpfnWndProc = (WNDPROC) ShellView_WndProc;
1621 wc.hInstance = shell32_hInstance;
1623 wc.hCursor = LoadCursorA (0, IDC_ARROWA);
1624 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
1625 wc.lpszMenuName = NULL;
1626 wc.lpszClassName = SV_CLASS_NAME;
1628 if(!RegisterClassA(&wc))
1632 *phWnd = CreateWindowExA(0,
1635 WS_CHILD | WS_VISIBLE | WS_TABSTOP,
1638 prcView->right - prcView->left,
1639 prcView->bottom - prcView->top,
1647 if(!*phWnd) return E_FAIL;
1652 static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView * iface)
1654 ICOM_THIS(IShellViewImpl, iface);
1656 TRACE("(%p)\n",This);
1658 /*Make absolutely sure all our UI is cleaned up.*/
1659 IShellView_UIActivate((IShellView*)This, SVUIA_DEACTIVATE);
1663 DestroyMenu(This->hMenu);
1666 DestroyWindow(This->hWnd);
1667 IShellBrowser_Release(This->pShellBrowser);
1672 static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView * iface, LPFOLDERSETTINGS lpfs)
1674 ICOM_THIS(IShellViewImpl, iface);
1676 TRACE("(%p)->(%p) vmode=%x flags=%x\n",This, lpfs,
1677 This->FolderSettings.ViewMode, This->FolderSettings.fFlags);
1679 if (!lpfs) return E_INVALIDARG;
1681 *lpfs = This->FolderSettings;
1685 static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView * iface, DWORD dwReserved,LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
1687 ICOM_THIS(IShellViewImpl, iface);
1689 FIXME("(%p) stub\n",This);
1694 static HRESULT WINAPI IShellView_fnSaveViewState(IShellView * iface)
1696 ICOM_THIS(IShellViewImpl, iface);
1698 FIXME("(%p) stub\n",This);
1703 static HRESULT WINAPI IShellView_fnSelectItem(
1708 ICOM_THIS(IShellViewImpl, iface);
1711 TRACE("(%p)->(pidl=%p, 0x%08x) stub\n",This, pidl, uFlags);
1713 i = LV_FindItemByPidl(This, pidl);
1719 if(uFlags & SVSI_ENSUREVISIBLE)
1720 ListView_EnsureVisible(This->hWndList, i, 0);
1722 ZeroMemory(&lvItem, sizeof(LVITEMA));
1723 lvItem.mask = LVIF_STATE;
1726 while(ListView_GetItemA(This->hWndList, &lvItem))
1728 if (lvItem.iItem == i)
1730 if (uFlags & SVSI_SELECT)
1731 lvItem.state |= LVIS_SELECTED;
1733 lvItem.state &= ~LVIS_SELECTED;
1735 if(uFlags & SVSI_FOCUSED)
1736 lvItem.state &= ~LVIS_FOCUSED;
1740 if (uFlags & SVSI_DESELECTOTHERS)
1741 lvItem.state &= ~LVIS_SELECTED;
1743 ListView_SetItemA(This->hWndList, &lvItem);
1748 if(uFlags & SVSI_EDIT)
1749 ListView_EditLabelA(This->hWndList, i);
1755 static HRESULT WINAPI IShellView_fnGetItemObject(IShellView * iface, UINT uItem, REFIID riid, LPVOID *ppvOut)
1757 ICOM_THIS(IShellViewImpl, iface);
1759 TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This, uItem, debugstr_guid(riid), ppvOut);
1765 case SVGIO_BACKGROUND:
1766 *ppvOut = ISvBgCm_Constructor(This->pSFParent);
1769 case SVGIO_SELECTION:
1770 ShellView_GetSelections(This);
1771 IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, riid, 0, ppvOut);
1774 TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
1776 if(!*ppvOut) return E_OUTOFMEMORY;
1781 static HRESULT WINAPI IShellView_fnEditItem(
1785 ICOM_THIS(IShellViewImpl, iface);
1788 TRACE("(%p)->(pidl=%p)\n",This, pidl);
1790 i = LV_FindItemByPidl(This, pidl);
1793 SetFocus(This->hWndList);
1794 ListView_EditLabelA(This->hWndList, i);
1799 static struct ICOM_VTABLE(IShellView) svvt =
1801 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1802 IShellView_fnQueryInterface,
1803 IShellView_fnAddRef,
1804 IShellView_fnRelease,
1805 IShellView_fnGetWindow,
1806 IShellView_fnContextSensitiveHelp,
1807 IShellView_fnTranslateAccelerator,
1808 IShellView_fnEnableModeless,
1809 IShellView_fnUIActivate,
1810 IShellView_fnRefresh,
1811 IShellView_fnCreateViewWindow,
1812 IShellView_fnDestroyViewWindow,
1813 IShellView_fnGetCurrentInfo,
1814 IShellView_fnAddPropertySheetPages,
1815 IShellView_fnSaveViewState,
1816 IShellView_fnSelectItem,
1817 IShellView_fnGetItemObject,
1818 IShellView_fnEditItem
1822 /**********************************************************
1823 * ISVOleCmdTarget_QueryInterface (IUnknown)
1825 static HRESULT WINAPI ISVOleCmdTarget_QueryInterface(
1826 IOleCommandTarget * iface,
1830 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1832 return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj);
1835 /**********************************************************
1836 * ISVOleCmdTarget_AddRef (IUnknown)
1838 static ULONG WINAPI ISVOleCmdTarget_AddRef(
1839 IOleCommandTarget * iface)
1841 _ICOM_THIS_From_IOleCommandTarget(IShellFolder, iface);
1843 return IShellFolder_AddRef((IShellFolder*)This);
1846 /**********************************************************
1847 * ISVOleCmdTarget_Release (IUnknown)
1849 static ULONG WINAPI ISVOleCmdTarget_Release(
1850 IOleCommandTarget * iface)
1852 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1854 return IShellFolder_Release((IShellFolder*)This);
1857 /**********************************************************
1858 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
1860 static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
1861 IOleCommandTarget *iface,
1862 const GUID* pguidCmdGroup,
1865 OLECMDTEXT* pCmdText)
1867 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1869 FIXME("(%p)->(%p(%s) 0x%08lx %p %p\n",
1870 This, pguidCmdGroup, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
1874 /**********************************************************
1875 * ISVOleCmdTarget_Exec (IOleCommandTarget)
1877 * nCmdID is the OLECMDID_* enumeration
1879 static HRESULT WINAPI ISVOleCmdTarget_Exec(
1880 IOleCommandTarget *iface,
1881 const GUID* pguidCmdGroup,
1887 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1889 FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08lx Opt:0x%08lx %p %p)\n",
1890 This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, pvaIn, pvaOut);
1894 static ICOM_VTABLE(IOleCommandTarget) ctvt =
1896 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1897 ISVOleCmdTarget_QueryInterface,
1898 ISVOleCmdTarget_AddRef,
1899 ISVOleCmdTarget_Release,
1900 ISVOleCmdTarget_QueryStatus,
1901 ISVOleCmdTarget_Exec
1904 /**********************************************************
1905 * ISVDropTarget implementation
1908 static HRESULT WINAPI ISVDropTarget_QueryInterface(
1913 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1915 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1917 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
1920 static ULONG WINAPI ISVDropTarget_AddRef( IDropTarget *iface)
1922 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1924 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1926 return IShellFolder_AddRef((IShellFolder*)This);
1929 static ULONG WINAPI ISVDropTarget_Release( IDropTarget *iface)
1931 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1933 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1935 return IShellFolder_Release((IShellFolder*)This);
1938 static HRESULT WINAPI ISVDropTarget_DragEnter(
1940 IDataObject *pDataObject,
1946 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1948 FIXME("Stub: This=%p, DataObject=%p\n",This,pDataObject);
1953 static HRESULT WINAPI ISVDropTarget_DragOver(
1959 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1961 FIXME("Stub: This=%p\n",This);
1966 static HRESULT WINAPI ISVDropTarget_DragLeave(
1969 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1971 FIXME("Stub: This=%p\n",This);
1976 static HRESULT WINAPI ISVDropTarget_Drop(
1978 IDataObject* pDataObject,
1983 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1985 FIXME("Stub: This=%p\n",This);
1990 static struct ICOM_VTABLE(IDropTarget) dtvt =
1992 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1993 ISVDropTarget_QueryInterface,
1994 ISVDropTarget_AddRef,
1995 ISVDropTarget_Release,
1996 ISVDropTarget_DragEnter,
1997 ISVDropTarget_DragOver,
1998 ISVDropTarget_DragLeave,
2002 /**********************************************************
2003 * ISVDropSource implementation
2006 static HRESULT WINAPI ISVDropSource_QueryInterface(
2011 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2013 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2015 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2018 static ULONG WINAPI ISVDropSource_AddRef( IDropSource *iface)
2020 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2022 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2024 return IShellFolder_AddRef((IShellFolder*)This);
2027 static ULONG WINAPI ISVDropSource_Release( IDropSource *iface)
2029 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2031 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2033 return IShellFolder_Release((IShellFolder*)This);
2035 static HRESULT WINAPI ISVDropSource_QueryContinueDrag(
2037 BOOL fEscapePressed,
2040 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2041 TRACE("(%p)\n",This);
2044 return DRAGDROP_S_CANCEL;
2045 else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
2046 return DRAGDROP_S_DROP;
2051 static HRESULT WINAPI ISVDropSource_GiveFeedback(
2055 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2056 TRACE("(%p)\n",This);
2058 return DRAGDROP_S_USEDEFAULTCURSORS;
2061 static struct ICOM_VTABLE(IDropSource) dsvt =
2063 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2064 ISVDropSource_QueryInterface,
2065 ISVDropSource_AddRef,
2066 ISVDropSource_Release,
2067 ISVDropSource_QueryContinueDrag,
2068 ISVDropSource_GiveFeedback
2070 /**********************************************************
2071 * ISVViewObject implementation
2074 static HRESULT WINAPI ISVViewObject_QueryInterface(
2079 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2081 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2083 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2086 static ULONG WINAPI ISVViewObject_AddRef( IViewObject *iface)
2088 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2090 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2092 return IShellFolder_AddRef((IShellFolder*)This);
2095 static ULONG WINAPI ISVViewObject_Release( IViewObject *iface)
2097 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2099 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2101 return IShellFolder_Release((IShellFolder*)This);
2104 static HRESULT WINAPI ISVViewObject_Draw(
2109 DVTARGETDEVICE* ptd,
2112 LPCRECTL lprcBounds,
2113 LPCRECTL lprcWBounds,
2114 IVO_ContCallback pfnContinue,
2118 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2120 FIXME("Stub: This=%p\n",This);
2124 static HRESULT WINAPI ISVViewObject_GetColorSet(
2129 DVTARGETDEVICE* ptd,
2130 HDC hicTargetDevice,
2131 LOGPALETTE** ppColorSet)
2134 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2136 FIXME("Stub: This=%p\n",This);
2140 static HRESULT WINAPI ISVViewObject_Freeze(
2148 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2150 FIXME("Stub: This=%p\n",This);
2154 static HRESULT WINAPI ISVViewObject_Unfreeze(
2159 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2161 FIXME("Stub: This=%p\n",This);
2165 static HRESULT WINAPI ISVViewObject_SetAdvise(
2169 IAdviseSink* pAdvSink)
2172 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2174 FIXME("Stub: This=%p\n",This);
2178 static HRESULT WINAPI ISVViewObject_GetAdvise(
2182 IAdviseSink** ppAdvSink)
2185 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2187 FIXME("Stub: This=%p\n",This);
2193 static struct ICOM_VTABLE(IViewObject) vovt =
2195 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2196 ISVViewObject_QueryInterface,
2197 ISVViewObject_AddRef,
2198 ISVViewObject_Release,
2200 ISVViewObject_GetColorSet,
2201 ISVViewObject_Freeze,
2202 ISVViewObject_Unfreeze,
2203 ISVViewObject_SetAdvise,
2204 ISVViewObject_GetAdvise