Fix typo in OUTLINETEXTMETRIC definition.
[wine.git] / dlls / shell32 / shlview.c
blobc8850d50a21b895c211fe5b4e7fcd12871001908
1 /*
2 * ShellView
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.
8 *
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
13 * the ShellBrowser
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
22 * Release() ???
25 #include <stdlib.h>
26 #include <string.h>
28 #include "windef.h"
29 #include "winerror.h"
30 #include "winnls.h"
31 #include "servprov.h"
32 #include "shlguid.h"
33 #include "shlobj.h"
34 #include "wine/undocshell.h"
35 #include "shresdef.h"
36 #include "debugtools.h"
38 #include "docobj.h"
39 #include "pidl.h"
40 #include "shell32_main.h"
41 #include "shellfolder.h"
43 DEFAULT_DEBUG_CHANNEL(shell);
45 typedef struct
46 { BOOL bIsAscending;
47 INT nHeaderID;
48 INT nLastHeaderID;
49 }LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO;
51 typedef struct
52 { ICOM_VFIELD(IShellView);
53 DWORD ref;
54 ICOM_VTABLE(IOleCommandTarget)* lpvtblOleCommandTarget;
55 ICOM_VTABLE(IDropTarget)* lpvtblDropTarget;
56 ICOM_VTABLE(IDropSource)* lpvtblDropSource;
57 ICOM_VTABLE(IViewObject)* lpvtblViewObject;
58 IShellFolder* pSFParent;
59 IShellFolder2* pSF2Parent;
60 IShellBrowser* pShellBrowser;
61 ICommDlgBrowser* pCommDlgBrowser;
62 HWND hWnd; /* SHELLDLL_DefView */
63 HWND hWndList; /* ListView control */
64 HWND hWndParent;
65 FOLDERSETTINGS FolderSettings;
66 HMENU hMenu;
67 UINT uState;
68 UINT cidl;
69 LPITEMIDLIST *apidl;
70 LISTVIEW_SORT_INFO ListViewSortInfo;
71 HANDLE hNotify; /* change notification handle */
72 HANDLE hAccel;
73 } IShellViewImpl;
75 static struct ICOM_VTABLE(IShellView) svvt;
77 static struct ICOM_VTABLE(IOleCommandTarget) ctvt;
78 #define _IOleCommandTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblOleCommandTarget)))
79 #define _ICOM_THIS_From_IOleCommandTarget(class, name) class* This = (class*)(((char*)name)-_IOleCommandTarget_Offset);
81 static struct ICOM_VTABLE(IDropTarget) dtvt;
82 #define _IDropTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropTarget)))
83 #define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
85 static struct ICOM_VTABLE(IDropSource) dsvt;
86 #define _IDropSource_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropSource)))
87 #define _ICOM_THIS_From_IDropSource(class, name) class* This = (class*)(((char*)name)-_IDropSource_Offset);
89 static struct ICOM_VTABLE(IViewObject) vovt;
90 #define _IViewObject_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblViewObject)))
91 #define _ICOM_THIS_From_IViewObject(class, name) class* This = (class*)(((char*)name)-_IViewObject_Offset);
93 /* ListView Header ID's */
94 #define LISTVIEW_COLUMN_NAME 0
95 #define LISTVIEW_COLUMN_SIZE 1
96 #define LISTVIEW_COLUMN_TYPE 2
97 #define LISTVIEW_COLUMN_TIME 3
98 #define LISTVIEW_COLUMN_ATTRIB 4
100 /*menu items */
101 #define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500)
102 #define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501)
103 #define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502)
105 #define ID_LISTVIEW 2000
107 #define SHV_CHANGE_NOTIFY WM_USER + 0x1111
109 /*windowsx.h */
110 #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
111 #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
112 #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
114 extern void WINAPI _InsertMenuItem (HMENU hmenu, UINT indexMenu, BOOL fByPosition,
115 UINT wID, UINT fType, LPSTR dwTypeData, UINT fState);
118 Items merged into the toolbar and and the filemenu
120 typedef struct
121 { int idCommand;
122 int iImage;
123 int idButtonString;
124 int idMenuString;
125 BYTE bState;
126 BYTE bStyle;
127 } MYTOOLINFO, *LPMYTOOLINFO;
129 MYTOOLINFO Tools[] =
131 { FCIDM_SHVIEW_BIGICON, 0, 0, IDS_VIEW_LARGE, TBSTATE_ENABLED, TBSTYLE_BUTTON },
132 { FCIDM_SHVIEW_SMALLICON, 0, 0, IDS_VIEW_SMALL, TBSTATE_ENABLED, TBSTYLE_BUTTON },
133 { FCIDM_SHVIEW_LISTVIEW, 0, 0, IDS_VIEW_LIST, TBSTATE_ENABLED, TBSTYLE_BUTTON },
134 { FCIDM_SHVIEW_REPORTVIEW, 0, 0, IDS_VIEW_DETAILS, TBSTATE_ENABLED, TBSTYLE_BUTTON },
135 { -1, 0, 0, 0, 0, 0}
138 typedef void CALLBACK (*PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
140 /**********************************************************
141 * IShellView_Constructor
143 IShellView * IShellView_Constructor( IShellFolder * pFolder)
144 { IShellViewImpl * sv;
145 sv=(IShellViewImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl));
146 sv->ref=1;
147 ICOM_VTBL(sv)=&svvt;
148 sv->lpvtblOleCommandTarget=&ctvt;
149 sv->lpvtblDropTarget=&dtvt;
150 sv->lpvtblDropSource=&dsvt;
151 sv->lpvtblViewObject=&vovt;
153 sv->pSFParent = pFolder;
154 if(pFolder) IShellFolder_AddRef(pFolder);
155 IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (LPVOID*)&sv->pSF2Parent);
157 TRACE("(%p)->(%p)\n",sv, pFolder);
158 shell32_ObjCount++;
159 return (IShellView *) sv;
162 /**********************************************************
164 * ##### helperfunctions for communication with ICommDlgBrowser #####
166 static BOOL IsInCommDlg(IShellViewImpl * This)
167 { return(This->pCommDlgBrowser != NULL);
170 static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl)
172 HRESULT ret = S_OK;
174 if ( IsInCommDlg(This) )
176 TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
177 ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView*)This, pidl);
178 TRACE("--0x%08lx\n", ret);
180 return ret;
183 static HRESULT OnDefaultCommand(IShellViewImpl * This)
185 HRESULT ret = S_FALSE;
187 if (IsInCommDlg(This))
189 TRACE("ICommDlgBrowser::OnDefaultCommand\n");
190 ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView*)This);
191 TRACE("--\n");
193 return ret;
196 static HRESULT OnStateChange(IShellViewImpl * This, UINT uFlags)
198 HRESULT ret = S_FALSE;
200 if (IsInCommDlg(This))
202 TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags);
203 ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView*)This, uFlags);
204 TRACE("--\n");
206 return ret;
208 /**********************************************************
209 * set the toolbar of the filedialog buttons
211 * - activates the buttons from the shellbrowser according to
212 * the view state
214 static void CheckToolbar(IShellViewImpl * This)
216 LRESULT result;
218 TRACE("\n");
220 if (IsInCommDlg(This))
222 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
223 FCIDM_TB_SMALLICON, (This->FolderSettings.ViewMode==FVM_LIST)? TRUE : FALSE, &result);
224 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
225 FCIDM_TB_REPORTVIEW, (This->FolderSettings.ViewMode==FVM_DETAILS)? TRUE : FALSE, &result);
226 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
227 FCIDM_TB_SMALLICON, TRUE, &result);
228 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
229 FCIDM_TB_REPORTVIEW, TRUE, &result);
233 /**********************************************************
235 * ##### helperfunctions for initializing the view #####
237 /**********************************************************
238 * change the style of the listview control
240 static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove)
242 DWORD tmpstyle;
244 TRACE("(%p)\n", This);
246 tmpstyle = GetWindowLongA(This->hWndList, GWL_STYLE);
247 SetWindowLongA(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove));
250 /**********************************************************
251 * ShellView_CreateList()
253 * - creates the list view window
255 static BOOL ShellView_CreateList (IShellViewImpl * This)
256 { DWORD dwStyle;
258 TRACE("%p\n",This);
260 dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
261 LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_AUTOARRANGE;
263 switch (This->FolderSettings.ViewMode)
265 case FVM_ICON: dwStyle |= LVS_ICON; break;
266 case FVM_DETAILS: dwStyle |= LVS_REPORT; break;
267 case FVM_SMALLICON: dwStyle |= LVS_SMALLICON; break;
268 case FVM_LIST: dwStyle |= LVS_LIST; break;
269 default: dwStyle |= LVS_LIST; break;
272 if (This->FolderSettings.fFlags & FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE;
273 /*if (This->FolderSettings.fFlags && FWF_DESKTOP); used from explorer*/
274 if (This->FolderSettings.fFlags & FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL;
276 This->hWndList=CreateWindowExA( WS_EX_CLIENTEDGE,
277 WC_LISTVIEWA,
278 NULL,
279 dwStyle,
280 0,0,0,0,
281 This->hWnd,
282 (HMENU)ID_LISTVIEW,
283 shell32_hInstance,
284 NULL);
286 if(!This->hWndList)
287 return FALSE;
289 This->ListViewSortInfo.bIsAscending = TRUE;
290 This->ListViewSortInfo.nHeaderID = -1;
291 This->ListViewSortInfo.nLastHeaderID = -1;
293 /* UpdateShellSettings(); */
294 return TRUE;
297 /**********************************************************
298 * ShellView_InitList()
300 * - adds all needed columns to the shellview
302 static BOOL ShellView_InitList(IShellViewImpl * This)
304 LVCOLUMNA lvColumn;
305 SHELLDETAILS sd;
306 int i;
307 char szTemp[50];
309 TRACE("%p\n",This);
311 ListView_DeleteAllItems(This->hWndList);
313 lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
314 lvColumn.pszText = szTemp;
316 if (This->pSF2Parent)
318 for (i=0; 1; i++)
320 if (!SUCCEEDED(IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, i, &sd)))
321 break;
322 lvColumn.fmt = sd.fmt;
323 lvColumn.cx = sd.cxChar*8; /* chars->pixel */
324 StrRetToStrNA( szTemp, 50, &sd.str, NULL);
325 ListView_InsertColumnA(This->hWndList, i, &lvColumn);
328 else
330 FIXME("no SF2\n");
333 ListView_SetImageList(This->hWndList, ShellSmallIconList, LVSIL_SMALL);
334 ListView_SetImageList(This->hWndList, ShellBigIconList, LVSIL_NORMAL);
336 return TRUE;
338 /**********************************************************
339 * ShellView_CompareItems()
341 * NOTES
342 * internal, CALLBACK for DSA_Sort
344 static INT CALLBACK ShellView_CompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
346 int ret;
347 TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1, lParam2, (LPVOID) lpData);
349 if(!lpData) return 0;
351 ret = (SHORT) SCODE_CODE(IShellFolder_CompareIDs((LPSHELLFOLDER)lpData, 0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2));
352 TRACE("ret=%i\n",ret);
353 return ret;
356 /*************************************************************************
357 * ShellView_ListViewCompareItems
359 * Compare Function for the Listview (FileOpen Dialog)
361 * PARAMS
362 * lParam1 [I] the first ItemIdList to compare with
363 * lParam2 [I] the second ItemIdList to compare with
364 * lpData [I] The column ID for the header Ctrl to process
366 * RETURNS
367 * A negative value if the first item should precede the second,
368 * a positive value if the first item should follow the second,
369 * or zero if the two items are equivalent
371 * NOTES
372 * FIXME: function does what ShellView_CompareItems is supposed to do.
373 * unify it and figure out how to use the undocumented first parameter
374 * of IShellFolder_CompareIDs to do the job this function does and
375 * move this code to IShellFolder.
376 * make LISTVIEW_SORT_INFO obsolete
377 * the way this function works is only usable if we had only
378 * filesystemfolders (25/10/99 jsch)
380 static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
382 INT nDiff=0;
383 FILETIME fd1, fd2;
384 char strName1[MAX_PATH], strName2[MAX_PATH];
385 BOOL bIsFolder1, bIsFolder2,bIsBothFolder;
386 LPITEMIDLIST pItemIdList1 = (LPITEMIDLIST) lParam1;
387 LPITEMIDLIST pItemIdList2 = (LPITEMIDLIST) lParam2;
388 LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData;
391 bIsFolder1 = _ILIsFolder(pItemIdList1);
392 bIsFolder2 = _ILIsFolder(pItemIdList2);
393 bIsBothFolder = bIsFolder1 && bIsFolder2;
395 /* When sorting between a File and a Folder, the Folder gets sorted first */
396 if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder)
398 nDiff = bIsFolder1 ? -1 : 1;
400 else
402 /* Sort by Time: Folders or Files can be sorted */
404 if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)
406 _ILGetFileDateTime(pItemIdList1, &fd1);
407 _ILGetFileDateTime(pItemIdList2, &fd2);
408 nDiff = CompareFileTime(&fd2, &fd1);
410 /* Sort by Attribute: Folder or Files can be sorted */
411 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB)
413 _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH);
414 _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH);
415 nDiff = strcasecmp(strName1, strName2);
417 /* Sort by FileName: Folder or Files can be sorted */
418 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder)
420 /* Sort by Text */
421 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
422 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
423 nDiff = strcasecmp(strName1, strName2);
425 /* Sort by File Size, Only valid for Files */
426 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)
428 nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0));
430 /* Sort by File Type, Only valid for Files */
431 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)
433 /* Sort by Type */
434 _ILGetFileType(pItemIdList1, strName1, MAX_PATH);
435 _ILGetFileType(pItemIdList2, strName2, MAX_PATH);
436 nDiff = strcasecmp(strName1, strName2);
439 /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
441 if(nDiff == 0)
443 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
444 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
445 nDiff = strcasecmp(strName1, strName2);
448 if(!pSortInfo->bIsAscending)
450 nDiff = -nDiff;
453 return nDiff;
457 /**********************************************************
458 * LV_FindItemByPidl()
460 static int LV_FindItemByPidl(
461 IShellViewImpl * This,
462 LPCITEMIDLIST pidl)
464 LVITEMA lvItem;
465 ZeroMemory(&lvItem, sizeof(LVITEMA));
466 lvItem.mask = LVIF_PARAM;
467 for(lvItem.iItem = 0; ListView_GetItemA(This->hWndList, &lvItem); lvItem.iItem++)
469 LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam;
470 HRESULT hr = IShellFolder_CompareIDs(This->pSFParent, 0, pidl, currentpidl);
471 if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
473 return lvItem.iItem;
476 return -1;
479 /**********************************************************
480 * LV_AddItem()
482 static BOOLEAN LV_AddItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
484 LVITEMA lvItem;
486 TRACE("(%p)(pidl=%p)\n", This, pidl);
488 ZeroMemory(&lvItem, sizeof(lvItem)); /* create the listview item*/
489 lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; /*set the mask*/
490 lvItem.iItem = ListView_GetItemCount(This->hWndList); /*add the item to the end of the list*/
491 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidl)); /*set the item's data*/
492 lvItem.pszText = LPSTR_TEXTCALLBACKA; /*get text on a callback basis*/
493 lvItem.iImage = I_IMAGECALLBACK; /*get the image on a callback basis*/
494 return (-1==ListView_InsertItemA(This->hWndList, &lvItem))? FALSE: TRUE;
497 /**********************************************************
498 * LV_DeleteItem()
500 static BOOLEAN LV_DeleteItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
502 int nIndex;
504 TRACE("(%p)(pidl=%p)\n", This, pidl);
506 nIndex = LV_FindItemByPidl(This, ILFindLastID(pidl));
507 return (-1==ListView_DeleteItem(This->hWndList, nIndex))? FALSE: TRUE;
510 /**********************************************************
511 * LV_RenameItem()
513 static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew )
515 int nItem;
516 LVITEMA lvItem;
518 TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew);
520 nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld));
521 if ( -1 != nItem )
523 ZeroMemory(&lvItem, sizeof(lvItem)); /* create the listview item*/
524 lvItem.mask = LVIF_PARAM; /* only the pidl */
525 lvItem.iItem = nItem;
526 ListView_GetItemA(This->hWndList, &lvItem);
528 SHFree((LPITEMIDLIST)lvItem.lParam);
529 lvItem.mask = LVIF_PARAM;
530 lvItem.iItem = nItem;
531 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew)); /* set the item's data */
532 ListView_SetItemA(This->hWndList, &lvItem);
533 ListView_Update(This->hWndList, nItem);
534 return TRUE; /* fixme: better handling */
536 return FALSE;
538 /**********************************************************
539 * ShellView_FillList()
541 * - gets the objectlist from the shellfolder
542 * - sorts the list
543 * - fills the list into the view
546 static HRESULT ShellView_FillList(IShellViewImpl * This)
548 LPENUMIDLIST pEnumIDList;
549 LPITEMIDLIST pidl;
550 DWORD dwFetched;
551 UINT i;
552 HRESULT hRes;
553 HDPA hdpa;
555 TRACE("%p\n",This);
557 /* get the itemlist from the shfolder*/
558 hRes = IShellFolder_EnumObjects(This->pSFParent,This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList);
559 if (hRes != S_OK)
561 if (hRes==S_FALSE)
562 return(NOERROR);
563 return(hRes);
566 /* create a pointer array */
567 hdpa = pDPA_Create(16);
568 if (!hdpa)
570 return(E_OUTOFMEMORY);
573 /* copy the items into the array*/
574 while((S_OK == IEnumIDList_Next(pEnumIDList,1, &pidl, &dwFetched)) && dwFetched)
576 if (pDPA_InsertPtr(hdpa, 0x7fff, pidl) == -1)
578 SHFree(pidl);
582 /* sort the array */
583 pDPA_Sort(hdpa, ShellView_CompareItems, (LPARAM)This->pSFParent);
585 /*turn the listview's redrawing off*/
586 SendMessageA(This->hWndList, WM_SETREDRAW, FALSE, 0);
588 for (i=0; i < DPA_GetPtrCount(hdpa); ++i) /* DPA_GetPtrCount is a macro*/
590 pidl = (LPITEMIDLIST)pDPA_GetPtr(hdpa, i);
592 /* in a commdlg This works as a filemask*/
593 if ( IncludeObject(This, pidl)==S_OK )
594 LV_AddItem(This, pidl);
595 SHFree(pidl);
598 /*turn the listview's redrawing back on and force it to draw*/
599 SendMessageA(This->hWndList, WM_SETREDRAW, TRUE, 0);
601 IEnumIDList_Release(pEnumIDList); /* destroy the list*/
602 pDPA_Destroy(hdpa);
604 return S_OK;
607 /**********************************************************
608 * ShellView_OnCreate()
610 static LRESULT ShellView_OnCreate(IShellViewImpl * This)
612 IDropTarget* pdt;
613 NOTIFYREGISTER ntreg;
614 IPersistFolder2 * ppf2 = NULL;
616 TRACE("%p\n",This);
618 if(ShellView_CreateList(This))
620 if(ShellView_InitList(This))
622 ShellView_FillList(This);
626 if(GetShellOle())
628 if (SUCCEEDED(IShellFolder_CreateViewObject(This->pSFParent, This->hWnd, &IID_IDropTarget, (LPVOID*)&pdt)))
630 pRegisterDragDrop(This->hWnd, pdt);
631 IDropTarget_Release(pdt);
635 /* register for receiving notifications */
636 IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2);
637 if (ppf2)
639 IPersistFolder2_GetCurFolder(ppf2, &ntreg.pidlPath);
640 ntreg.bWatchSubtree = FALSE;
641 This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNF_IDLIST, SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg);
642 SHFree(ntreg.pidlPath);
643 IPersistFolder2_Release(ppf2);
646 This->hAccel = LoadAcceleratorsA(shell32_hInstance, "shv_accel");
648 return S_OK;
651 /**********************************************************
652 * #### Handling of the menus ####
655 /**********************************************************
656 * ShellView_BuildFileMenu()
658 static HMENU ShellView_BuildFileMenu(IShellViewImpl * This)
659 { CHAR szText[MAX_PATH];
660 MENUITEMINFOA mii;
661 int nTools,i;
662 HMENU hSubMenu;
664 TRACE("(%p)\n",This);
666 hSubMenu = CreatePopupMenu();
667 if(hSubMenu)
668 { /*get the number of items in our global array*/
669 for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){}
671 /*add the menu items*/
672 for(i = 0; i < nTools; i++)
674 LoadStringA(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH);
676 ZeroMemory(&mii, sizeof(mii));
677 mii.cbSize = sizeof(mii);
678 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
680 if(TBSTYLE_SEP != Tools[i].bStyle) /* no seperator*/
682 mii.fType = MFT_STRING;
683 mii.fState = MFS_ENABLED;
684 mii.dwTypeData = szText;
685 mii.wID = Tools[i].idCommand;
687 else
689 mii.fType = MFT_SEPARATOR;
691 /* tack This item onto the end of the menu */
692 InsertMenuItemA(hSubMenu, (UINT)-1, TRUE, &mii);
695 TRACE("-- return (menu=0x%x)\n",hSubMenu);
696 return hSubMenu;
698 /**********************************************************
699 * ShellView_MergeFileMenu()
701 static void ShellView_MergeFileMenu(IShellViewImpl * This, HMENU hSubMenu)
702 { TRACE("(%p)->(submenu=0x%08x) stub\n",This,hSubMenu);
704 if(hSubMenu)
705 { /*insert This item at the beginning of the menu */
706 _InsertMenuItem(hSubMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
707 _InsertMenuItem(hSubMenu, 0, TRUE, IDM_MYFILEITEM, MFT_STRING, "dummy45", MFS_ENABLED);
710 TRACE("--\n");
713 /**********************************************************
714 * ShellView_MergeViewMenu()
717 static void ShellView_MergeViewMenu(IShellViewImpl * This, HMENU hSubMenu)
718 { MENUITEMINFOA mii;
720 TRACE("(%p)->(submenu=0x%08x)\n",This,hSubMenu);
722 if(hSubMenu)
723 { /*add a separator at the correct position in the menu*/
724 _InsertMenuItem(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
726 ZeroMemory(&mii, sizeof(mii));
727 mii.cbSize = sizeof(mii);
728 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;;
729 mii.fType = MFT_STRING;
730 mii.dwTypeData = "View";
731 mii.hSubMenu = LoadMenuA(shell32_hInstance, "MENU_001");
732 InsertMenuItemA(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
736 /**********************************************************
737 * ShellView_GetSelections()
739 * - fills the this->apidl list with the selected objects
741 * RETURNS
742 * number of selected items
744 static UINT ShellView_GetSelections(IShellViewImpl * This)
746 LVITEMA lvItem;
747 UINT i = 0;
749 if (This->apidl)
751 SHFree(This->apidl);
754 This->cidl = ListView_GetSelectedCount(This->hWndList);
755 This->apidl = (LPITEMIDLIST*)SHAlloc(This->cidl * sizeof(LPITEMIDLIST));
757 TRACE("selected=%i\n", This->cidl);
759 if(This->apidl)
761 TRACE("-- Items selected =%u\n", This->cidl);
763 ZeroMemory(&lvItem, sizeof(lvItem));
764 lvItem.mask = LVIF_STATE | LVIF_PARAM;
765 lvItem.stateMask = LVIS_SELECTED;
767 while(ListView_GetItemA(This->hWndList, &lvItem) && (i < This->cidl))
769 if(lvItem.state & LVIS_SELECTED)
771 This->apidl[i] = (LPITEMIDLIST)lvItem.lParam;
772 i++;
773 TRACE("-- selected Item found\n");
775 lvItem.iItem++;
778 return This->cidl;
781 /**********************************************************
782 * ShellView_DoContextMenu()
784 static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL bDefault)
785 { UINT uCommand;
786 DWORD wFlags;
787 HMENU hMenu;
788 BOOL fExplore = FALSE;
789 HWND hwndTree = 0;
790 LPCONTEXTMENU pContextMenu = NULL;
791 IContextMenu * pCM = NULL;
792 CMINVOKECOMMANDINFO cmi;
794 TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, bDefault);
796 /* look, what's selected and create a context menu object of it*/
797 if( ShellView_GetSelections(This) )
799 IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, This->apidl,
800 (REFIID)&IID_IContextMenu, NULL, (LPVOID *)&pContextMenu);
802 if(pContextMenu)
804 TRACE("-- pContextMenu\n");
805 hMenu = CreatePopupMenu();
807 if( hMenu )
809 /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
810 if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree)
812 TRACE("-- explore mode\n");
813 fExplore = TRUE;
816 /* build the flags depending on what we can do with the selected item */
817 wFlags = CMF_NORMAL | (This->cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0);
819 /* let the ContextMenu merge its items in */
820 if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags )))
822 if( bDefault )
824 TRACE("-- get menu default command\n");
825 uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS);
827 else
829 TRACE("-- track popup\n");
830 uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
833 if(uCommand > 0)
835 TRACE("-- uCommand=%u\n", uCommand);
836 if (IsInCommDlg(This) && ((uCommand==FCIDM_SHVIEW_EXPLORE) || (uCommand==FCIDM_SHVIEW_OPEN)))
838 TRACE("-- dlg: OnDefaultCommand\n");
839 OnDefaultCommand(This);
841 else
843 TRACE("-- explore -- invoke command\n");
844 ZeroMemory(&cmi, sizeof(cmi));
845 cmi.cbSize = sizeof(cmi);
846 cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */
847 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
848 IContextMenu_InvokeCommand(pContextMenu, &cmi);
851 DestroyMenu(hMenu);
854 if (pContextMenu)
855 IContextMenu_Release(pContextMenu);
858 else /* background context menu */
860 hMenu = CreatePopupMenu();
862 pCM = ISvBgCm_Constructor(This->pSFParent);
863 IContextMenu_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
865 uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
866 DestroyMenu(hMenu);
868 TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand);
870 ZeroMemory(&cmi, sizeof(cmi));
871 cmi.cbSize = sizeof(cmi);
872 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
873 cmi.hwnd = This->hWndParent;
874 IContextMenu_InvokeCommand(pCM, &cmi);
876 IContextMenu_Release(pCM);
880 /**********************************************************
881 * ##### message handling #####
884 /**********************************************************
885 * ShellView_OnSize()
887 static LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight)
889 TRACE("%p width=%u height=%u\n",This, wWidth,wHeight);
891 /*resize the ListView to fit our window*/
892 if(This->hWndList)
894 MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE);
897 return S_OK;
899 /**********************************************************
900 * ShellView_OnDeactivate()
902 * NOTES
903 * internal
905 static void ShellView_OnDeactivate(IShellViewImpl * This)
907 TRACE("%p\n",This);
909 if(This->uState != SVUIA_DEACTIVATE)
911 if(This->hMenu)
913 IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0);
914 IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu);
915 DestroyMenu(This->hMenu);
916 This->hMenu = 0;
919 This->uState = SVUIA_DEACTIVATE;
923 /**********************************************************
924 * ShellView_OnActivate()
926 static LRESULT ShellView_OnActivate(IShellViewImpl * This, UINT uState)
927 { OLEMENUGROUPWIDTHS omw = { {0, 0, 0, 0, 0, 0} };
928 MENUITEMINFOA mii;
929 CHAR szText[MAX_PATH];
931 TRACE("%p uState=%x\n",This,uState);
933 /*don't do anything if the state isn't really changing */
934 if(This->uState == uState)
936 return S_OK;
939 ShellView_OnDeactivate(This);
941 /*only do This if we are active */
942 if(uState != SVUIA_DEACTIVATE)
944 /*merge the menus */
945 This->hMenu = CreateMenu();
947 if(This->hMenu)
949 IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw);
950 TRACE("-- after fnInsertMenusSB\n");
952 /*build the top level menu get the menu item's text*/
953 strcpy(szText,"dummy 31");
955 ZeroMemory(&mii, sizeof(mii));
956 mii.cbSize = sizeof(mii);
957 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
958 mii.fType = MFT_STRING;
959 mii.fState = MFS_ENABLED;
960 mii.dwTypeData = szText;
961 mii.hSubMenu = ShellView_BuildFileMenu(This);
963 /*insert our menu into the menu bar*/
964 if(mii.hSubMenu)
966 InsertMenuItemA(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii);
969 /*get the view menu so we can merge with it*/
970 ZeroMemory(&mii, sizeof(mii));
971 mii.cbSize = sizeof(mii);
972 mii.fMask = MIIM_SUBMENU;
974 if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii))
976 ShellView_MergeViewMenu(This, mii.hSubMenu);
979 /*add the items that should only be added if we have the focus*/
980 if(SVUIA_ACTIVATE_FOCUS == uState)
982 /*get the file menu so we can merge with it */
983 ZeroMemory(&mii, sizeof(mii));
984 mii.cbSize = sizeof(mii);
985 mii.fMask = MIIM_SUBMENU;
987 if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii))
989 ShellView_MergeFileMenu(This, mii.hSubMenu);
992 TRACE("-- before fnSetMenuSB\n");
993 IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd);
996 This->uState = uState;
997 TRACE("--\n");
998 return S_OK;
1001 /**********************************************************
1002 * ShellView_OnSetFocus()
1005 static LRESULT ShellView_OnSetFocus(IShellViewImpl * This)
1007 TRACE("%p\n",This);
1009 /* Tell the browser one of our windows has received the focus. This
1010 should always be done before merging menus (OnActivate merges the
1011 menus) if one of our windows has the focus.*/
1013 IShellBrowser_OnViewWindowActive(This->pShellBrowser,(IShellView*) This);
1014 ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS);
1016 /* Set the focus to the listview */
1017 SetFocus(This->hWndList);
1019 /* Notify the ICommDlgBrowser interface */
1020 OnStateChange(This,CDBOSC_SETFOCUS);
1022 return 0;
1025 /**********************************************************
1026 * ShellView_OnKillFocus()
1028 static LRESULT ShellView_OnKillFocus(IShellViewImpl * This)
1030 TRACE("(%p) stub\n",This);
1032 ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS);
1033 /* Notify the ICommDlgBrowser */
1034 OnStateChange(This,CDBOSC_KILLFOCUS);
1036 return 0;
1039 /**********************************************************
1040 * ShellView_OnCommand()
1042 * NOTES
1043 * the CmdID's are the ones from the context menu
1045 static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd)
1047 TRACE("(%p)->(0x%08lx 0x%08lx 0x%08x) stub\n",This, dwCmdID, dwCmd, hwndCmd);
1049 switch(dwCmdID)
1051 case FCIDM_SHVIEW_SMALLICON:
1052 This->FolderSettings.ViewMode = FVM_SMALLICON;
1053 SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK);
1054 CheckToolbar(This);
1055 break;
1057 case FCIDM_SHVIEW_BIGICON:
1058 This->FolderSettings.ViewMode = FVM_ICON;
1059 SetStyle (This, LVS_ICON, LVS_TYPEMASK);
1060 CheckToolbar(This);
1061 break;
1063 case FCIDM_SHVIEW_LISTVIEW:
1064 This->FolderSettings.ViewMode = FVM_LIST;
1065 SetStyle (This, LVS_LIST, LVS_TYPEMASK);
1066 CheckToolbar(This);
1067 break;
1069 case FCIDM_SHVIEW_REPORTVIEW:
1070 This->FolderSettings.ViewMode = FVM_DETAILS;
1071 SetStyle (This, LVS_REPORT, LVS_TYPEMASK);
1072 CheckToolbar(This);
1073 break;
1075 /* the menu-ID's for sorting are 0x30... see shrec.rc */
1076 case 0x30:
1077 case 0x31:
1078 case 0x32:
1079 case 0x33:
1080 This->ListViewSortInfo.nHeaderID = (LPARAM) (dwCmdID - 0x30);
1081 This->ListViewSortInfo.bIsAscending = TRUE;
1082 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1083 ListView_SortItems(This->hWndList, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1084 break;
1086 default:
1087 TRACE("-- COMMAND 0x%04lx unhandled\n", dwCmdID);
1089 return 0;
1092 /**********************************************************
1093 * ShellView_OnNotify()
1096 static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
1097 { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
1098 NMLVDISPINFOA *lpdi = (NMLVDISPINFOA *)lpnmh;
1099 LPITEMIDLIST pidl;
1101 TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code);
1103 switch(lpnmh->code)
1105 case NM_SETFOCUS:
1106 TRACE("-- NM_SETFOCUS %p\n",This);
1107 ShellView_OnSetFocus(This);
1108 break;
1110 case NM_KILLFOCUS:
1111 TRACE("-- NM_KILLFOCUS %p\n",This);
1112 ShellView_OnDeactivate(This);
1113 /* Notify the ICommDlgBrowser interface */
1114 OnStateChange(This,CDBOSC_KILLFOCUS);
1115 break;
1117 case HDN_ENDTRACKA:
1118 TRACE("-- HDN_ENDTRACKA %p\n",This);
1119 /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
1120 nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
1121 break;
1123 case LVN_DELETEITEM:
1124 TRACE("-- LVN_DELETEITEM %p\n",This);
1125 SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/
1126 break;
1128 case LVN_ITEMACTIVATE:
1129 TRACE("-- LVN_ITEMACTIVATE %p\n",This);
1130 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1131 ShellView_DoContextMenu(This, 0, 0, TRUE);
1132 break;
1134 case LVN_COLUMNCLICK:
1135 This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem;
1136 if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID)
1138 This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending;
1140 else
1142 This->ListViewSortInfo.bIsAscending = TRUE;
1144 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1146 ListView_SortItems(lpnmlv->hdr.hwndFrom, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1147 break;
1149 case LVN_GETDISPINFOA:
1150 TRACE("-- LVN_GETDISPINFOA %p\n",This);
1151 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1153 if(lpdi->item.mask & LVIF_TEXT) /* text requested */
1155 if (This->pSF2Parent)
1157 SHELLDETAILS sd;
1158 IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
1159 StrRetToStrNA( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1160 TRACE("-- text=%s\n",lpdi->item.pszText);
1162 else
1164 FIXME("no SF2\n");
1167 if(lpdi->item.mask & LVIF_IMAGE) /* image requested */
1169 lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
1171 break;
1173 case LVN_ITEMCHANGED:
1174 TRACE("-- LVN_ITEMCHANGED %p\n",This);
1175 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1176 break;
1178 case LVN_BEGINDRAG:
1179 case LVN_BEGINRDRAG:
1180 TRACE("-- LVN_BEGINDRAG\n");
1182 if (ShellView_GetSelections(This))
1184 IDataObject * pda;
1185 DWORD dwAttributes = SFGAO_CANLINK;
1186 DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
1188 if(GetShellOle())
1190 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
1192 IDropSource * pds = (IDropSource*)&(This->lpvtblDropSource); /* own DropSource interface */
1194 if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, This->apidl, &dwAttributes)))
1196 if (dwAttributes & SFGAO_CANLINK)
1198 dwEffect |= DROPEFFECT_LINK;
1202 if (pds)
1204 DWORD dwEffect;
1205 pDoDragDrop(pda, pds, dwEffect, &dwEffect);
1207 IDataObject_Release(pda);
1211 break;
1213 case LVN_BEGINLABELEDITA:
1215 DWORD dwAttr = SFGAO_CANRENAME;
1216 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1218 TRACE("-- LVN_BEGINLABELEDITA %p\n",This);
1220 IShellFolder_GetAttributesOf(This->pSFParent, 1, &pidl, &dwAttr);
1221 if (SFGAO_CANRENAME & dwAttr)
1223 return FALSE;
1225 return TRUE;
1227 break;
1229 case LVN_ENDLABELEDITA:
1231 TRACE("-- LVN_ENDLABELEDITA %p\n",This);
1232 if (lpdi->item.pszText)
1234 HRESULT hr;
1235 WCHAR wszNewName[MAX_PATH];
1236 LVITEMA lvItem;
1238 ZeroMemory(&lvItem, sizeof(LVITEMA));
1239 lvItem.iItem = lpdi->item.iItem;
1240 lvItem.mask = LVIF_PARAM;
1241 ListView_GetItemA(This->hWndList, &lvItem);
1243 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1244 if (!MultiByteToWideChar( CP_ACP, 0, lpdi->item.pszText, -1, wszNewName, MAX_PATH ))
1245 wszNewName[MAX_PATH-1] = 0;
1246 hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, wszNewName, SHGDN_INFOLDER, &pidl);
1248 if(SUCCEEDED(hr) && pidl)
1250 lvItem.mask = LVIF_PARAM;
1251 lvItem.lParam = (LPARAM)pidl;
1252 ListView_SetItemA(This->hWndList, &lvItem);
1253 return TRUE;
1256 return FALSE;
1258 break;
1260 case LVN_KEYDOWN:
1262 /* MSG msg;
1263 msg.hwnd = This->hWnd;
1264 msg.message = WM_KEYDOWN;
1265 msg.wParam = plvKeyDown->wVKey;
1266 msg.lParam = 0;
1267 msg.time = 0;
1268 msg.pt = 0;*/
1270 LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
1272 /* initiate a rename of the selected file or directory */
1273 if(plvKeyDown->wVKey == VK_F2)
1275 /* see how many files are selected */
1276 int i = ListView_GetSelectedCount(This->hWndList);
1278 /* get selected item */
1279 if(i == 1)
1281 /* get selected item */
1282 i = ListView_GetNextItem(This->hWndList, -1,
1283 LVNI_SELECTED);
1285 ListView_EnsureVisible(This->hWndList, i, 0);
1286 ListView_EditLabelA(This->hWndList, i);
1289 #if 0
1290 TranslateAccelerator(This->hWnd, This->hAccel, &msg)
1291 #endif
1292 else if(plvKeyDown->wVKey == VK_DELETE)
1294 int i, item_index;
1295 LVITEMA item;
1296 LPITEMIDLIST* pItems;
1297 ISFHelper *psfhlp;
1299 IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper,
1300 (LPVOID*)&psfhlp);
1302 if(!(i = ListView_GetSelectedCount(This->hWndList)))
1303 break;
1305 /* allocate memory for the pidl array */
1306 pItems = HeapAlloc(GetProcessHeap(), 0,
1307 sizeof(LPITEMIDLIST) * i);
1309 /* retrieve all selected items */
1310 i = 0;
1311 item_index = -1;
1312 while(ListView_GetSelectedCount(This->hWndList) > i)
1314 /* get selected item */
1315 item_index = ListView_GetNextItem(This->hWndList,
1316 item_index, LVNI_SELECTED);
1317 item.iItem = item_index;
1318 ListView_GetItemA(This->hWndList, &item);
1320 /* get item pidl */
1321 pItems[i] = (LPITEMIDLIST)item.lParam;
1323 i++;
1326 /* perform the item deletion */
1327 ISFHelper_DeleteItems(psfhlp, i, pItems);
1329 /* free pidl array memory */
1330 HeapFree(GetProcessHeap(), 0, pItems);
1332 else
1333 FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey);
1335 break;
1337 default:
1338 TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code);
1339 break;;
1341 return 0;
1344 /**********************************************************
1345 * ShellView_OnChange()
1348 static LRESULT ShellView_OnChange(IShellViewImpl * This, LPITEMIDLIST * Pidls, LONG wEventId)
1351 TRACE("(%p)(%p,%p,0x%08lx)\n", This, Pidls[0], Pidls[1], wEventId);
1352 switch(wEventId)
1354 case SHCNE_MKDIR:
1355 case SHCNE_CREATE:
1356 LV_AddItem(This, Pidls[0]);
1357 break;
1358 case SHCNE_RMDIR:
1359 case SHCNE_DELETE:
1360 LV_DeleteItem(This, Pidls[0]);
1361 break;
1362 case SHCNE_RENAMEFOLDER:
1363 case SHCNE_RENAMEITEM:
1364 LV_RenameItem(This, Pidls[0], Pidls[1]);
1365 break;
1366 case SHCNE_UPDATEITEM:
1367 break;
1369 return TRUE;
1371 /**********************************************************
1372 * ShellView_WndProc
1375 static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1377 IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongA(hWnd, GWL_USERDATA);
1378 LPCREATESTRUCTA lpcs;
1380 TRACE("(hwnd=%x msg=%x wparm=%x lparm=%lx)\n",hWnd, uMessage, wParam, lParam);
1382 switch (uMessage)
1384 case WM_NCCREATE:
1385 lpcs = (LPCREATESTRUCTA)lParam;
1386 pThis = (IShellViewImpl*)(lpcs->lpCreateParams);
1387 SetWindowLongA(hWnd, GWL_USERDATA, (LONG)pThis);
1388 pThis->hWnd = hWnd; /*set the window handle*/
1389 break;
1391 case WM_SIZE: return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam));
1392 case WM_SETFOCUS: return ShellView_OnSetFocus(pThis);
1393 case WM_KILLFOCUS: return ShellView_OnKillFocus(pThis);
1394 case WM_CREATE: return ShellView_OnCreate(pThis);
1395 case WM_ACTIVATE: return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS);
1396 case WM_NOTIFY: return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam);
1397 case WM_COMMAND: return ShellView_OnCommand(pThis,
1398 GET_WM_COMMAND_ID(wParam, lParam),
1399 GET_WM_COMMAND_CMD(wParam, lParam),
1400 GET_WM_COMMAND_HWND(wParam, lParam));
1401 case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (LPITEMIDLIST*)wParam, (LONG)lParam);
1403 case WM_CONTEXTMENU: ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE);
1404 return 0;
1406 case WM_SHOWWINDOW: UpdateWindow(pThis->hWndList);
1407 break;
1409 case WM_GETDLGCODE: return SendMessageA(pThis->hWndList,uMessage,0,0);
1411 case WM_DESTROY: if(GetShellOle())
1413 pRevokeDragDrop(pThis->hWnd);
1415 SHChangeNotifyDeregister(pThis->hNotify);
1416 break;
1419 return DefWindowProcA (hWnd, uMessage, wParam, lParam);
1421 /**********************************************************
1424 * The INTERFACE of the IShellView object
1427 **********************************************************
1428 * IShellView_QueryInterface
1430 static HRESULT WINAPI IShellView_fnQueryInterface(IShellView * iface,REFIID riid, LPVOID *ppvObj)
1432 ICOM_THIS(IShellViewImpl, iface);
1434 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1436 *ppvObj = NULL;
1438 if(IsEqualIID(riid, &IID_IUnknown))
1440 *ppvObj = This;
1442 else if(IsEqualIID(riid, &IID_IShellView))
1444 *ppvObj = (IShellView*)This;
1446 else if(IsEqualIID(riid, &IID_IOleCommandTarget))
1448 *ppvObj = (IOleCommandTarget*)&(This->lpvtblOleCommandTarget);
1450 else if(IsEqualIID(riid, &IID_IDropTarget))
1452 *ppvObj = (IDropTarget*)&(This->lpvtblDropTarget);
1454 else if(IsEqualIID(riid, &IID_IDropSource))
1456 *ppvObj = (IDropSource*)&(This->lpvtblDropSource);
1458 else if(IsEqualIID(riid, &IID_IViewObject))
1460 *ppvObj = (IViewObject*)&(This->lpvtblViewObject);
1463 if(*ppvObj)
1465 IUnknown_AddRef( (IUnknown*)*ppvObj );
1466 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1467 return S_OK;
1469 TRACE("-- Interface: E_NOINTERFACE\n");
1470 return E_NOINTERFACE;
1473 /**********************************************************
1474 * IShellView_AddRef
1476 static ULONG WINAPI IShellView_fnAddRef(IShellView * iface)
1478 ICOM_THIS(IShellViewImpl, iface);
1480 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1482 shell32_ObjCount++;
1483 return ++(This->ref);
1485 /**********************************************************
1486 * IShellView_Release
1488 static ULONG WINAPI IShellView_fnRelease(IShellView * iface)
1490 ICOM_THIS(IShellViewImpl, iface);
1492 TRACE("(%p)->()\n",This);
1494 shell32_ObjCount--;
1496 if (!--(This->ref))
1498 TRACE(" destroying IShellView(%p)\n",This);
1500 if(This->pSFParent)
1501 IShellFolder_Release(This->pSFParent);
1503 if(This->pSF2Parent)
1504 IShellFolder2_Release(This->pSF2Parent);
1506 if (This->apidl)
1507 SHFree(This->apidl);
1509 if (This->pCommDlgBrowser)
1510 ICommDlgBrowser_Release(This->pCommDlgBrowser);
1512 HeapFree(GetProcessHeap(),0,This);
1513 return 0;
1515 return This->ref;
1518 /**********************************************************
1519 * ShellView_GetWindow
1521 static HRESULT WINAPI IShellView_fnGetWindow(IShellView * iface,HWND * phWnd)
1523 ICOM_THIS(IShellViewImpl, iface);
1525 TRACE("(%p)\n",This);
1527 *phWnd = This->hWnd;
1529 return S_OK;
1532 static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView * iface,BOOL fEnterMode)
1534 ICOM_THIS(IShellViewImpl, iface);
1536 FIXME("(%p) stub\n",This);
1538 return E_NOTIMPL;
1541 /**********************************************************
1542 * IShellView_TranslateAccelerator
1544 * FIXME:
1545 * use the accel functions
1547 static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg)
1549 #if 0
1550 ICOM_THIS(IShellViewImpl, iface);
1552 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1553 #endif
1555 if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST))
1557 TRACE("-- key=0x04%x",lpmsg->wParam) ;
1559 return S_FALSE; /* not handled */
1562 static HRESULT WINAPI IShellView_fnEnableModeless(IShellView * iface,BOOL fEnable)
1564 ICOM_THIS(IShellViewImpl, iface);
1566 FIXME("(%p) stub\n",This);
1568 return E_NOTIMPL;
1571 static HRESULT WINAPI IShellView_fnUIActivate(IShellView * iface,UINT uState)
1573 ICOM_THIS(IShellViewImpl, iface);
1576 CHAR szName[MAX_PATH];
1578 LRESULT lResult;
1579 int nPartArray[1] = {-1};
1581 TRACE("(%p)->(state=%x) stub\n",This, uState);
1583 /*don't do anything if the state isn't really changing*/
1584 if(This->uState == uState)
1586 return S_OK;
1589 /*OnActivate handles the menu merging and internal state*/
1590 ShellView_OnActivate(This, uState);
1592 /*only do This if we are active*/
1593 if(uState != SVUIA_DEACTIVATE)
1597 GetFolderPath is not a method of IShellFolder
1598 IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1600 /* set the number of parts */
1601 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1602 (LPARAM)nPartArray, &lResult);
1604 /* set the text for the parts */
1606 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1607 0, (LPARAM)szName, &lResult);
1611 return S_OK;
1614 static HRESULT WINAPI IShellView_fnRefresh(IShellView * iface)
1616 ICOM_THIS(IShellViewImpl, iface);
1618 TRACE("(%p)\n",This);
1620 ListView_DeleteAllItems(This->hWndList);
1621 ShellView_FillList(This);
1623 return S_OK;
1626 static HRESULT WINAPI IShellView_fnCreateViewWindow(
1627 IShellView * iface,
1628 IShellView *lpPrevView,
1629 LPCFOLDERSETTINGS lpfs,
1630 IShellBrowser * psb,
1631 RECT * prcView,
1632 HWND *phWnd)
1634 ICOM_THIS(IShellViewImpl, iface);
1636 WNDCLASSA wc;
1637 *phWnd = 0;
1640 TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This, lpPrevView,lpfs, psb, prcView, phWnd);
1641 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);
1643 /*set up the member variables*/
1644 This->pShellBrowser = psb;
1645 This->FolderSettings = *lpfs;
1647 /*get our parent window*/
1648 IShellBrowser_AddRef(This->pShellBrowser);
1649 IShellBrowser_GetWindow(This->pShellBrowser, &(This->hWndParent));
1651 /* try to get the ICommDlgBrowserInterface, adds a reference !!! */
1652 This->pCommDlgBrowser=NULL;
1653 if ( SUCCEEDED (IShellBrowser_QueryInterface( This->pShellBrowser,
1654 (REFIID)&IID_ICommDlgBrowser, (LPVOID*) &This->pCommDlgBrowser)))
1656 TRACE("-- CommDlgBrowser\n");
1659 /*if our window class has not been registered, then do so*/
1660 if(!GetClassInfoA(shell32_hInstance, SV_CLASS_NAME, &wc))
1662 ZeroMemory(&wc, sizeof(wc));
1663 wc.style = CS_HREDRAW | CS_VREDRAW;
1664 wc.lpfnWndProc = (WNDPROC) ShellView_WndProc;
1665 wc.cbClsExtra = 0;
1666 wc.cbWndExtra = 0;
1667 wc.hInstance = shell32_hInstance;
1668 wc.hIcon = 0;
1669 wc.hCursor = LoadCursorA (0, IDC_ARROWA);
1670 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
1671 wc.lpszMenuName = NULL;
1672 wc.lpszClassName = SV_CLASS_NAME;
1674 if(!RegisterClassA(&wc))
1675 return E_FAIL;
1678 *phWnd = CreateWindowExA(0,
1679 SV_CLASS_NAME,
1680 NULL,
1681 WS_CHILD | WS_VISIBLE | WS_TABSTOP,
1682 prcView->left,
1683 prcView->top,
1684 prcView->right - prcView->left,
1685 prcView->bottom - prcView->top,
1686 This->hWndParent,
1688 shell32_hInstance,
1689 (LPVOID)This);
1691 CheckToolbar(This);
1693 if(!*phWnd) return E_FAIL;
1695 return S_OK;
1698 static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView * iface)
1700 ICOM_THIS(IShellViewImpl, iface);
1702 TRACE("(%p)\n",This);
1704 /*Make absolutely sure all our UI is cleaned up.*/
1705 IShellView_UIActivate((IShellView*)This, SVUIA_DEACTIVATE);
1707 if(This->hMenu)
1709 DestroyMenu(This->hMenu);
1712 DestroyWindow(This->hWnd);
1713 IShellBrowser_Release(This->pShellBrowser);
1715 return S_OK;
1718 static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView * iface, LPFOLDERSETTINGS lpfs)
1720 ICOM_THIS(IShellViewImpl, iface);
1722 TRACE("(%p)->(%p) vmode=%x flags=%x\n",This, lpfs,
1723 This->FolderSettings.ViewMode, This->FolderSettings.fFlags);
1725 if (!lpfs) return E_INVALIDARG;
1727 *lpfs = This->FolderSettings;
1728 return NOERROR;
1731 static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView * iface, DWORD dwReserved,LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
1733 ICOM_THIS(IShellViewImpl, iface);
1735 FIXME("(%p) stub\n",This);
1737 return E_NOTIMPL;
1740 static HRESULT WINAPI IShellView_fnSaveViewState(IShellView * iface)
1742 ICOM_THIS(IShellViewImpl, iface);
1744 FIXME("(%p) stub\n",This);
1746 return S_OK;
1749 static HRESULT WINAPI IShellView_fnSelectItem(
1750 IShellView * iface,
1751 LPCITEMIDLIST pidl,
1752 UINT uFlags)
1754 ICOM_THIS(IShellViewImpl, iface);
1755 int i;
1757 TRACE("(%p)->(pidl=%p, 0x%08x) stub\n",This, pidl, uFlags);
1759 i = LV_FindItemByPidl(This, pidl);
1761 if (i != -1)
1763 LVITEMA lvItem;
1765 if(uFlags & SVSI_ENSUREVISIBLE)
1766 ListView_EnsureVisible(This->hWndList, i, 0);
1768 ZeroMemory(&lvItem, sizeof(LVITEMA));
1769 lvItem.mask = LVIF_STATE;
1770 lvItem.iItem = 0;
1772 while(ListView_GetItemA(This->hWndList, &lvItem))
1774 if (lvItem.iItem == i)
1776 if (uFlags & SVSI_SELECT)
1777 lvItem.state |= LVIS_SELECTED;
1778 else
1779 lvItem.state &= ~LVIS_SELECTED;
1781 if(uFlags & SVSI_FOCUSED)
1782 lvItem.state &= ~LVIS_FOCUSED;
1784 else
1786 if (uFlags & SVSI_DESELECTOTHERS)
1787 lvItem.state &= ~LVIS_SELECTED;
1789 ListView_SetItemA(This->hWndList, &lvItem);
1790 lvItem.iItem++;
1794 if(uFlags & SVSI_EDIT)
1795 ListView_EditLabelA(This->hWndList, i);
1798 return S_OK;
1801 static HRESULT WINAPI IShellView_fnGetItemObject(IShellView * iface, UINT uItem, REFIID riid, LPVOID *ppvOut)
1803 ICOM_THIS(IShellViewImpl, iface);
1805 TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This, uItem, debugstr_guid(riid), ppvOut);
1807 *ppvOut = NULL;
1809 switch(uItem)
1811 case SVGIO_BACKGROUND:
1812 *ppvOut = ISvBgCm_Constructor(This->pSFParent);
1813 break;
1815 case SVGIO_SELECTION:
1816 ShellView_GetSelections(This);
1817 IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, riid, 0, ppvOut);
1818 break;
1820 TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
1822 if(!*ppvOut) return E_OUTOFMEMORY;
1824 return S_OK;
1827 static HRESULT WINAPI IShellView_fnEditItem(
1828 IShellView * iface,
1829 LPITEMIDLIST pidl)
1831 ICOM_THIS(IShellViewImpl, iface);
1832 int i;
1834 TRACE("(%p)->(pidl=%p)\n",This, pidl);
1836 i = LV_FindItemByPidl(This, pidl);
1837 if (i != -1)
1839 SetFocus(This->hWndList);
1840 ListView_EditLabelA(This->hWndList, i);
1842 return S_OK;
1845 static struct ICOM_VTABLE(IShellView) svvt =
1847 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1848 IShellView_fnQueryInterface,
1849 IShellView_fnAddRef,
1850 IShellView_fnRelease,
1851 IShellView_fnGetWindow,
1852 IShellView_fnContextSensitiveHelp,
1853 IShellView_fnTranslateAccelerator,
1854 IShellView_fnEnableModeless,
1855 IShellView_fnUIActivate,
1856 IShellView_fnRefresh,
1857 IShellView_fnCreateViewWindow,
1858 IShellView_fnDestroyViewWindow,
1859 IShellView_fnGetCurrentInfo,
1860 IShellView_fnAddPropertySheetPages,
1861 IShellView_fnSaveViewState,
1862 IShellView_fnSelectItem,
1863 IShellView_fnGetItemObject,
1864 IShellView_fnEditItem
1868 /**********************************************************
1869 * ISVOleCmdTarget_QueryInterface (IUnknown)
1871 static HRESULT WINAPI ISVOleCmdTarget_QueryInterface(
1872 IOleCommandTarget * iface,
1873 REFIID iid,
1874 LPVOID* ppvObj)
1876 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1878 return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj);
1881 /**********************************************************
1882 * ISVOleCmdTarget_AddRef (IUnknown)
1884 static ULONG WINAPI ISVOleCmdTarget_AddRef(
1885 IOleCommandTarget * iface)
1887 _ICOM_THIS_From_IOleCommandTarget(IShellFolder, iface);
1889 return IShellFolder_AddRef((IShellFolder*)This);
1892 /**********************************************************
1893 * ISVOleCmdTarget_Release (IUnknown)
1895 static ULONG WINAPI ISVOleCmdTarget_Release(
1896 IOleCommandTarget * iface)
1898 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1900 return IShellFolder_Release((IShellFolder*)This);
1903 /**********************************************************
1904 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
1906 static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
1907 IOleCommandTarget *iface,
1908 const GUID* pguidCmdGroup,
1909 ULONG cCmds,
1910 OLECMD * prgCmds,
1911 OLECMDTEXT* pCmdText)
1913 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1915 FIXME("(%p)->(%p(%s) 0x%08lx %p %p\n",
1916 This, pguidCmdGroup, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
1917 return E_NOTIMPL;
1920 /**********************************************************
1921 * ISVOleCmdTarget_Exec (IOleCommandTarget)
1923 * nCmdID is the OLECMDID_* enumeration
1925 static HRESULT WINAPI ISVOleCmdTarget_Exec(
1926 IOleCommandTarget *iface,
1927 const GUID* pguidCmdGroup,
1928 DWORD nCmdID,
1929 DWORD nCmdexecopt,
1930 VARIANT* pvaIn,
1931 VARIANT* pvaOut)
1933 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1935 FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08lx Opt:0x%08lx %p %p)\n",
1936 This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, pvaIn, pvaOut);
1937 return E_NOTIMPL;
1940 static ICOM_VTABLE(IOleCommandTarget) ctvt =
1942 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1943 ISVOleCmdTarget_QueryInterface,
1944 ISVOleCmdTarget_AddRef,
1945 ISVOleCmdTarget_Release,
1946 ISVOleCmdTarget_QueryStatus,
1947 ISVOleCmdTarget_Exec
1950 /**********************************************************
1951 * ISVDropTarget implementation
1954 static HRESULT WINAPI ISVDropTarget_QueryInterface(
1955 IDropTarget *iface,
1956 REFIID riid,
1957 LPVOID *ppvObj)
1959 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1961 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1963 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
1966 static ULONG WINAPI ISVDropTarget_AddRef( IDropTarget *iface)
1968 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1970 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1972 return IShellFolder_AddRef((IShellFolder*)This);
1975 static ULONG WINAPI ISVDropTarget_Release( IDropTarget *iface)
1977 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1979 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1981 return IShellFolder_Release((IShellFolder*)This);
1984 static HRESULT WINAPI ISVDropTarget_DragEnter(
1985 IDropTarget *iface,
1986 IDataObject *pDataObject,
1987 DWORD grfKeyState,
1988 POINTL pt,
1989 DWORD *pdwEffect)
1992 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1994 FIXME("Stub: This=%p, DataObject=%p\n",This,pDataObject);
1996 return E_NOTIMPL;
1999 static HRESULT WINAPI ISVDropTarget_DragOver(
2000 IDropTarget *iface,
2001 DWORD grfKeyState,
2002 POINTL pt,
2003 DWORD *pdwEffect)
2005 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2007 FIXME("Stub: This=%p\n",This);
2009 return E_NOTIMPL;
2012 static HRESULT WINAPI ISVDropTarget_DragLeave(
2013 IDropTarget *iface)
2015 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2017 FIXME("Stub: This=%p\n",This);
2019 return E_NOTIMPL;
2022 static HRESULT WINAPI ISVDropTarget_Drop(
2023 IDropTarget *iface,
2024 IDataObject* pDataObject,
2025 DWORD grfKeyState,
2026 POINTL pt,
2027 DWORD *pdwEffect)
2029 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2031 FIXME("Stub: This=%p\n",This);
2033 return E_NOTIMPL;
2036 static struct ICOM_VTABLE(IDropTarget) dtvt =
2038 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2039 ISVDropTarget_QueryInterface,
2040 ISVDropTarget_AddRef,
2041 ISVDropTarget_Release,
2042 ISVDropTarget_DragEnter,
2043 ISVDropTarget_DragOver,
2044 ISVDropTarget_DragLeave,
2045 ISVDropTarget_Drop
2048 /**********************************************************
2049 * ISVDropSource implementation
2052 static HRESULT WINAPI ISVDropSource_QueryInterface(
2053 IDropSource *iface,
2054 REFIID riid,
2055 LPVOID *ppvObj)
2057 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2059 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2061 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2064 static ULONG WINAPI ISVDropSource_AddRef( IDropSource *iface)
2066 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2068 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2070 return IShellFolder_AddRef((IShellFolder*)This);
2073 static ULONG WINAPI ISVDropSource_Release( IDropSource *iface)
2075 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2077 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2079 return IShellFolder_Release((IShellFolder*)This);
2081 static HRESULT WINAPI ISVDropSource_QueryContinueDrag(
2082 IDropSource *iface,
2083 BOOL fEscapePressed,
2084 DWORD grfKeyState)
2086 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2087 TRACE("(%p)\n",This);
2089 if (fEscapePressed)
2090 return DRAGDROP_S_CANCEL;
2091 else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
2092 return DRAGDROP_S_DROP;
2093 else
2094 return NOERROR;
2097 static HRESULT WINAPI ISVDropSource_GiveFeedback(
2098 IDropSource *iface,
2099 DWORD dwEffect)
2101 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2102 TRACE("(%p)\n",This);
2104 return DRAGDROP_S_USEDEFAULTCURSORS;
2107 static struct ICOM_VTABLE(IDropSource) dsvt =
2109 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2110 ISVDropSource_QueryInterface,
2111 ISVDropSource_AddRef,
2112 ISVDropSource_Release,
2113 ISVDropSource_QueryContinueDrag,
2114 ISVDropSource_GiveFeedback
2116 /**********************************************************
2117 * ISVViewObject implementation
2120 static HRESULT WINAPI ISVViewObject_QueryInterface(
2121 IViewObject *iface,
2122 REFIID riid,
2123 LPVOID *ppvObj)
2125 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2127 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2129 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2132 static ULONG WINAPI ISVViewObject_AddRef( IViewObject *iface)
2134 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2136 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2138 return IShellFolder_AddRef((IShellFolder*)This);
2141 static ULONG WINAPI ISVViewObject_Release( IViewObject *iface)
2143 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2145 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2147 return IShellFolder_Release((IShellFolder*)This);
2150 static HRESULT WINAPI ISVViewObject_Draw(
2151 IViewObject *iface,
2152 DWORD dwDrawAspect,
2153 LONG lindex,
2154 void* pvAspect,
2155 DVTARGETDEVICE* ptd,
2156 HDC hdcTargetDev,
2157 HDC hdcDraw,
2158 LPCRECTL lprcBounds,
2159 LPCRECTL lprcWBounds,
2160 IVO_ContCallback pfnContinue,
2161 DWORD dwContinue)
2164 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2166 FIXME("Stub: This=%p\n",This);
2168 return E_NOTIMPL;
2170 static HRESULT WINAPI ISVViewObject_GetColorSet(
2171 IViewObject *iface,
2172 DWORD dwDrawAspect,
2173 LONG lindex,
2174 void *pvAspect,
2175 DVTARGETDEVICE* ptd,
2176 HDC hicTargetDevice,
2177 LOGPALETTE** ppColorSet)
2180 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2182 FIXME("Stub: This=%p\n",This);
2184 return E_NOTIMPL;
2186 static HRESULT WINAPI ISVViewObject_Freeze(
2187 IViewObject *iface,
2188 DWORD dwDrawAspect,
2189 LONG lindex,
2190 void* pvAspect,
2191 DWORD* pdwFreeze)
2194 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2196 FIXME("Stub: This=%p\n",This);
2198 return E_NOTIMPL;
2200 static HRESULT WINAPI ISVViewObject_Unfreeze(
2201 IViewObject *iface,
2202 DWORD dwFreeze)
2205 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2207 FIXME("Stub: This=%p\n",This);
2209 return E_NOTIMPL;
2211 static HRESULT WINAPI ISVViewObject_SetAdvise(
2212 IViewObject *iface,
2213 DWORD aspects,
2214 DWORD advf,
2215 IAdviseSink* pAdvSink)
2218 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2220 FIXME("Stub: This=%p\n",This);
2222 return E_NOTIMPL;
2224 static HRESULT WINAPI ISVViewObject_GetAdvise(
2225 IViewObject *iface,
2226 DWORD* pAspects,
2227 DWORD* pAdvf,
2228 IAdviseSink** ppAdvSink)
2231 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2233 FIXME("Stub: This=%p\n",This);
2235 return E_NOTIMPL;
2239 static struct ICOM_VTABLE(IViewObject) vovt =
2241 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2242 ISVViewObject_QueryInterface,
2243 ISVViewObject_AddRef,
2244 ISVViewObject_Release,
2245 ISVViewObject_Draw,
2246 ISVViewObject_GetColorSet,
2247 ISVViewObject_Freeze,
2248 ISVViewObject_Unfreeze,
2249 ISVViewObject_SetAdvise,
2250 ISVViewObject_GetAdvise