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: The order by part of the background context menu should be
10 * buily according to the columns shown.
12 * FIXME: Load/Save the view state from/into the stream provied by
15 * FIXME: CheckToolbar: handle the "new folder" and "folder up" button
17 * FIXME: ShellView_FillList: consider sort orders
19 * FIXME: implement the drag and drop in the old (msg-based) way
21 * FIXME: when the ShellView_WndProc gets a WM_NCDESTROY should we do a
30 #include "wine/obj_base.h"
31 #include "wine/obj_shellfolder.h"
32 #include "wine/obj_shellview.h"
33 #include "wine/obj_oleview.h"
34 #include "wine/obj_commdlgbrowser.h"
35 #include "wine/obj_shellbrowser.h"
36 #include "wine/obj_dockingwindowframe.h"
37 #include "wine/obj_extracticon.h"
38 #include "wine/obj_dragdrop.h"
39 #include "wine/undocshell.h"
42 #include "debugtools.h"
44 #include "wine/winestring.h"
48 #include "shell32_main.h"
50 DEFAULT_DEBUG_CHANNEL(shell)
56 }LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO;
59 { ICOM_VFIELD(IShellView);
61 ICOM_VTABLE(IOleCommandTarget)* lpvtblOleCommandTarget;
62 ICOM_VTABLE(IDropTarget)* lpvtblDropTarget;
63 ICOM_VTABLE(IDropSource)* lpvtblDropSource;
64 ICOM_VTABLE(IViewObject)* lpvtblViewObject;
65 IShellFolder* pSFParent;
66 IShellFolder2* pSF2Parent;
67 IShellBrowser* pShellBrowser;
68 ICommDlgBrowser* pCommDlgBrowser;
69 HWND hWnd; /* SHELLDLL_DefView */
70 HWND hWndList; /* ListView control */
72 FOLDERSETTINGS FolderSettings;
77 LISTVIEW_SORT_INFO ListViewSortInfo;
78 HANDLE hNotify; /* change notification handle */
82 static struct ICOM_VTABLE(IShellView) svvt;
84 static struct ICOM_VTABLE(IOleCommandTarget) ctvt;
85 #define _IOleCommandTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblOleCommandTarget)))
86 #define _ICOM_THIS_From_IOleCommandTarget(class, name) class* This = (class*)(((char*)name)-_IOleCommandTarget_Offset);
88 static struct ICOM_VTABLE(IDropTarget) dtvt;
89 #define _IDropTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropTarget)))
90 #define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
92 static struct ICOM_VTABLE(IDropSource) dsvt;
93 #define _IDropSource_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropSource)))
94 #define _ICOM_THIS_From_IDropSource(class, name) class* This = (class*)(((char*)name)-_IDropSource_Offset);
96 static struct ICOM_VTABLE(IViewObject) vovt;
97 #define _IViewObject_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblViewObject)))
98 #define _ICOM_THIS_From_IViewObject(class, name) class* This = (class*)(((char*)name)-_IViewObject_Offset);
100 /* ListView Header ID's */
101 #define LISTVIEW_COLUMN_NAME 0
102 #define LISTVIEW_COLUMN_SIZE 1
103 #define LISTVIEW_COLUMN_TYPE 2
104 #define LISTVIEW_COLUMN_TIME 3
105 #define LISTVIEW_COLUMN_ATTRIB 4
108 #define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500)
109 #define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501)
110 #define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502)
112 #define ID_LISTVIEW 2000
114 #define SHV_CHANGE_NOTIFY WM_USER + 0x1111
116 #define TOOLBAR_ID (L"SHELLDLL_DefView")
118 #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
119 #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
120 #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
122 #define WM_SETTINGCHANGE WM_WININICHANGE
123 extern void WINAPI _InsertMenuItem (HMENU hmenu, UINT indexMenu, BOOL fByPosition,
124 UINT wID, UINT fType, LPSTR dwTypeData, UINT fState);
127 Items merged into the toolbar and and the filemenu
136 } MYTOOLINFO, *LPMYTOOLINFO;
140 { FCIDM_SHVIEW_BIGICON, 0, 0, IDS_VIEW_LARGE, TBSTATE_ENABLED, TBSTYLE_BUTTON },
141 { FCIDM_SHVIEW_SMALLICON, 0, 0, IDS_VIEW_SMALL, TBSTATE_ENABLED, TBSTYLE_BUTTON },
142 { FCIDM_SHVIEW_LISTVIEW, 0, 0, IDS_VIEW_LIST, TBSTATE_ENABLED, TBSTYLE_BUTTON },
143 { FCIDM_SHVIEW_REPORTVIEW, 0, 0, IDS_VIEW_DETAILS, TBSTATE_ENABLED, TBSTYLE_BUTTON },
147 typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
149 /**********************************************************
150 * IShellView_Constructor
152 IShellView * IShellView_Constructor( IShellFolder * pFolder)
153 { IShellViewImpl * sv;
154 sv=(IShellViewImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl));
157 sv->lpvtblOleCommandTarget=&ctvt;
158 sv->lpvtblDropTarget=&dtvt;
159 sv->lpvtblDropSource=&dsvt;
160 sv->lpvtblViewObject=&vovt;
162 sv->pSFParent = pFolder;
163 if(pFolder) IShellFolder_AddRef(pFolder);
164 IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (LPVOID*)&sv->pSF2Parent);
166 TRACE("(%p)->(%p)\n",sv, pFolder);
168 return (IShellView *) sv;
171 /**********************************************************
173 * ##### helperfunctions for communication with ICommDlgBrowser #####
175 static BOOL IsInCommDlg(IShellViewImpl * This)
176 { return(This->pCommDlgBrowser != NULL);
179 static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl)
183 if ( IsInCommDlg(This) )
185 TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
186 ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView*)This, pidl);
187 TRACE("--0x%08lx\n", ret);
192 static HRESULT OnDefaultCommand(IShellViewImpl * This)
194 HRESULT ret = S_FALSE;
196 if (IsInCommDlg(This))
198 TRACE("ICommDlgBrowser::OnDefaultCommand\n");
199 ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView*)This);
205 static HRESULT OnStateChange(IShellViewImpl * This, UINT uFlags)
207 HRESULT ret = S_FALSE;
209 if (IsInCommDlg(This))
211 TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags);
212 ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView*)This, uFlags);
217 /**********************************************************
218 * set the toolbar of the filedialog buttons
220 * - activates the buttons from the shellbrowser according to
223 static void CheckToolbar(IShellViewImpl * This)
229 if (IsInCommDlg(This))
231 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
232 FCIDM_TB_SMALLICON, (This->FolderSettings.ViewMode==FVM_LIST)? TRUE : FALSE, &result);
233 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
234 FCIDM_TB_REPORTVIEW, (This->FolderSettings.ViewMode==FVM_DETAILS)? TRUE : FALSE, &result);
235 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
236 FCIDM_TB_SMALLICON, TRUE, &result);
237 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
238 FCIDM_TB_REPORTVIEW, TRUE, &result);
242 /**********************************************************
244 * ##### helperfunctions for initializing the view #####
246 /**********************************************************
247 * change the style of the listview control
249 static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove)
253 TRACE("(%p)\n", This);
255 tmpstyle = GetWindowLongA(This->hWndList, GWL_STYLE);
256 SetWindowLongA(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove));
259 /**********************************************************
260 * ShellView_CreateList()
262 * - creates the list view window
264 static BOOL ShellView_CreateList (IShellViewImpl * This)
269 dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
270 LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_AUTOARRANGE;
272 switch (This->FolderSettings.ViewMode)
274 case FVM_ICON: dwStyle |= LVS_ICON; break;
275 case FVM_DETAILS: dwStyle |= LVS_REPORT; break;
276 case FVM_SMALLICON: dwStyle |= LVS_SMALLICON; break;
277 case FVM_LIST: dwStyle |= LVS_LIST; break;
278 default: dwStyle |= LVS_LIST; break;
281 if (This->FolderSettings.fFlags & FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE;
282 /*if (This->FolderSettings.fFlags && FWF_DESKTOP); used from explorer*/
283 if (This->FolderSettings.fFlags & FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL;
285 This->hWndList=CreateWindowExA( WS_EX_CLIENTEDGE,
298 This->ListViewSortInfo.bIsAscending = TRUE;
299 This->ListViewSortInfo.nHeaderID = -1;
300 This->ListViewSortInfo.nLastHeaderID = -1;
302 /* UpdateShellSettings(); */
306 /**********************************************************
307 * ShellView_InitList()
309 * - adds all needed columns to the shellview
311 static BOOL ShellView_InitList(IShellViewImpl * This)
320 ListView_DeleteAllItems(This->hWndList);
322 lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
323 lvColumn.pszText = szTemp;
325 if (This->pSF2Parent)
329 if (!SUCCEEDED(IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, i, &sd)))
331 lvColumn.fmt = sd.fmt;
332 lvColumn.cx = sd.cxChar*8; /* chars->pixel */
333 StrRetToStrNA( szTemp, 50, &sd.str, NULL);
334 ListView_InsertColumnA(This->hWndList, i, &lvColumn);
342 ListView_SetImageList(This->hWndList, ShellSmallIconList, LVSIL_SMALL);
343 ListView_SetImageList(This->hWndList, ShellBigIconList, LVSIL_NORMAL);
347 /**********************************************************
348 * ShellView_CompareItems()
351 * internal, CALLBACK for DSA_Sort
353 static INT CALLBACK ShellView_CompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
356 TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1, lParam2, (LPVOID) lpData);
358 if(!lpData) return 0;
360 ret = (SHORT) SCODE_CODE(IShellFolder_CompareIDs((LPSHELLFOLDER)lpData, 0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2));
361 TRACE("ret=%i\n",ret);
365 /*************************************************************************
366 * ShellView_ListViewCompareItems
368 * Compare Function for the Listview (FileOpen Dialog)
371 * lParam1 [I] the first ItemIdList to compare with
372 * lParam2 [I] the second ItemIdList to compare with
373 * lpData [I] The column ID for the header Ctrl to process
376 * A negative value if the first item should precede the second,
377 * a positive value if the first item should follow the second,
378 * or zero if the two items are equivalent
381 * FIXME: function does what ShellView_CompareItems is supposed to do.
382 * unify it and figure out how to use the undocumented first parameter
383 * of IShellFolder_CompareIDs to do the job this function does and
384 * move this code to IShellFolder.
385 * make LISTVIEW_SORT_INFO obsolete
386 * the way this function works is only usable if we had only
387 * filesystemfolders (25/10/99 jsch)
389 static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
393 char strName1[MAX_PATH], strName2[MAX_PATH];
394 BOOL bIsFolder1, bIsFolder2,bIsBothFolder;
395 LPITEMIDLIST pItemIdList1 = (LPITEMIDLIST) lParam1;
396 LPITEMIDLIST pItemIdList2 = (LPITEMIDLIST) lParam2;
397 LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData;
400 bIsFolder1 = _ILIsFolder(pItemIdList1);
401 bIsFolder2 = _ILIsFolder(pItemIdList2);
402 bIsBothFolder = bIsFolder1 && bIsFolder2;
404 /* When sorting between a File and a Folder, the Folder gets sorted first */
405 if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder)
407 nDiff = bIsFolder1 ? -1 : 1;
411 /* Sort by Time: Folders or Files can be sorted */
413 if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)
415 _ILGetFileDateTime(pItemIdList1, &fd1);
416 _ILGetFileDateTime(pItemIdList2, &fd2);
417 nDiff = CompareFileTime(&fd2, &fd1);
419 /* Sort by Attribute: Folder or Files can be sorted */
420 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB)
422 _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH);
423 _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH);
424 nDiff = strcasecmp(strName1, strName2);
426 /* Sort by FileName: Folder or Files can be sorted */
427 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder)
430 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
431 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
432 nDiff = strcasecmp(strName1, strName2);
434 /* Sort by File Size, Only valid for Files */
435 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)
437 nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0));
439 /* Sort by File Type, Only valid for Files */
440 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)
443 _ILGetFileType(pItemIdList1, strName1, MAX_PATH);
444 _ILGetFileType(pItemIdList2, strName2, MAX_PATH);
445 nDiff = strcasecmp(strName1, strName2);
448 /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
452 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
453 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
454 nDiff = strcasecmp(strName1, strName2);
457 if(!pSortInfo->bIsAscending)
466 /**********************************************************
467 * LV_FindItemByPidl()
469 static int LV_FindItemByPidl(
470 IShellViewImpl * This,
474 ZeroMemory(&lvItem, sizeof(LVITEMA));
475 lvItem.mask = LVIF_PARAM;
476 for(lvItem.iItem = 0; ListView_GetItemA(This->hWndList, &lvItem); lvItem.iItem++)
478 LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam;
479 HRESULT hr = IShellFolder_CompareIDs(This->pSFParent, 0, pidl, currentpidl);
480 if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
488 /**********************************************************
491 static BOOLEAN LV_AddItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
495 TRACE("(%p)(pidl=%p)\n", This, pidl);
497 ZeroMemory(&lvItem, sizeof(lvItem)); /* create the listview item*/
498 lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; /*set the mask*/
499 lvItem.iItem = ListView_GetItemCount(This->hWndList); /*add the item to the end of the list*/
500 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidl)); /*set the item's data*/
501 lvItem.pszText = LPSTR_TEXTCALLBACKA; /*get text on a callback basis*/
502 lvItem.iImage = I_IMAGECALLBACK; /*get the image on a callback basis*/
503 return (-1==ListView_InsertItemA(This->hWndList, &lvItem))? FALSE: TRUE;
506 /**********************************************************
509 static BOOLEAN LV_DeleteItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
513 TRACE("(%p)(pidl=%p)\n", This, pidl);
515 nIndex = LV_FindItemByPidl(This, ILFindLastID(pidl));
516 return (-1==ListView_DeleteItem(This->hWndList, nIndex))? FALSE: TRUE;
519 /**********************************************************
522 static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew )
527 TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew);
529 nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld));
532 ZeroMemory(&lvItem, sizeof(lvItem)); /* create the listview item*/
533 lvItem.mask = LVIF_PARAM; /* only the pidl */
534 lvItem.iItem = nItem;
535 ListView_GetItemA(This->hWndList, &lvItem);
537 SHFree((LPITEMIDLIST)lvItem.lParam);
538 lvItem.mask = LVIF_PARAM;
539 lvItem.iItem = nItem;
540 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew)); /* set the item's data */
541 ListView_SetItemA(This->hWndList, &lvItem);
542 ListView_Update(This->hWndList, nItem);
543 return TRUE; /* fixme: better handling */
547 /**********************************************************
548 * ShellView_FillList()
550 * - gets the objectlist from the shellfolder
552 * - fills the list into the view
555 static HRESULT ShellView_FillList(IShellViewImpl * This)
557 LPENUMIDLIST pEnumIDList;
566 /* get the itemlist from the shfolder*/
567 hRes = IShellFolder_EnumObjects(This->pSFParent,This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList);
575 /* create a pointer array */
576 hdpa = pDPA_Create(16);
579 return(E_OUTOFMEMORY);
582 /* copy the items into the array*/
583 while((S_OK == IEnumIDList_Next(pEnumIDList,1, &pidl, &dwFetched)) && dwFetched)
585 if (pDPA_InsertPtr(hdpa, 0x7fff, pidl) == -1)
592 pDPA_Sort(hdpa, ShellView_CompareItems, (LPARAM)This->pSFParent);
594 /*turn the listview's redrawing off*/
595 SendMessageA(This->hWndList, WM_SETREDRAW, FALSE, 0);
597 for (i=0; i < DPA_GetPtrCount(hdpa); ++i) /* DPA_GetPtrCount is a macro*/
599 pidl = (LPITEMIDLIST)pDPA_GetPtr(hdpa, i);
601 /* in a commdlg This works as a filemask*/
602 if ( IncludeObject(This, pidl)==S_OK )
603 LV_AddItem(This, pidl);
607 /*turn the listview's redrawing back on and force it to draw*/
608 SendMessageA(This->hWndList, WM_SETREDRAW, TRUE, 0);
610 IEnumIDList_Release(pEnumIDList); /* destroy the list*/
616 /**********************************************************
617 * ShellView_OnCreate()
619 static LRESULT ShellView_OnCreate(IShellViewImpl * This)
622 NOTIFYREGISTER ntreg;
623 IPersistFolder2 * ppf2 = NULL;
627 if(ShellView_CreateList(This))
629 if(ShellView_InitList(This))
631 ShellView_FillList(This);
637 if (SUCCEEDED(IShellFolder_CreateViewObject(This->pSFParent, This->hWnd, &IID_IDropTarget, (LPVOID*)&pdt)))
639 pRegisterDragDrop(This->hWnd, pdt);
640 IDropTarget_Release(pdt);
644 /* register for receiving notifications */
645 IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2);
648 IPersistFolder2_GetCurFolder(ppf2, &ntreg.pidlPath);
649 ntreg.bWatchSubtree = FALSE;
650 This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNF_IDLIST, SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg);
651 SHFree(ntreg.pidlPath);
652 IPersistFolder2_Release(ppf2);
655 This->hAccel = LoadAcceleratorsA(shell32_hInstance, "shv_accel");
660 /**********************************************************
661 * #### Handling of the menus ####
664 /**********************************************************
665 * ShellView_BuildFileMenu()
667 static HMENU ShellView_BuildFileMenu(IShellViewImpl * This)
668 { CHAR szText[MAX_PATH];
673 TRACE("(%p)\n",This);
675 hSubMenu = CreatePopupMenu();
677 { /*get the number of items in our global array*/
678 for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){}
680 /*add the menu items*/
681 for(i = 0; i < nTools; i++)
683 LoadStringA(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH);
685 ZeroMemory(&mii, sizeof(mii));
686 mii.cbSize = sizeof(mii);
687 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
689 if(TBSTYLE_SEP != Tools[i].bStyle) /* no seperator*/
691 mii.fType = MFT_STRING;
692 mii.fState = MFS_ENABLED;
693 mii.dwTypeData = szText;
694 mii.wID = Tools[i].idCommand;
698 mii.fType = MFT_SEPARATOR;
700 /* tack This item onto the end of the menu */
701 InsertMenuItemA(hSubMenu, (UINT)-1, TRUE, &mii);
704 TRACE("-- return (menu=0x%x)\n",hSubMenu);
707 /**********************************************************
708 * ShellView_MergeFileMenu()
710 static void ShellView_MergeFileMenu(IShellViewImpl * This, HMENU hSubMenu)
711 { TRACE("(%p)->(submenu=0x%08x) stub\n",This,hSubMenu);
714 { /*insert This item at the beginning of the menu */
715 _InsertMenuItem(hSubMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
716 _InsertMenuItem(hSubMenu, 0, TRUE, IDM_MYFILEITEM, MFT_STRING, "dummy45", MFS_ENABLED);
722 /**********************************************************
723 * ShellView_MergeViewMenu()
726 static void ShellView_MergeViewMenu(IShellViewImpl * This, HMENU hSubMenu)
729 TRACE("(%p)->(submenu=0x%08x)\n",This,hSubMenu);
732 { /*add a separator at the correct position in the menu*/
733 _InsertMenuItem(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
735 ZeroMemory(&mii, sizeof(mii));
736 mii.cbSize = sizeof(mii);
737 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;;
738 mii.fType = MFT_STRING;
739 mii.dwTypeData = "View";
740 mii.hSubMenu = LoadMenuA(shell32_hInstance, "MENU_001");
741 InsertMenuItemA(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
745 /**********************************************************
746 * ShellView_GetSelections()
748 * - fills the this->apidl list with the selected objects
751 * number of selected items
753 static UINT ShellView_GetSelections(IShellViewImpl * This)
763 This->cidl = ListView_GetSelectedCount(This->hWndList);
764 This->apidl = (LPITEMIDLIST*)SHAlloc(This->cidl * sizeof(LPITEMIDLIST));
766 TRACE("selected=%i\n", This->cidl);
770 TRACE("-- Items selected =%u\n", This->cidl);
772 ZeroMemory(&lvItem, sizeof(lvItem));
773 lvItem.mask = LVIF_STATE | LVIF_PARAM;
774 lvItem.stateMask = LVIS_SELECTED;
776 while(ListView_GetItemA(This->hWndList, &lvItem) && (i < This->cidl))
778 if(lvItem.state & LVIS_SELECTED)
780 This->apidl[i] = (LPITEMIDLIST)lvItem.lParam;
782 TRACE("-- selected Item found\n");
790 /**********************************************************
791 * ShellView_DoContextMenu()
793 static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL bDefault)
797 BOOL fExplore = FALSE;
799 LPCONTEXTMENU pContextMenu = NULL;
800 IContextMenu * pCM = NULL;
801 CMINVOKECOMMANDINFO cmi;
803 TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, bDefault);
805 /* look, what's selected and create a context menu object of it*/
806 if( ShellView_GetSelections(This) )
808 IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, This->apidl,
809 (REFIID)&IID_IContextMenu, NULL, (LPVOID *)&pContextMenu);
813 TRACE("-- pContextMenu\n");
814 hMenu = CreatePopupMenu();
818 /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
819 if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree)
821 TRACE("-- explore mode\n");
825 /* build the flags depending on what we can do with the selected item */
826 wFlags = CMF_NORMAL | (This->cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0);
828 /* let the ContextMenu merge its items in */
829 if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags )))
833 TRACE("-- get menu default command\n");
834 uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS);
838 TRACE("-- track popup\n");
839 uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
844 TRACE("-- uCommand=%u\n", uCommand);
845 if (IsInCommDlg(This) && ((uCommand==FCIDM_SHVIEW_EXPLORE) || (uCommand==FCIDM_SHVIEW_OPEN)))
847 TRACE("-- dlg: OnDefaultCommand\n");
848 OnDefaultCommand(This);
852 TRACE("-- explore -- invoke command\n");
853 ZeroMemory(&cmi, sizeof(cmi));
854 cmi.cbSize = sizeof(cmi);
855 cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */
856 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
857 IContextMenu_InvokeCommand(pContextMenu, &cmi);
864 IContextMenu_Release(pContextMenu);
867 else /* background context menu */
869 hMenu = CreatePopupMenu();
871 pCM = ISvBgCm_Constructor(This->pSFParent);
872 IContextMenu_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
874 uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
877 TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand);
879 ZeroMemory(&cmi, sizeof(cmi));
880 cmi.cbSize = sizeof(cmi);
881 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
882 cmi.hwnd = This->hWndParent;
883 IContextMenu_InvokeCommand(pCM, &cmi);
885 IContextMenu_Release(pCM);
889 /**********************************************************
890 * ##### message handling #####
893 /**********************************************************
896 static LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight)
898 TRACE("%p width=%u height=%u\n",This, wWidth,wHeight);
900 /*resize the ListView to fit our window*/
903 MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE);
908 /**********************************************************
909 * ShellView_OnDeactivate()
914 static void ShellView_OnDeactivate(IShellViewImpl * This)
918 if(This->uState != SVUIA_DEACTIVATE)
922 IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0);
923 IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu);
924 DestroyMenu(This->hMenu);
928 This->uState = SVUIA_DEACTIVATE;
932 /**********************************************************
933 * ShellView_OnActivate()
935 static LRESULT ShellView_OnActivate(IShellViewImpl * This, UINT uState)
936 { OLEMENUGROUPWIDTHS omw = { {0, 0, 0, 0, 0, 0} };
938 CHAR szText[MAX_PATH];
940 TRACE("%p uState=%x\n",This,uState);
942 /*don't do anything if the state isn't really changing */
943 if(This->uState == uState)
948 ShellView_OnDeactivate(This);
950 /*only do This if we are active */
951 if(uState != SVUIA_DEACTIVATE)
954 This->hMenu = CreateMenu();
958 IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw);
959 TRACE("-- after fnInsertMenusSB\n");
961 /*build the top level menu get the menu item's text*/
962 strcpy(szText,"dummy 31");
964 ZeroMemory(&mii, sizeof(mii));
965 mii.cbSize = sizeof(mii);
966 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
967 mii.fType = MFT_STRING;
968 mii.fState = MFS_ENABLED;
969 mii.dwTypeData = szText;
970 mii.hSubMenu = ShellView_BuildFileMenu(This);
972 /*insert our menu into the menu bar*/
975 InsertMenuItemA(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii);
978 /*get the view menu so we can merge with it*/
979 ZeroMemory(&mii, sizeof(mii));
980 mii.cbSize = sizeof(mii);
981 mii.fMask = MIIM_SUBMENU;
983 if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii))
985 ShellView_MergeViewMenu(This, mii.hSubMenu);
988 /*add the items that should only be added if we have the focus*/
989 if(SVUIA_ACTIVATE_FOCUS == uState)
991 /*get the file menu so we can merge with it */
992 ZeroMemory(&mii, sizeof(mii));
993 mii.cbSize = sizeof(mii);
994 mii.fMask = MIIM_SUBMENU;
996 if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii))
998 ShellView_MergeFileMenu(This, mii.hSubMenu);
1001 TRACE("-- before fnSetMenuSB\n");
1002 IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd);
1005 This->uState = uState;
1010 /**********************************************************
1011 * ShellView_OnSetFocus()
1014 static LRESULT ShellView_OnSetFocus(IShellViewImpl * This)
1018 /* Tell the browser one of our windows has received the focus. This
1019 should always be done before merging menus (OnActivate merges the
1020 menus) if one of our windows has the focus.*/
1022 IShellBrowser_OnViewWindowActive(This->pShellBrowser,(IShellView*) This);
1023 ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS);
1025 /* Set the focus to the listview */
1026 SetFocus(This->hWndList);
1028 /* Notify the ICommDlgBrowser interface */
1029 OnStateChange(This,CDBOSC_SETFOCUS);
1034 /**********************************************************
1035 * ShellView_OnKillFocus()
1037 static LRESULT ShellView_OnKillFocus(IShellViewImpl * This)
1039 TRACE("(%p) stub\n",This);
1041 ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS);
1042 /* Notify the ICommDlgBrowser */
1043 OnStateChange(This,CDBOSC_KILLFOCUS);
1048 /**********************************************************
1049 * ShellView_OnCommand()
1052 * the CmdID's are the ones from the context menu
1054 static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd)
1056 TRACE("(%p)->(0x%08lx 0x%08lx 0x%08x) stub\n",This, dwCmdID, dwCmd, hwndCmd);
1060 case FCIDM_SHVIEW_SMALLICON:
1061 This->FolderSettings.ViewMode = FVM_SMALLICON;
1062 SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK);
1066 case FCIDM_SHVIEW_BIGICON:
1067 This->FolderSettings.ViewMode = FVM_ICON;
1068 SetStyle (This, LVS_ICON, LVS_TYPEMASK);
1072 case FCIDM_SHVIEW_LISTVIEW:
1073 This->FolderSettings.ViewMode = FVM_LIST;
1074 SetStyle (This, LVS_LIST, LVS_TYPEMASK);
1078 case FCIDM_SHVIEW_REPORTVIEW:
1079 This->FolderSettings.ViewMode = FVM_DETAILS;
1080 SetStyle (This, LVS_REPORT, LVS_TYPEMASK);
1084 /* the menu-ID's for sorting are 0x30... see shrec.rc */
1089 This->ListViewSortInfo.nHeaderID = (LPARAM) (dwCmdID - 0x30);
1090 This->ListViewSortInfo.bIsAscending = TRUE;
1091 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1092 ListView_SortItems(This->hWndList, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1096 TRACE("-- COMMAND 0x%04lx unhandled\n", dwCmdID);
1101 /**********************************************************
1102 * ShellView_OnNotify()
1105 static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
1106 { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
1107 NMLVDISPINFOA *lpdi = (NMLVDISPINFOA *)lpnmh;
1110 TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code);
1115 TRACE("-- NM_SETFOCUS %p\n",This);
1116 ShellView_OnSetFocus(This);
1120 TRACE("-- NM_KILLFOCUS %p\n",This);
1121 ShellView_OnDeactivate(This);
1122 /* Notify the ICommDlgBrowser interface */
1123 OnStateChange(This,CDBOSC_KILLFOCUS);
1127 TRACE("-- HDN_ENDTRACKA %p\n",This);
1128 /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
1129 nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
1132 case LVN_DELETEITEM:
1133 TRACE("-- LVN_DELETEITEM %p\n",This);
1134 SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/
1137 case LVN_ITEMACTIVATE:
1138 TRACE("-- LVN_ITEMACTIVATE %p\n",This);
1139 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1140 ShellView_DoContextMenu(This, 0, 0, TRUE);
1143 case LVN_COLUMNCLICK:
1144 This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem;
1145 if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID)
1147 This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending;
1151 This->ListViewSortInfo.bIsAscending = TRUE;
1153 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1155 ListView_SortItems(lpnmlv->hdr.hwndFrom, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1158 case LVN_GETDISPINFOA:
1159 TRACE("-- LVN_GETDISPINFOA %p\n",This);
1160 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1162 if(lpdi->item.mask & LVIF_TEXT) /* text requested */
1164 if (This->pSF2Parent)
1167 IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
1168 StrRetToStrNA( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1169 TRACE("-- text=%s\n",lpdi->item.pszText);
1176 if(lpdi->item.mask & LVIF_IMAGE) /* image requested */
1178 lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
1182 case LVN_ITEMCHANGED:
1183 TRACE("-- LVN_ITEMCHANGED %p\n",This);
1184 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1188 case LVN_BEGINRDRAG:
1189 TRACE("-- LVN_BEGINDRAG\n");
1191 if (ShellView_GetSelections(This))
1194 DWORD dwAttributes = SFGAO_CANLINK;
1195 DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
1199 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
1201 IDropSource * pds = (IDropSource*)&(This->lpvtblDropSource); /* own DropSource interface */
1203 if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, This->apidl, &dwAttributes)))
1205 if (dwAttributes & SFGAO_CANLINK)
1207 dwEffect |= DROPEFFECT_LINK;
1214 pDoDragDrop(pda, pds, dwEffect, &dwEffect);
1216 IDataObject_Release(pda);
1222 case LVN_BEGINLABELEDITA:
1224 DWORD dwAttr = SFGAO_CANRENAME;
1225 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1227 TRACE("-- LVN_BEGINLABELEDITA %p\n",This);
1229 IShellFolder_GetAttributesOf(This->pSFParent, 1, &pidl, &dwAttr);
1230 if (SFGAO_CANRENAME & dwAttr)
1238 case LVN_ENDLABELEDITA:
1240 TRACE("-- LVN_ENDLABELEDITA %p\n",This);
1241 if (lpdi->item.pszText)
1244 WCHAR wszNewName[MAX_PATH];
1247 ZeroMemory(&lvItem, sizeof(LVITEMA));
1248 lvItem.iItem = lpdi->item.iItem;
1249 lvItem.mask = LVIF_PARAM;
1250 ListView_GetItemA(This->hWndList, &lvItem);
1252 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1253 lstrcpynAtoW(wszNewName, lpdi->item.pszText, MAX_PATH);
1254 hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, wszNewName, SHGDN_INFOLDER, &pidl);
1256 if(SUCCEEDED(hr) && pidl)
1258 lvItem.mask = LVIF_PARAM;
1259 lvItem.lParam = (LPARAM)pidl;
1260 ListView_SetItemA(This->hWndList, &lvItem);
1271 msg.hwnd = This->hWnd;
1272 msg.message = WM_KEYDOWN;
1273 msg.wParam = plvKeyDown->wVKey;
1278 LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
1280 TranslateAccelerator(This->hWnd, This->hAccel, &msg)
1282 FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey);
1286 TRACE("-- %p WM_COMMAND %s unhandled\n", This, SPY_GetMsgName(lpnmh->code));
1292 /**********************************************************
1293 * ShellView_OnChange()
1296 static LRESULT ShellView_OnChange(IShellViewImpl * This, LPITEMIDLIST * Pidls, LONG wEventId)
1299 TRACE("(%p)(%p,%p,0x%08lx)\n", This, Pidls[0], Pidls[1], wEventId);
1304 LV_AddItem(This, Pidls[0]);
1308 LV_DeleteItem(This, Pidls[0]);
1310 case SHCNE_RENAMEFOLDER:
1311 case SHCNE_RENAMEITEM:
1312 LV_RenameItem(This, Pidls[0], Pidls[1]);
1314 case SHCNE_UPDATEITEM:
1319 /**********************************************************
1323 static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1325 IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongA(hWnd, GWL_USERDATA);
1326 LPCREATESTRUCTA lpcs;
1328 TRACE("(hwnd=%x msg=%x wparm=%x lparm=%lx)\n",hWnd, uMessage, wParam, lParam);
1333 lpcs = (LPCREATESTRUCTA)lParam;
1334 pThis = (IShellViewImpl*)(lpcs->lpCreateParams);
1335 SetWindowLongA(hWnd, GWL_USERDATA, (LONG)pThis);
1336 pThis->hWnd = hWnd; /*set the window handle*/
1339 case WM_SIZE: return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam));
1340 case WM_SETFOCUS: return ShellView_OnSetFocus(pThis);
1341 case WM_KILLFOCUS: return ShellView_OnKillFocus(pThis);
1342 case WM_CREATE: return ShellView_OnCreate(pThis);
1343 case WM_ACTIVATE: return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS);
1344 case WM_NOTIFY: return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam);
1345 case WM_COMMAND: return ShellView_OnCommand(pThis,
1346 GET_WM_COMMAND_ID(wParam, lParam),
1347 GET_WM_COMMAND_CMD(wParam, lParam),
1348 GET_WM_COMMAND_HWND(wParam, lParam));
1349 case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (LPITEMIDLIST*)wParam, (LONG)lParam);
1351 case WM_CONTEXTMENU: ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE);
1354 case WM_SHOWWINDOW: UpdateWindow(pThis->hWndList);
1357 case WM_GETDLGCODE: return SendMessageA(pThis->hWndList,uMessage,0,0);
1359 case WM_DESTROY: if(GetShellOle())
1361 pRevokeDragDrop(pThis->hWnd);
1363 SHChangeNotifyDeregister(pThis->hNotify);
1367 return DefWindowProcA (hWnd, uMessage, wParam, lParam);
1369 /**********************************************************
1372 * The INTERFACE of the IShellView object
1375 **********************************************************
1376 * IShellView_QueryInterface
1378 static HRESULT WINAPI IShellView_fnQueryInterface(IShellView * iface,REFIID riid, LPVOID *ppvObj)
1380 ICOM_THIS(IShellViewImpl, iface);
1382 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1386 if(IsEqualIID(riid, &IID_IUnknown))
1390 else if(IsEqualIID(riid, &IID_IShellView))
1392 *ppvObj = (IShellView*)This;
1394 else if(IsEqualIID(riid, &IID_IOleCommandTarget))
1396 *ppvObj = (IOleCommandTarget*)&(This->lpvtblOleCommandTarget);
1398 else if(IsEqualIID(riid, &IID_IDropTarget))
1400 *ppvObj = (IDropTarget*)&(This->lpvtblDropTarget);
1402 else if(IsEqualIID(riid, &IID_IDropSource))
1404 *ppvObj = (IDropSource*)&(This->lpvtblDropSource);
1406 else if(IsEqualIID(riid, &IID_IViewObject))
1408 *ppvObj = (IViewObject*)&(This->lpvtblViewObject);
1413 IUnknown_AddRef( (IUnknown*)*ppvObj );
1414 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1417 TRACE("-- Interface: E_NOINTERFACE\n");
1418 return E_NOINTERFACE;
1421 /**********************************************************
1424 static ULONG WINAPI IShellView_fnAddRef(IShellView * iface)
1426 ICOM_THIS(IShellViewImpl, iface);
1428 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1431 return ++(This->ref);
1433 /**********************************************************
1434 * IShellView_Release
1436 static ULONG WINAPI IShellView_fnRelease(IShellView * iface)
1438 ICOM_THIS(IShellViewImpl, iface);
1440 TRACE("(%p)->()\n",This);
1446 TRACE(" destroying IShellView(%p)\n",This);
1449 IShellFolder_Release(This->pSFParent);
1451 if(This->pSF2Parent)
1452 IShellFolder2_Release(This->pSF2Parent);
1455 SHFree(This->apidl);
1457 if (This->pCommDlgBrowser)
1458 ICommDlgBrowser_Release(This->pCommDlgBrowser);
1460 HeapFree(GetProcessHeap(),0,This);
1466 /**********************************************************
1467 * ShellView_GetWindow
1469 static HRESULT WINAPI IShellView_fnGetWindow(IShellView * iface,HWND * phWnd)
1471 ICOM_THIS(IShellViewImpl, iface);
1473 TRACE("(%p)\n",This);
1475 *phWnd = This->hWnd;
1480 static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView * iface,BOOL fEnterMode)
1482 ICOM_THIS(IShellViewImpl, iface);
1484 FIXME("(%p) stub\n",This);
1489 /**********************************************************
1490 * IShellView_TranslateAccelerator
1493 * use the accel functions
1495 static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg)
1498 ICOM_THIS(IShellViewImpl, iface);
1500 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1503 if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST))
1505 TRACE("-- key=0x04%x",lpmsg->wParam) ;
1507 return S_FALSE; /* not handled */
1510 static HRESULT WINAPI IShellView_fnEnableModeless(IShellView * iface,BOOL fEnable)
1512 ICOM_THIS(IShellViewImpl, iface);
1514 FIXME("(%p) stub\n",This);
1519 static HRESULT WINAPI IShellView_fnUIActivate(IShellView * iface,UINT uState)
1521 ICOM_THIS(IShellViewImpl, iface);
1524 CHAR szName[MAX_PATH];
1527 int nPartArray[1] = {-1};
1529 TRACE("(%p)->(state=%x) stub\n",This, uState);
1531 /*don't do anything if the state isn't really changing*/
1532 if(This->uState == uState)
1537 /*OnActivate handles the menu merging and internal state*/
1538 ShellView_OnActivate(This, uState);
1540 /*only do This if we are active*/
1541 if(uState != SVUIA_DEACTIVATE)
1545 GetFolderPath is not a method of IShellFolder
1546 IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1548 /* set the number of parts */
1549 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1550 (LPARAM)nPartArray, &lResult);
1552 /* set the text for the parts */
1554 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1555 0, (LPARAM)szName, &lResult);
1562 static HRESULT WINAPI IShellView_fnRefresh(IShellView * iface)
1564 ICOM_THIS(IShellViewImpl, iface);
1566 TRACE("(%p)\n",This);
1568 ListView_DeleteAllItems(This->hWndList);
1569 ShellView_FillList(This);
1574 static HRESULT WINAPI IShellView_fnCreateViewWindow(
1576 IShellView *lpPrevView,
1577 LPCFOLDERSETTINGS lpfs,
1578 IShellBrowser * psb,
1582 ICOM_THIS(IShellViewImpl, iface);
1588 TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This, lpPrevView,lpfs, psb, prcView, phWnd);
1589 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);
1591 /*set up the member variables*/
1592 This->pShellBrowser = psb;
1593 This->FolderSettings = *lpfs;
1595 /*get our parent window*/
1596 IShellBrowser_AddRef(This->pShellBrowser);
1597 IShellBrowser_GetWindow(This->pShellBrowser, &(This->hWndParent));
1599 /* try to get the ICommDlgBrowserInterface, adds a reference !!! */
1600 This->pCommDlgBrowser=NULL;
1601 if ( SUCCEEDED (IShellBrowser_QueryInterface( This->pShellBrowser,
1602 (REFIID)&IID_ICommDlgBrowser, (LPVOID*) &This->pCommDlgBrowser)))
1604 TRACE("-- CommDlgBrowser\n");
1607 /*if our window class has not been registered, then do so*/
1608 if(!GetClassInfoA(shell32_hInstance, SV_CLASS_NAME, &wc))
1610 ZeroMemory(&wc, sizeof(wc));
1611 wc.style = CS_HREDRAW | CS_VREDRAW;
1612 wc.lpfnWndProc = (WNDPROC) ShellView_WndProc;
1615 wc.hInstance = shell32_hInstance;
1617 wc.hCursor = LoadCursorA (0, IDC_ARROWA);
1618 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
1619 wc.lpszMenuName = NULL;
1620 wc.lpszClassName = SV_CLASS_NAME;
1622 if(!RegisterClassA(&wc))
1626 *phWnd = CreateWindowExA(0,
1629 WS_CHILD | WS_VISIBLE | WS_TABSTOP,
1632 prcView->right - prcView->left,
1633 prcView->bottom - prcView->top,
1641 if(!*phWnd) return E_FAIL;
1646 static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView * iface)
1648 ICOM_THIS(IShellViewImpl, iface);
1650 TRACE("(%p)\n",This);
1652 /*Make absolutely sure all our UI is cleaned up.*/
1653 IShellView_UIActivate((IShellView*)This, SVUIA_DEACTIVATE);
1657 DestroyMenu(This->hMenu);
1660 DestroyWindow(This->hWnd);
1661 IShellBrowser_Release(This->pShellBrowser);
1666 static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView * iface, LPFOLDERSETTINGS lpfs)
1668 ICOM_THIS(IShellViewImpl, iface);
1670 TRACE("(%p)->(%p) vmode=%x flags=%x\n",This, lpfs,
1671 This->FolderSettings.ViewMode, This->FolderSettings.fFlags);
1673 if (!lpfs) return E_INVALIDARG;
1675 *lpfs = This->FolderSettings;
1679 static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView * iface, DWORD dwReserved,LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
1681 ICOM_THIS(IShellViewImpl, iface);
1683 FIXME("(%p) stub\n",This);
1688 static HRESULT WINAPI IShellView_fnSaveViewState(IShellView * iface)
1690 ICOM_THIS(IShellViewImpl, iface);
1692 FIXME("(%p) stub\n",This);
1697 static HRESULT WINAPI IShellView_fnSelectItem(
1702 ICOM_THIS(IShellViewImpl, iface);
1705 TRACE("(%p)->(pidl=%p, 0x%08x) stub\n",This, pidl, uFlags);
1707 i = LV_FindItemByPidl(This, pidl);
1713 if(uFlags & SVSI_ENSUREVISIBLE)
1714 ListView_EnsureVisible(This->hWndList, i, 0);
1716 ZeroMemory(&lvItem, sizeof(LVITEMA));
1717 lvItem.mask = LVIF_STATE;
1720 while(ListView_GetItemA(This->hWndList, &lvItem))
1722 if (lvItem.iItem == i)
1724 if (uFlags & SVSI_SELECT)
1725 lvItem.state |= LVIS_SELECTED;
1727 lvItem.state &= ~LVIS_SELECTED;
1729 if(uFlags & SVSI_FOCUSED)
1730 lvItem.state &= ~LVIS_FOCUSED;
1734 if (uFlags & SVSI_DESELECTOTHERS)
1735 lvItem.state &= ~LVIS_SELECTED;
1737 ListView_SetItemA(This->hWndList, &lvItem);
1742 if(uFlags & SVSI_EDIT)
1743 ListView_EditLabelA(This->hWndList, i);
1749 static HRESULT WINAPI IShellView_fnGetItemObject(IShellView * iface, UINT uItem, REFIID riid, LPVOID *ppvOut)
1751 ICOM_THIS(IShellViewImpl, iface);
1753 TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This, uItem, debugstr_guid(riid), ppvOut);
1759 case SVGIO_BACKGROUND:
1760 *ppvOut = ISvBgCm_Constructor(This->pSFParent);
1763 case SVGIO_SELECTION:
1764 ShellView_GetSelections(This);
1765 IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, riid, 0, ppvOut);
1768 TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
1770 if(!*ppvOut) return E_OUTOFMEMORY;
1775 static HRESULT WINAPI IShellView_fnEditItem(
1779 ICOM_THIS(IShellViewImpl, iface);
1782 TRACE("(%p)->(pidl=%p)\n",This, pidl);
1784 i = LV_FindItemByPidl(This, pidl);
1787 SetFocus(This->hWndList);
1788 ListView_EditLabelA(This->hWndList, i);
1793 static struct ICOM_VTABLE(IShellView) svvt =
1795 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1796 IShellView_fnQueryInterface,
1797 IShellView_fnAddRef,
1798 IShellView_fnRelease,
1799 IShellView_fnGetWindow,
1800 IShellView_fnContextSensitiveHelp,
1801 IShellView_fnTranslateAccelerator,
1802 IShellView_fnEnableModeless,
1803 IShellView_fnUIActivate,
1804 IShellView_fnRefresh,
1805 IShellView_fnCreateViewWindow,
1806 IShellView_fnDestroyViewWindow,
1807 IShellView_fnGetCurrentInfo,
1808 IShellView_fnAddPropertySheetPages,
1809 IShellView_fnSaveViewState,
1810 IShellView_fnSelectItem,
1811 IShellView_fnGetItemObject,
1812 IShellView_fnEditItem
1816 /**********************************************************
1817 * ISVOleCmdTarget_QueryInterface (IUnknown)
1819 static HRESULT WINAPI ISVOleCmdTarget_QueryInterface(
1820 IOleCommandTarget * iface,
1824 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1826 return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj);
1829 /**********************************************************
1830 * ISVOleCmdTarget_AddRef (IUnknown)
1832 static ULONG WINAPI ISVOleCmdTarget_AddRef(
1833 IOleCommandTarget * iface)
1835 _ICOM_THIS_From_IOleCommandTarget(IShellFolder, iface);
1837 return IShellFolder_AddRef((IShellFolder*)This);
1840 /**********************************************************
1841 * ISVOleCmdTarget_Release (IUnknown)
1843 static ULONG WINAPI ISVOleCmdTarget_Release(
1844 IOleCommandTarget * iface)
1846 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1848 return IShellFolder_Release((IShellFolder*)This);
1851 /**********************************************************
1852 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
1854 static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
1855 IOleCommandTarget *iface,
1856 const GUID* pguidCmdGroup,
1859 OLECMDTEXT* pCmdText)
1861 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1863 FIXME("(%p)->(%p(%s) 0x%08lx %p %p\n",
1864 This, pguidCmdGroup, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
1868 /**********************************************************
1869 * ISVOleCmdTarget_Exec (IOleCommandTarget)
1871 * nCmdID is the OLECMDID_* enumeration
1873 static HRESULT WINAPI ISVOleCmdTarget_Exec(
1874 IOleCommandTarget *iface,
1875 const GUID* pguidCmdGroup,
1881 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1883 FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08lx Opt:0x%08lx %p %p)\n",
1884 This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, pvaIn, pvaOut);
1888 static ICOM_VTABLE(IOleCommandTarget) ctvt =
1890 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1891 ISVOleCmdTarget_QueryInterface,
1892 ISVOleCmdTarget_AddRef,
1893 ISVOleCmdTarget_Release,
1894 ISVOleCmdTarget_QueryStatus,
1895 ISVOleCmdTarget_Exec
1898 /**********************************************************
1899 * ISVDropTarget implementation
1902 static HRESULT WINAPI ISVDropTarget_QueryInterface(
1907 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1909 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1911 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
1914 static ULONG WINAPI ISVDropTarget_AddRef( IDropTarget *iface)
1916 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1918 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1920 return IShellFolder_AddRef((IShellFolder*)This);
1923 static ULONG WINAPI ISVDropTarget_Release( IDropTarget *iface)
1925 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1927 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1929 return IShellFolder_Release((IShellFolder*)This);
1932 static HRESULT WINAPI ISVDropTarget_DragEnter(
1934 IDataObject *pDataObject,
1940 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1942 FIXME("Stub: This=%p, DataObject=%p\n",This,pDataObject);
1947 static HRESULT WINAPI ISVDropTarget_DragOver(
1953 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1955 FIXME("Stub: This=%p\n",This);
1960 static HRESULT WINAPI ISVDropTarget_DragLeave(
1963 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1965 FIXME("Stub: This=%p\n",This);
1970 static HRESULT WINAPI ISVDropTarget_Drop(
1972 IDataObject* pDataObject,
1977 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1979 FIXME("Stub: This=%p\n",This);
1984 static struct ICOM_VTABLE(IDropTarget) dtvt =
1986 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1987 ISVDropTarget_QueryInterface,
1988 ISVDropTarget_AddRef,
1989 ISVDropTarget_Release,
1990 ISVDropTarget_DragEnter,
1991 ISVDropTarget_DragOver,
1992 ISVDropTarget_DragLeave,
1996 /**********************************************************
1997 * ISVDropSource implementation
2000 static HRESULT WINAPI ISVDropSource_QueryInterface(
2005 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2007 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2009 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2012 static ULONG WINAPI ISVDropSource_AddRef( IDropSource *iface)
2014 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2016 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2018 return IShellFolder_AddRef((IShellFolder*)This);
2021 static ULONG WINAPI ISVDropSource_Release( IDropSource *iface)
2023 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2025 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2027 return IShellFolder_Release((IShellFolder*)This);
2029 static HRESULT WINAPI ISVDropSource_QueryContinueDrag(
2031 BOOL fEscapePressed,
2034 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2035 TRACE("(%p)\n",This);
2038 return DRAGDROP_S_CANCEL;
2039 else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
2040 return DRAGDROP_S_DROP;
2045 static HRESULT WINAPI ISVDropSource_GiveFeedback(
2049 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2050 TRACE("(%p)\n",This);
2052 return DRAGDROP_S_USEDEFAULTCURSORS;
2055 static struct ICOM_VTABLE(IDropSource) dsvt =
2057 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2058 ISVDropSource_QueryInterface,
2059 ISVDropSource_AddRef,
2060 ISVDropSource_Release,
2061 ISVDropSource_QueryContinueDrag,
2062 ISVDropSource_GiveFeedback
2064 /**********************************************************
2065 * ISVViewObject implementation
2068 static HRESULT WINAPI ISVViewObject_QueryInterface(
2073 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2075 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2077 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2080 static ULONG WINAPI ISVViewObject_AddRef( IViewObject *iface)
2082 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2084 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2086 return IShellFolder_AddRef((IShellFolder*)This);
2089 static ULONG WINAPI ISVViewObject_Release( IViewObject *iface)
2091 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2093 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2095 return IShellFolder_Release((IShellFolder*)This);
2098 static HRESULT WINAPI ISVViewObject_Draw(
2103 DVTARGETDEVICE* ptd,
2106 LPCRECTL lprcBounds,
2107 LPCRECTL lprcWBounds,
2108 IVO_ContCallback pfnContinue,
2112 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2114 FIXME("Stub: This=%p\n",This);
2118 static HRESULT WINAPI ISVViewObject_GetColorSet(
2123 DVTARGETDEVICE* ptd,
2124 HDC hicTargetDevice,
2125 LOGPALETTE** ppColorSet)
2128 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2130 FIXME("Stub: This=%p\n",This);
2134 static HRESULT WINAPI ISVViewObject_Freeze(
2142 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2144 FIXME("Stub: This=%p\n",This);
2148 static HRESULT WINAPI ISVViewObject_Unfreeze(
2153 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2155 FIXME("Stub: This=%p\n",This);
2159 static HRESULT WINAPI ISVViewObject_SetAdvise(
2163 IAdviseSink* pAdvSink)
2166 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2168 FIXME("Stub: This=%p\n",This);
2172 static HRESULT WINAPI ISVViewObject_GetAdvise(
2176 IAdviseSink** ppAdvSink)
2179 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2181 FIXME("Stub: This=%p\n",This);
2187 static struct ICOM_VTABLE(IViewObject) vovt =
2189 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2190 ISVViewObject_QueryInterface,
2191 ISVViewObject_AddRef,
2192 ISVViewObject_Release,
2194 ISVViewObject_GetColorSet,
2195 ISVViewObject_Freeze,
2196 ISVViewObject_Unfreeze,
2197 ISVViewObject_SetAdvise,
2198 ISVViewObject_GetAdvise