Handle ascii & unicode drag and drop structures in DragQueryFileA &
[wine/dcerpc.git] / dlls / shell32 / shlview.c
blobbd9085d60bd7bc00ca7a17633ab94b08f2dbe31b
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.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * FIXME: The order by part of the background context menu should be
24 * buily according to the columns shown.
26 * FIXME: Load/Save the view state from/into the stream provied by
27 * the ShellBrowser
29 * FIXME: CheckToolbar: handle the "new folder" and "folder up" button
31 * FIXME: ShellView_FillList: consider sort orders
33 * FIXME: implement the drag and drop in the old (msg-based) way
35 * FIXME: when the ShellView_WndProc gets a WM_NCDESTROY should we do a
36 * Release() ???
39 #include <stdlib.h>
40 #include <string.h>
42 #include "windef.h"
43 #include "winerror.h"
44 #include "winnls.h"
45 #include "servprov.h"
46 #include "shlguid.h"
47 #include "shlobj.h"
48 #include "undocshell.h"
49 #include "shresdef.h"
50 #include "wine/debug.h"
52 #include "docobj.h"
53 #include "pidl.h"
54 #include "shell32_main.h"
55 #include "shellfolder.h"
57 WINE_DEFAULT_DEBUG_CHANNEL(shell);
59 typedef struct
60 { BOOL bIsAscending;
61 INT nHeaderID;
62 INT nLastHeaderID;
63 }LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO;
65 typedef struct
66 { ICOM_VFIELD(IShellView);
67 DWORD ref;
68 ICOM_VTABLE(IOleCommandTarget)* lpvtblOleCommandTarget;
69 ICOM_VTABLE(IDropTarget)* lpvtblDropTarget;
70 ICOM_VTABLE(IDropSource)* lpvtblDropSource;
71 ICOM_VTABLE(IViewObject)* lpvtblViewObject;
72 IShellFolder* pSFParent;
73 IShellFolder2* pSF2Parent;
74 IShellBrowser* pShellBrowser;
75 ICommDlgBrowser* pCommDlgBrowser;
76 HWND hWnd; /* SHELLDLL_DefView */
77 HWND hWndList; /* ListView control */
78 HWND hWndParent;
79 FOLDERSETTINGS FolderSettings;
80 HMENU hMenu;
81 UINT uState;
82 UINT cidl;
83 LPITEMIDLIST *apidl;
84 LISTVIEW_SORT_INFO ListViewSortInfo;
85 HANDLE hNotify; /* change notification handle */
86 HANDLE hAccel;
87 } IShellViewImpl;
89 static struct ICOM_VTABLE(IShellView) svvt;
91 static struct ICOM_VTABLE(IOleCommandTarget) ctvt;
92 #define _IOleCommandTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblOleCommandTarget)))
93 #define _ICOM_THIS_From_IOleCommandTarget(class, name) class* This = (class*)(((char*)name)-_IOleCommandTarget_Offset);
95 static struct ICOM_VTABLE(IDropTarget) dtvt;
96 #define _IDropTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropTarget)))
97 #define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
99 static struct ICOM_VTABLE(IDropSource) dsvt;
100 #define _IDropSource_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropSource)))
101 #define _ICOM_THIS_From_IDropSource(class, name) class* This = (class*)(((char*)name)-_IDropSource_Offset);
103 static struct ICOM_VTABLE(IViewObject) vovt;
104 #define _IViewObject_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblViewObject)))
105 #define _ICOM_THIS_From_IViewObject(class, name) class* This = (class*)(((char*)name)-_IViewObject_Offset);
107 /* ListView Header ID's */
108 #define LISTVIEW_COLUMN_NAME 0
109 #define LISTVIEW_COLUMN_SIZE 1
110 #define LISTVIEW_COLUMN_TYPE 2
111 #define LISTVIEW_COLUMN_TIME 3
112 #define LISTVIEW_COLUMN_ATTRIB 4
114 /*menu items */
115 #define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500)
116 #define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501)
117 #define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502)
119 #define ID_LISTVIEW 2000
121 #define SHV_CHANGE_NOTIFY WM_USER + 0x1111
123 /*windowsx.h */
124 #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
125 #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
126 #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
128 extern void WINAPI _InsertMenuItem (HMENU hmenu, UINT indexMenu, BOOL fByPosition,
129 UINT wID, UINT fType, LPSTR dwTypeData, UINT fState);
132 Items merged into the toolbar and and the filemenu
134 typedef struct
135 { int idCommand;
136 int iImage;
137 int idButtonString;
138 int idMenuString;
139 BYTE bState;
140 BYTE bStyle;
141 } MYTOOLINFO, *LPMYTOOLINFO;
143 MYTOOLINFO Tools[] =
145 { FCIDM_SHVIEW_BIGICON, 0, 0, IDS_VIEW_LARGE, TBSTATE_ENABLED, TBSTYLE_BUTTON },
146 { FCIDM_SHVIEW_SMALLICON, 0, 0, IDS_VIEW_SMALL, TBSTATE_ENABLED, TBSTYLE_BUTTON },
147 { FCIDM_SHVIEW_LISTVIEW, 0, 0, IDS_VIEW_LIST, TBSTATE_ENABLED, TBSTYLE_BUTTON },
148 { FCIDM_SHVIEW_REPORTVIEW, 0, 0, IDS_VIEW_DETAILS, TBSTATE_ENABLED, TBSTYLE_BUTTON },
149 { -1, 0, 0, 0, 0, 0}
152 typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
154 /**********************************************************
155 * IShellView_Constructor
157 IShellView * IShellView_Constructor( IShellFolder * pFolder)
158 { IShellViewImpl * sv;
159 sv=(IShellViewImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl));
160 sv->ref=1;
161 ICOM_VTBL(sv)=&svvt;
162 sv->lpvtblOleCommandTarget=&ctvt;
163 sv->lpvtblDropTarget=&dtvt;
164 sv->lpvtblDropSource=&dsvt;
165 sv->lpvtblViewObject=&vovt;
167 sv->pSFParent = pFolder;
168 if(pFolder) IShellFolder_AddRef(pFolder);
169 IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (LPVOID*)&sv->pSF2Parent);
171 TRACE("(%p)->(%p)\n",sv, pFolder);
172 shell32_ObjCount++;
173 return (IShellView *) sv;
176 /**********************************************************
178 * ##### helperfunctions for communication with ICommDlgBrowser #####
180 static BOOL IsInCommDlg(IShellViewImpl * This)
181 { return(This->pCommDlgBrowser != NULL);
184 static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl)
186 HRESULT ret = S_OK;
188 if ( IsInCommDlg(This) )
190 TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
191 ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView*)This, pidl);
192 TRACE("--0x%08lx\n", ret);
194 return ret;
197 static HRESULT OnDefaultCommand(IShellViewImpl * This)
199 HRESULT ret = S_FALSE;
201 if (IsInCommDlg(This))
203 TRACE("ICommDlgBrowser::OnDefaultCommand\n");
204 ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView*)This);
205 TRACE("--\n");
207 return ret;
210 static HRESULT OnStateChange(IShellViewImpl * This, UINT uFlags)
212 HRESULT ret = S_FALSE;
214 if (IsInCommDlg(This))
216 TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags);
217 ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView*)This, uFlags);
218 TRACE("--\n");
220 return ret;
222 /**********************************************************
223 * set the toolbar of the filedialog buttons
225 * - activates the buttons from the shellbrowser according to
226 * the view state
228 static void CheckToolbar(IShellViewImpl * This)
230 LRESULT result;
232 TRACE("\n");
234 if (IsInCommDlg(This))
236 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
237 FCIDM_TB_SMALLICON, (This->FolderSettings.ViewMode==FVM_LIST)? TRUE : FALSE, &result);
238 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
239 FCIDM_TB_REPORTVIEW, (This->FolderSettings.ViewMode==FVM_DETAILS)? TRUE : FALSE, &result);
240 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
241 FCIDM_TB_SMALLICON, TRUE, &result);
242 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
243 FCIDM_TB_REPORTVIEW, TRUE, &result);
247 /**********************************************************
249 * ##### helperfunctions for initializing the view #####
251 /**********************************************************
252 * change the style of the listview control
254 static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove)
256 DWORD tmpstyle;
258 TRACE("(%p)\n", This);
260 tmpstyle = GetWindowLongA(This->hWndList, GWL_STYLE);
261 SetWindowLongA(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove));
264 /**********************************************************
265 * ShellView_CreateList()
267 * - creates the list view window
269 static BOOL ShellView_CreateList (IShellViewImpl * This)
270 { DWORD dwStyle;
272 TRACE("%p\n",This);
274 dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
275 LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_AUTOARRANGE;
277 switch (This->FolderSettings.ViewMode)
279 case FVM_ICON: dwStyle |= LVS_ICON; break;
280 case FVM_DETAILS: dwStyle |= LVS_REPORT; break;
281 case FVM_SMALLICON: dwStyle |= LVS_SMALLICON; break;
282 case FVM_LIST: dwStyle |= LVS_LIST; break;
283 default: dwStyle |= LVS_LIST; break;
286 if (This->FolderSettings.fFlags & FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE;
287 /*if (This->FolderSettings.fFlags && FWF_DESKTOP); used from explorer*/
288 if (This->FolderSettings.fFlags & FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL;
290 This->hWndList=CreateWindowExA( WS_EX_CLIENTEDGE,
291 WC_LISTVIEWA,
292 NULL,
293 dwStyle,
294 0,0,0,0,
295 This->hWnd,
296 (HMENU)ID_LISTVIEW,
297 shell32_hInstance,
298 NULL);
300 if(!This->hWndList)
301 return FALSE;
303 This->ListViewSortInfo.bIsAscending = TRUE;
304 This->ListViewSortInfo.nHeaderID = -1;
305 This->ListViewSortInfo.nLastHeaderID = -1;
307 /* UpdateShellSettings(); */
308 return TRUE;
311 /**********************************************************
312 * ShellView_InitList()
314 * - adds all needed columns to the shellview
316 static BOOL ShellView_InitList(IShellViewImpl * This)
318 LVCOLUMNA lvColumn;
319 SHELLDETAILS sd;
320 int i;
321 char szTemp[50];
323 TRACE("%p\n",This);
325 ListView_DeleteAllItems(This->hWndList);
327 lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
328 lvColumn.pszText = szTemp;
330 if (This->pSF2Parent)
332 for (i=0; 1; i++)
334 if (!SUCCEEDED(IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, i, &sd)))
335 break;
336 lvColumn.fmt = sd.fmt;
337 lvColumn.cx = sd.cxChar*8; /* chars->pixel */
338 StrRetToStrNA( szTemp, 50, &sd.str, NULL);
339 ListView_InsertColumnA(This->hWndList, i, &lvColumn);
342 else
344 FIXME("no SF2\n");
347 ListView_SetImageList(This->hWndList, ShellSmallIconList, LVSIL_SMALL);
348 ListView_SetImageList(This->hWndList, ShellBigIconList, LVSIL_NORMAL);
350 return TRUE;
352 /**********************************************************
353 * ShellView_CompareItems()
355 * NOTES
356 * internal, CALLBACK for DSA_Sort
358 static INT CALLBACK ShellView_CompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
360 int ret;
361 TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1, lParam2, (LPVOID) lpData);
363 if(!lpData) return 0;
365 ret = (SHORT) SCODE_CODE(IShellFolder_CompareIDs((LPSHELLFOLDER)lpData, 0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2));
366 TRACE("ret=%i\n",ret);
367 return ret;
370 /*************************************************************************
371 * ShellView_ListViewCompareItems
373 * Compare Function for the Listview (FileOpen Dialog)
375 * PARAMS
376 * lParam1 [I] the first ItemIdList to compare with
377 * lParam2 [I] the second ItemIdList to compare with
378 * lpData [I] The column ID for the header Ctrl to process
380 * RETURNS
381 * A negative value if the first item should precede the second,
382 * a positive value if the first item should follow the second,
383 * or zero if the two items are equivalent
385 * NOTES
386 * FIXME: function does what ShellView_CompareItems is supposed to do.
387 * unify it and figure out how to use the undocumented first parameter
388 * of IShellFolder_CompareIDs to do the job this function does and
389 * move this code to IShellFolder.
390 * make LISTVIEW_SORT_INFO obsolete
391 * the way this function works is only usable if we had only
392 * filesystemfolders (25/10/99 jsch)
394 static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
396 INT nDiff=0;
397 FILETIME fd1, fd2;
398 char strName1[MAX_PATH], strName2[MAX_PATH];
399 BOOL bIsFolder1, bIsFolder2,bIsBothFolder;
400 LPITEMIDLIST pItemIdList1 = (LPITEMIDLIST) lParam1;
401 LPITEMIDLIST pItemIdList2 = (LPITEMIDLIST) lParam2;
402 LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData;
405 bIsFolder1 = _ILIsFolder(pItemIdList1);
406 bIsFolder2 = _ILIsFolder(pItemIdList2);
407 bIsBothFolder = bIsFolder1 && bIsFolder2;
409 /* When sorting between a File and a Folder, the Folder gets sorted first */
410 if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder)
412 nDiff = bIsFolder1 ? -1 : 1;
414 else
416 /* Sort by Time: Folders or Files can be sorted */
418 if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)
420 _ILGetFileDateTime(pItemIdList1, &fd1);
421 _ILGetFileDateTime(pItemIdList2, &fd2);
422 nDiff = CompareFileTime(&fd2, &fd1);
424 /* Sort by Attribute: Folder or Files can be sorted */
425 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB)
427 _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH);
428 _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH);
429 nDiff = strcasecmp(strName1, strName2);
431 /* Sort by FileName: Folder or Files can be sorted */
432 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder)
434 /* Sort by Text */
435 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
436 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
437 nDiff = strcasecmp(strName1, strName2);
439 /* Sort by File Size, Only valid for Files */
440 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)
442 nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0));
444 /* Sort by File Type, Only valid for Files */
445 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)
447 /* Sort by Type */
448 _ILGetFileType(pItemIdList1, strName1, MAX_PATH);
449 _ILGetFileType(pItemIdList2, strName2, MAX_PATH);
450 nDiff = strcasecmp(strName1, strName2);
453 /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
455 if(nDiff == 0)
457 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
458 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
459 nDiff = strcasecmp(strName1, strName2);
462 if(!pSortInfo->bIsAscending)
464 nDiff = -nDiff;
467 return nDiff;
471 /**********************************************************
472 * LV_FindItemByPidl()
474 static int LV_FindItemByPidl(
475 IShellViewImpl * This,
476 LPCITEMIDLIST pidl)
478 LVITEMA lvItem;
479 ZeroMemory(&lvItem, sizeof(LVITEMA));
480 lvItem.mask = LVIF_PARAM;
481 for(lvItem.iItem = 0; ListView_GetItemA(This->hWndList, &lvItem); lvItem.iItem++)
483 LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam;
484 HRESULT hr = IShellFolder_CompareIDs(This->pSFParent, 0, pidl, currentpidl);
485 if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
487 return lvItem.iItem;
490 return -1;
493 /**********************************************************
494 * LV_AddItem()
496 static BOOLEAN LV_AddItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
498 LVITEMA lvItem;
500 TRACE("(%p)(pidl=%p)\n", This, pidl);
502 ZeroMemory(&lvItem, sizeof(lvItem)); /* create the listview item*/
503 lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; /*set the mask*/
504 lvItem.iItem = ListView_GetItemCount(This->hWndList); /*add the item to the end of the list*/
505 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidl)); /*set the item's data*/
506 lvItem.pszText = LPSTR_TEXTCALLBACKA; /*get text on a callback basis*/
507 lvItem.iImage = I_IMAGECALLBACK; /*get the image on a callback basis*/
508 return (-1==ListView_InsertItemA(This->hWndList, &lvItem))? FALSE: TRUE;
511 /**********************************************************
512 * LV_DeleteItem()
514 static BOOLEAN LV_DeleteItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
516 int nIndex;
518 TRACE("(%p)(pidl=%p)\n", This, pidl);
520 nIndex = LV_FindItemByPidl(This, ILFindLastID(pidl));
521 return (-1==ListView_DeleteItem(This->hWndList, nIndex))? FALSE: TRUE;
524 /**********************************************************
525 * LV_RenameItem()
527 static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew )
529 int nItem;
530 LVITEMA lvItem;
532 TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew);
534 nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld));
535 if ( -1 != nItem )
537 ZeroMemory(&lvItem, sizeof(lvItem)); /* create the listview item*/
538 lvItem.mask = LVIF_PARAM; /* only the pidl */
539 lvItem.iItem = nItem;
540 ListView_GetItemA(This->hWndList, &lvItem);
542 SHFree((LPITEMIDLIST)lvItem.lParam);
543 lvItem.mask = LVIF_PARAM;
544 lvItem.iItem = nItem;
545 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew)); /* set the item's data */
546 ListView_SetItemA(This->hWndList, &lvItem);
547 ListView_Update(This->hWndList, nItem);
548 return TRUE; /* FIXME: better handling */
550 return FALSE;
552 /**********************************************************
553 * ShellView_FillList()
555 * - gets the objectlist from the shellfolder
556 * - sorts the list
557 * - fills the list into the view
560 static HRESULT ShellView_FillList(IShellViewImpl * This)
562 LPENUMIDLIST pEnumIDList;
563 LPITEMIDLIST pidl;
564 DWORD dwFetched;
565 UINT i;
566 HRESULT hRes;
567 HDPA hdpa;
569 TRACE("%p\n",This);
571 /* get the itemlist from the shfolder*/
572 hRes = IShellFolder_EnumObjects(This->pSFParent,This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList);
573 if (hRes != S_OK)
575 if (hRes==S_FALSE)
576 return(NOERROR);
577 return(hRes);
580 /* create a pointer array */
581 hdpa = pDPA_Create(16);
582 if (!hdpa)
584 return(E_OUTOFMEMORY);
587 /* copy the items into the array*/
588 while((S_OK == IEnumIDList_Next(pEnumIDList,1, &pidl, &dwFetched)) && dwFetched)
590 if (pDPA_InsertPtr(hdpa, 0x7fff, pidl) == -1)
592 SHFree(pidl);
596 /* sort the array */
597 pDPA_Sort(hdpa, ShellView_CompareItems, (LPARAM)This->pSFParent);
599 /*turn the listview's redrawing off*/
600 SendMessageA(This->hWndList, WM_SETREDRAW, FALSE, 0);
602 for (i=0; i < DPA_GetPtrCount(hdpa); ++i) /* DPA_GetPtrCount is a macro*/
604 pidl = (LPITEMIDLIST)pDPA_GetPtr(hdpa, i);
606 /* in a commdlg This works as a filemask*/
607 if ( IncludeObject(This, pidl)==S_OK )
608 LV_AddItem(This, pidl);
609 SHFree(pidl);
612 /*turn the listview's redrawing back on and force it to draw*/
613 SendMessageA(This->hWndList, WM_SETREDRAW, TRUE, 0);
615 IEnumIDList_Release(pEnumIDList); /* destroy the list*/
616 pDPA_Destroy(hdpa);
618 return S_OK;
621 /**********************************************************
622 * ShellView_OnCreate()
624 static LRESULT ShellView_OnCreate(IShellViewImpl * This)
626 IDropTarget* pdt;
627 NOTIFYREGISTER ntreg;
628 IPersistFolder2 * ppf2 = NULL;
630 TRACE("%p\n",This);
632 if(ShellView_CreateList(This))
634 if(ShellView_InitList(This))
636 ShellView_FillList(This);
640 if(GetShellOle())
642 if (SUCCEEDED(IShellFolder_CreateViewObject(This->pSFParent, This->hWnd, &IID_IDropTarget, (LPVOID*)&pdt)))
644 pRegisterDragDrop(This->hWnd, pdt);
645 IDropTarget_Release(pdt);
649 /* register for receiving notifications */
650 IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2);
651 if (ppf2)
653 IPersistFolder2_GetCurFolder(ppf2, &ntreg.pidlPath);
654 ntreg.bWatchSubtree = FALSE;
655 This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNF_IDLIST, SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg);
656 SHFree(ntreg.pidlPath);
657 IPersistFolder2_Release(ppf2);
660 This->hAccel = LoadAcceleratorsA(shell32_hInstance, "shv_accel");
662 return S_OK;
665 /**********************************************************
666 * #### Handling of the menus ####
669 /**********************************************************
670 * ShellView_BuildFileMenu()
672 static HMENU ShellView_BuildFileMenu(IShellViewImpl * This)
673 { CHAR szText[MAX_PATH];
674 MENUITEMINFOA mii;
675 int nTools,i;
676 HMENU hSubMenu;
678 TRACE("(%p)\n",This);
680 hSubMenu = CreatePopupMenu();
681 if(hSubMenu)
682 { /*get the number of items in our global array*/
683 for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){}
685 /*add the menu items*/
686 for(i = 0; i < nTools; i++)
688 LoadStringA(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH);
690 ZeroMemory(&mii, sizeof(mii));
691 mii.cbSize = sizeof(mii);
692 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
694 if(TBSTYLE_SEP != Tools[i].bStyle) /* no seperator*/
696 mii.fType = MFT_STRING;
697 mii.fState = MFS_ENABLED;
698 mii.dwTypeData = szText;
699 mii.wID = Tools[i].idCommand;
701 else
703 mii.fType = MFT_SEPARATOR;
705 /* tack This item onto the end of the menu */
706 InsertMenuItemA(hSubMenu, (UINT)-1, TRUE, &mii);
709 TRACE("-- return (menu=0x%x)\n",hSubMenu);
710 return hSubMenu;
712 /**********************************************************
713 * ShellView_MergeFileMenu()
715 static void ShellView_MergeFileMenu(IShellViewImpl * This, HMENU hSubMenu)
716 { TRACE("(%p)->(submenu=0x%08x) stub\n",This,hSubMenu);
718 if(hSubMenu)
719 { /*insert This item at the beginning of the menu */
720 _InsertMenuItem(hSubMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
721 _InsertMenuItem(hSubMenu, 0, TRUE, IDM_MYFILEITEM, MFT_STRING, "dummy45", MFS_ENABLED);
724 TRACE("--\n");
727 /**********************************************************
728 * ShellView_MergeViewMenu()
731 static void ShellView_MergeViewMenu(IShellViewImpl * This, HMENU hSubMenu)
732 { MENUITEMINFOA mii;
734 TRACE("(%p)->(submenu=0x%08x)\n",This,hSubMenu);
736 if(hSubMenu)
737 { /*add a separator at the correct position in the menu*/
738 _InsertMenuItem(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
740 ZeroMemory(&mii, sizeof(mii));
741 mii.cbSize = sizeof(mii);
742 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;
743 mii.fType = MFT_STRING;
744 mii.dwTypeData = "View";
745 mii.hSubMenu = LoadMenuA(shell32_hInstance, "MENU_001");
746 InsertMenuItemA(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
750 /**********************************************************
751 * ShellView_GetSelections()
753 * - fills the this->apidl list with the selected objects
755 * RETURNS
756 * number of selected items
758 static UINT ShellView_GetSelections(IShellViewImpl * This)
760 LVITEMA lvItem;
761 UINT i = 0;
763 if (This->apidl)
765 SHFree(This->apidl);
768 This->cidl = ListView_GetSelectedCount(This->hWndList);
769 This->apidl = (LPITEMIDLIST*)SHAlloc(This->cidl * sizeof(LPITEMIDLIST));
771 TRACE("selected=%i\n", This->cidl);
773 if(This->apidl)
775 TRACE("-- Items selected =%u\n", This->cidl);
777 ZeroMemory(&lvItem, sizeof(lvItem));
778 lvItem.mask = LVIF_STATE | LVIF_PARAM;
779 lvItem.stateMask = LVIS_SELECTED;
781 while(ListView_GetItemA(This->hWndList, &lvItem) && (i < This->cidl))
783 if(lvItem.state & LVIS_SELECTED)
785 This->apidl[i] = (LPITEMIDLIST)lvItem.lParam;
786 i++;
787 TRACE("-- selected Item found\n");
789 lvItem.iItem++;
792 return This->cidl;
795 /**********************************************************
796 * ShellView_DoContextMenu()
798 static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL bDefault)
799 { UINT uCommand;
800 DWORD wFlags;
801 HMENU hMenu;
802 BOOL fExplore = FALSE;
803 HWND hwndTree = 0;
804 LPCONTEXTMENU pContextMenu = NULL;
805 IContextMenu * pCM = NULL;
806 CMINVOKECOMMANDINFO cmi;
808 TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, bDefault);
810 /* look, what's selected and create a context menu object of it*/
811 if( ShellView_GetSelections(This) )
813 IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, This->apidl,
814 (REFIID)&IID_IContextMenu, NULL, (LPVOID *)&pContextMenu);
816 if(pContextMenu)
818 TRACE("-- pContextMenu\n");
819 hMenu = CreatePopupMenu();
821 if( hMenu )
823 /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
824 if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree)
826 TRACE("-- explore mode\n");
827 fExplore = TRUE;
830 /* build the flags depending on what we can do with the selected item */
831 wFlags = CMF_NORMAL | (This->cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0);
833 /* let the ContextMenu merge its items in */
834 if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags )))
836 if( bDefault )
838 TRACE("-- get menu default command\n");
839 uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS);
841 else
843 TRACE("-- track popup\n");
844 uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
847 if(uCommand > 0)
849 TRACE("-- uCommand=%u\n", uCommand);
850 if (IsInCommDlg(This) && ((uCommand==FCIDM_SHVIEW_EXPLORE) || (uCommand==FCIDM_SHVIEW_OPEN)))
852 TRACE("-- dlg: OnDefaultCommand\n");
853 OnDefaultCommand(This);
855 else
857 TRACE("-- explore -- invoke command\n");
858 ZeroMemory(&cmi, sizeof(cmi));
859 cmi.cbSize = sizeof(cmi);
860 cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */
861 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
862 IContextMenu_InvokeCommand(pContextMenu, &cmi);
865 DestroyMenu(hMenu);
868 if (pContextMenu)
869 IContextMenu_Release(pContextMenu);
872 else /* background context menu */
874 hMenu = CreatePopupMenu();
876 pCM = ISvBgCm_Constructor(This->pSFParent);
877 IContextMenu_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
879 uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
880 DestroyMenu(hMenu);
882 TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand);
884 ZeroMemory(&cmi, sizeof(cmi));
885 cmi.cbSize = sizeof(cmi);
886 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
887 cmi.hwnd = This->hWndParent;
888 IContextMenu_InvokeCommand(pCM, &cmi);
890 IContextMenu_Release(pCM);
894 /**********************************************************
895 * ##### message handling #####
898 /**********************************************************
899 * ShellView_OnSize()
901 static LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight)
903 TRACE("%p width=%u height=%u\n",This, wWidth,wHeight);
905 /*resize the ListView to fit our window*/
906 if(This->hWndList)
908 MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE);
911 return S_OK;
913 /**********************************************************
914 * ShellView_OnDeactivate()
916 * NOTES
917 * internal
919 static void ShellView_OnDeactivate(IShellViewImpl * This)
921 TRACE("%p\n",This);
923 if(This->uState != SVUIA_DEACTIVATE)
925 if(This->hMenu)
927 IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0);
928 IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu);
929 DestroyMenu(This->hMenu);
930 This->hMenu = 0;
933 This->uState = SVUIA_DEACTIVATE;
937 /**********************************************************
938 * ShellView_OnActivate()
940 static LRESULT ShellView_OnActivate(IShellViewImpl * This, UINT uState)
941 { OLEMENUGROUPWIDTHS omw = { {0, 0, 0, 0, 0, 0} };
942 MENUITEMINFOA mii;
943 CHAR szText[MAX_PATH];
945 TRACE("%p uState=%x\n",This,uState);
947 /*don't do anything if the state isn't really changing */
948 if(This->uState == uState)
950 return S_OK;
953 ShellView_OnDeactivate(This);
955 /*only do This if we are active */
956 if(uState != SVUIA_DEACTIVATE)
958 /*merge the menus */
959 This->hMenu = CreateMenu();
961 if(This->hMenu)
963 IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw);
964 TRACE("-- after fnInsertMenusSB\n");
966 /*build the top level menu get the menu item's text*/
967 strcpy(szText,"dummy 31");
969 ZeroMemory(&mii, sizeof(mii));
970 mii.cbSize = sizeof(mii);
971 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
972 mii.fType = MFT_STRING;
973 mii.fState = MFS_ENABLED;
974 mii.dwTypeData = szText;
975 mii.hSubMenu = ShellView_BuildFileMenu(This);
977 /*insert our menu into the menu bar*/
978 if(mii.hSubMenu)
980 InsertMenuItemA(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii);
983 /*get the view menu so we can merge with it*/
984 ZeroMemory(&mii, sizeof(mii));
985 mii.cbSize = sizeof(mii);
986 mii.fMask = MIIM_SUBMENU;
988 if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii))
990 ShellView_MergeViewMenu(This, mii.hSubMenu);
993 /*add the items that should only be added if we have the focus*/
994 if(SVUIA_ACTIVATE_FOCUS == uState)
996 /*get the file menu so we can merge with it */
997 ZeroMemory(&mii, sizeof(mii));
998 mii.cbSize = sizeof(mii);
999 mii.fMask = MIIM_SUBMENU;
1001 if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii))
1003 ShellView_MergeFileMenu(This, mii.hSubMenu);
1006 TRACE("-- before fnSetMenuSB\n");
1007 IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd);
1010 This->uState = uState;
1011 TRACE("--\n");
1012 return S_OK;
1015 /**********************************************************
1016 * ShellView_OnSetFocus()
1019 static LRESULT ShellView_OnSetFocus(IShellViewImpl * This)
1021 TRACE("%p\n",This);
1023 /* Tell the browser one of our windows has received the focus. This
1024 should always be done before merging menus (OnActivate merges the
1025 menus) if one of our windows has the focus.*/
1027 IShellBrowser_OnViewWindowActive(This->pShellBrowser,(IShellView*) This);
1028 ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS);
1030 /* Set the focus to the listview */
1031 SetFocus(This->hWndList);
1033 /* Notify the ICommDlgBrowser interface */
1034 OnStateChange(This,CDBOSC_SETFOCUS);
1036 return 0;
1039 /**********************************************************
1040 * ShellView_OnKillFocus()
1042 static LRESULT ShellView_OnKillFocus(IShellViewImpl * This)
1044 TRACE("(%p) stub\n",This);
1046 ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS);
1047 /* Notify the ICommDlgBrowser */
1048 OnStateChange(This,CDBOSC_KILLFOCUS);
1050 return 0;
1053 /**********************************************************
1054 * ShellView_OnCommand()
1056 * NOTES
1057 * the CmdID's are the ones from the context menu
1059 static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd)
1061 TRACE("(%p)->(0x%08lx 0x%08lx 0x%08x) stub\n",This, dwCmdID, dwCmd, hwndCmd);
1063 switch(dwCmdID)
1065 case FCIDM_SHVIEW_SMALLICON:
1066 This->FolderSettings.ViewMode = FVM_SMALLICON;
1067 SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK);
1068 CheckToolbar(This);
1069 break;
1071 case FCIDM_SHVIEW_BIGICON:
1072 This->FolderSettings.ViewMode = FVM_ICON;
1073 SetStyle (This, LVS_ICON, LVS_TYPEMASK);
1074 CheckToolbar(This);
1075 break;
1077 case FCIDM_SHVIEW_LISTVIEW:
1078 This->FolderSettings.ViewMode = FVM_LIST;
1079 SetStyle (This, LVS_LIST, LVS_TYPEMASK);
1080 CheckToolbar(This);
1081 break;
1083 case FCIDM_SHVIEW_REPORTVIEW:
1084 This->FolderSettings.ViewMode = FVM_DETAILS;
1085 SetStyle (This, LVS_REPORT, LVS_TYPEMASK);
1086 CheckToolbar(This);
1087 break;
1089 /* the menu-ID's for sorting are 0x30... see shrec.rc */
1090 case 0x30:
1091 case 0x31:
1092 case 0x32:
1093 case 0x33:
1094 This->ListViewSortInfo.nHeaderID = (LPARAM) (dwCmdID - 0x30);
1095 This->ListViewSortInfo.bIsAscending = TRUE;
1096 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1097 ListView_SortItems(This->hWndList, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1098 break;
1100 default:
1101 TRACE("-- COMMAND 0x%04lx unhandled\n", dwCmdID);
1103 return 0;
1106 /**********************************************************
1107 * ShellView_OnNotify()
1110 static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
1111 { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
1112 NMLVDISPINFOA *lpdi = (NMLVDISPINFOA *)lpnmh;
1113 LPITEMIDLIST pidl;
1115 TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code);
1117 switch(lpnmh->code)
1119 case NM_SETFOCUS:
1120 TRACE("-- NM_SETFOCUS %p\n",This);
1121 ShellView_OnSetFocus(This);
1122 break;
1124 case NM_KILLFOCUS:
1125 TRACE("-- NM_KILLFOCUS %p\n",This);
1126 ShellView_OnDeactivate(This);
1127 /* Notify the ICommDlgBrowser interface */
1128 OnStateChange(This,CDBOSC_KILLFOCUS);
1129 break;
1131 case HDN_ENDTRACKA:
1132 TRACE("-- HDN_ENDTRACKA %p\n",This);
1133 /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
1134 nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
1135 break;
1137 case LVN_DELETEITEM:
1138 TRACE("-- LVN_DELETEITEM %p\n",This);
1139 SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/
1140 break;
1142 case LVN_ITEMACTIVATE:
1143 TRACE("-- LVN_ITEMACTIVATE %p\n",This);
1144 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1145 ShellView_DoContextMenu(This, 0, 0, TRUE);
1146 break;
1148 case LVN_COLUMNCLICK:
1149 This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem;
1150 if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID)
1152 This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending;
1154 else
1156 This->ListViewSortInfo.bIsAscending = TRUE;
1158 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1160 ListView_SortItems(lpnmlv->hdr.hwndFrom, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1161 break;
1163 case LVN_GETDISPINFOA:
1164 case LVN_GETDISPINFOW:
1165 TRACE("-- LVN_GETDISPINFO %p\n",This);
1166 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1168 if(lpdi->item.mask & LVIF_TEXT) /* text requested */
1170 if (This->pSF2Parent)
1172 SHELLDETAILS sd;
1173 IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
1174 if (lpnmh->code == LVN_GETDISPINFOA)
1176 StrRetToStrNA( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1177 TRACE("-- text=%s\n",lpdi->item.pszText);
1179 else /* LVN_GETDISPINFOW */
1181 StrRetToStrNW( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1182 TRACE("-- text=%s\n",debugstr_w((WCHAR*)(lpdi->item.pszText)));
1185 else
1187 FIXME("no SF2\n");
1190 if(lpdi->item.mask & LVIF_IMAGE) /* image requested */
1192 lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
1194 break;
1196 case LVN_ITEMCHANGED:
1197 TRACE("-- LVN_ITEMCHANGED %p\n",This);
1198 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1199 break;
1201 case LVN_BEGINDRAG:
1202 case LVN_BEGINRDRAG:
1203 TRACE("-- LVN_BEGINDRAG\n");
1205 if (ShellView_GetSelections(This))
1207 IDataObject * pda;
1208 DWORD dwAttributes = SFGAO_CANLINK;
1209 DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
1211 if(GetShellOle())
1213 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
1215 IDropSource * pds = (IDropSource*)&(This->lpvtblDropSource); /* own DropSource interface */
1217 if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, This->apidl, &dwAttributes)))
1219 if (dwAttributes & SFGAO_CANLINK)
1221 dwEffect |= DROPEFFECT_LINK;
1225 if (pds)
1227 DWORD dwEffect;
1228 pDoDragDrop(pda, pds, dwEffect, &dwEffect);
1230 IDataObject_Release(pda);
1234 break;
1236 case LVN_BEGINLABELEDITA:
1238 DWORD dwAttr = SFGAO_CANRENAME;
1239 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1241 TRACE("-- LVN_BEGINLABELEDITA %p\n",This);
1243 IShellFolder_GetAttributesOf(This->pSFParent, 1, &pidl, &dwAttr);
1244 if (SFGAO_CANRENAME & dwAttr)
1246 return FALSE;
1248 return TRUE;
1250 break;
1252 case LVN_ENDLABELEDITA:
1254 TRACE("-- LVN_ENDLABELEDITA %p\n",This);
1255 if (lpdi->item.pszText)
1257 HRESULT hr;
1258 WCHAR wszNewName[MAX_PATH];
1259 LVITEMA lvItem;
1261 ZeroMemory(&lvItem, sizeof(LVITEMA));
1262 lvItem.iItem = lpdi->item.iItem;
1263 lvItem.mask = LVIF_PARAM;
1264 ListView_GetItemA(This->hWndList, &lvItem);
1266 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1267 if (!MultiByteToWideChar( CP_ACP, 0, lpdi->item.pszText, -1, wszNewName, MAX_PATH ))
1268 wszNewName[MAX_PATH-1] = 0;
1269 hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, wszNewName, SHGDN_INFOLDER, &pidl);
1271 if(SUCCEEDED(hr) && pidl)
1273 lvItem.mask = LVIF_PARAM;
1274 lvItem.lParam = (LPARAM)pidl;
1275 ListView_SetItemA(This->hWndList, &lvItem);
1276 return TRUE;
1279 return FALSE;
1281 break;
1283 case LVN_KEYDOWN:
1285 /* MSG msg;
1286 msg.hwnd = This->hWnd;
1287 msg.message = WM_KEYDOWN;
1288 msg.wParam = plvKeyDown->wVKey;
1289 msg.lParam = 0;
1290 msg.time = 0;
1291 msg.pt = 0;*/
1293 LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
1295 /* initiate a rename of the selected file or directory */
1296 if(plvKeyDown->wVKey == VK_F2)
1298 /* see how many files are selected */
1299 int i = ListView_GetSelectedCount(This->hWndList);
1301 /* get selected item */
1302 if(i == 1)
1304 /* get selected item */
1305 i = ListView_GetNextItem(This->hWndList, -1,
1306 LVNI_SELECTED);
1308 ListView_EnsureVisible(This->hWndList, i, 0);
1309 ListView_EditLabelA(This->hWndList, i);
1312 #if 0
1313 TranslateAccelerator(This->hWnd, This->hAccel, &msg)
1314 #endif
1315 else if(plvKeyDown->wVKey == VK_DELETE)
1317 int i, item_index;
1318 LVITEMA item;
1319 LPITEMIDLIST* pItems;
1320 ISFHelper *psfhlp;
1322 IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper,
1323 (LPVOID*)&psfhlp);
1325 if(!(i = ListView_GetSelectedCount(This->hWndList)))
1326 break;
1328 /* allocate memory for the pidl array */
1329 pItems = HeapAlloc(GetProcessHeap(), 0,
1330 sizeof(LPITEMIDLIST) * i);
1332 /* retrieve all selected items */
1333 i = 0;
1334 item_index = -1;
1335 while(ListView_GetSelectedCount(This->hWndList) > i)
1337 /* get selected item */
1338 item_index = ListView_GetNextItem(This->hWndList,
1339 item_index, LVNI_SELECTED);
1340 item.iItem = item_index;
1341 ListView_GetItemA(This->hWndList, &item);
1343 /* get item pidl */
1344 pItems[i] = (LPITEMIDLIST)item.lParam;
1346 i++;
1349 /* perform the item deletion */
1350 ISFHelper_DeleteItems(psfhlp, i, pItems);
1352 /* free pidl array memory */
1353 HeapFree(GetProcessHeap(), 0, pItems);
1355 else
1356 FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey);
1358 break;
1360 default:
1361 TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code);
1362 break;
1364 return 0;
1367 /**********************************************************
1368 * ShellView_OnChange()
1371 static LRESULT ShellView_OnChange(IShellViewImpl * This, LPITEMIDLIST * Pidls, LONG wEventId)
1374 TRACE("(%p)(%p,%p,0x%08lx)\n", This, Pidls[0], Pidls[1], wEventId);
1375 switch(wEventId)
1377 case SHCNE_MKDIR:
1378 case SHCNE_CREATE:
1379 LV_AddItem(This, Pidls[0]);
1380 break;
1381 case SHCNE_RMDIR:
1382 case SHCNE_DELETE:
1383 LV_DeleteItem(This, Pidls[0]);
1384 break;
1385 case SHCNE_RENAMEFOLDER:
1386 case SHCNE_RENAMEITEM:
1387 LV_RenameItem(This, Pidls[0], Pidls[1]);
1388 break;
1389 case SHCNE_UPDATEITEM:
1390 break;
1392 return TRUE;
1394 /**********************************************************
1395 * ShellView_WndProc
1398 static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1400 IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongA(hWnd, GWL_USERDATA);
1401 LPCREATESTRUCTA lpcs;
1403 TRACE("(hwnd=%x msg=%x wparm=%x lparm=%lx)\n",hWnd, uMessage, wParam, lParam);
1405 switch (uMessage)
1407 case WM_NCCREATE:
1408 lpcs = (LPCREATESTRUCTA)lParam;
1409 pThis = (IShellViewImpl*)(lpcs->lpCreateParams);
1410 SetWindowLongA(hWnd, GWL_USERDATA, (LONG)pThis);
1411 pThis->hWnd = hWnd; /*set the window handle*/
1412 break;
1414 case WM_SIZE: return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam));
1415 case WM_SETFOCUS: return ShellView_OnSetFocus(pThis);
1416 case WM_KILLFOCUS: return ShellView_OnKillFocus(pThis);
1417 case WM_CREATE: return ShellView_OnCreate(pThis);
1418 case WM_ACTIVATE: return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS);
1419 case WM_NOTIFY: return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam);
1420 case WM_COMMAND: return ShellView_OnCommand(pThis,
1421 GET_WM_COMMAND_ID(wParam, lParam),
1422 GET_WM_COMMAND_CMD(wParam, lParam),
1423 GET_WM_COMMAND_HWND(wParam, lParam));
1424 case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (LPITEMIDLIST*)wParam, (LONG)lParam);
1426 case WM_CONTEXTMENU: ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE);
1427 return 0;
1429 case WM_SHOWWINDOW: UpdateWindow(pThis->hWndList);
1430 break;
1432 case WM_GETDLGCODE: return SendMessageA(pThis->hWndList,uMessage,0,0);
1434 case WM_DESTROY: if(GetShellOle())
1436 pRevokeDragDrop(pThis->hWnd);
1438 SHChangeNotifyDeregister(pThis->hNotify);
1439 break;
1442 return DefWindowProcA (hWnd, uMessage, wParam, lParam);
1444 /**********************************************************
1447 * The INTERFACE of the IShellView object
1450 **********************************************************
1451 * IShellView_QueryInterface
1453 static HRESULT WINAPI IShellView_fnQueryInterface(IShellView * iface,REFIID riid, LPVOID *ppvObj)
1455 ICOM_THIS(IShellViewImpl, iface);
1457 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1459 *ppvObj = NULL;
1461 if(IsEqualIID(riid, &IID_IUnknown))
1463 *ppvObj = This;
1465 else if(IsEqualIID(riid, &IID_IShellView))
1467 *ppvObj = (IShellView*)This;
1469 else if(IsEqualIID(riid, &IID_IOleCommandTarget))
1471 *ppvObj = (IOleCommandTarget*)&(This->lpvtblOleCommandTarget);
1473 else if(IsEqualIID(riid, &IID_IDropTarget))
1475 *ppvObj = (IDropTarget*)&(This->lpvtblDropTarget);
1477 else if(IsEqualIID(riid, &IID_IDropSource))
1479 *ppvObj = (IDropSource*)&(This->lpvtblDropSource);
1481 else if(IsEqualIID(riid, &IID_IViewObject))
1483 *ppvObj = (IViewObject*)&(This->lpvtblViewObject);
1486 if(*ppvObj)
1488 IUnknown_AddRef( (IUnknown*)*ppvObj );
1489 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1490 return S_OK;
1492 TRACE("-- Interface: E_NOINTERFACE\n");
1493 return E_NOINTERFACE;
1496 /**********************************************************
1497 * IShellView_AddRef
1499 static ULONG WINAPI IShellView_fnAddRef(IShellView * iface)
1501 ICOM_THIS(IShellViewImpl, iface);
1503 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1505 shell32_ObjCount++;
1506 return ++(This->ref);
1508 /**********************************************************
1509 * IShellView_Release
1511 static ULONG WINAPI IShellView_fnRelease(IShellView * iface)
1513 ICOM_THIS(IShellViewImpl, iface);
1515 TRACE("(%p)->()\n",This);
1517 shell32_ObjCount--;
1519 if (!--(This->ref))
1521 TRACE(" destroying IShellView(%p)\n",This);
1523 if(This->pSFParent)
1524 IShellFolder_Release(This->pSFParent);
1526 if(This->pSF2Parent)
1527 IShellFolder2_Release(This->pSF2Parent);
1529 if (This->apidl)
1530 SHFree(This->apidl);
1532 if (This->pCommDlgBrowser)
1533 ICommDlgBrowser_Release(This->pCommDlgBrowser);
1535 HeapFree(GetProcessHeap(),0,This);
1536 return 0;
1538 return This->ref;
1541 /**********************************************************
1542 * ShellView_GetWindow
1544 static HRESULT WINAPI IShellView_fnGetWindow(IShellView * iface,HWND * phWnd)
1546 ICOM_THIS(IShellViewImpl, iface);
1548 TRACE("(%p)\n",This);
1550 *phWnd = This->hWnd;
1552 return S_OK;
1555 static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView * iface,BOOL fEnterMode)
1557 ICOM_THIS(IShellViewImpl, iface);
1559 FIXME("(%p) stub\n",This);
1561 return E_NOTIMPL;
1564 /**********************************************************
1565 * IShellView_TranslateAccelerator
1567 * FIXME:
1568 * use the accel functions
1570 static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg)
1572 #if 0
1573 ICOM_THIS(IShellViewImpl, iface);
1575 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1576 #endif
1578 if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST))
1580 TRACE("-- key=0x04%x\n",lpmsg->wParam) ;
1582 return S_FALSE; /* not handled */
1585 static HRESULT WINAPI IShellView_fnEnableModeless(IShellView * iface,BOOL fEnable)
1587 ICOM_THIS(IShellViewImpl, iface);
1589 FIXME("(%p) stub\n",This);
1591 return E_NOTIMPL;
1594 static HRESULT WINAPI IShellView_fnUIActivate(IShellView * iface,UINT uState)
1596 ICOM_THIS(IShellViewImpl, iface);
1599 CHAR szName[MAX_PATH];
1601 LRESULT lResult;
1602 int nPartArray[1] = {-1};
1604 TRACE("(%p)->(state=%x) stub\n",This, uState);
1606 /*don't do anything if the state isn't really changing*/
1607 if(This->uState == uState)
1609 return S_OK;
1612 /*OnActivate handles the menu merging and internal state*/
1613 ShellView_OnActivate(This, uState);
1615 /*only do This if we are active*/
1616 if(uState != SVUIA_DEACTIVATE)
1620 GetFolderPath is not a method of IShellFolder
1621 IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1623 /* set the number of parts */
1624 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1625 (LPARAM)nPartArray, &lResult);
1627 /* set the text for the parts */
1629 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1630 0, (LPARAM)szName, &lResult);
1634 return S_OK;
1637 static HRESULT WINAPI IShellView_fnRefresh(IShellView * iface)
1639 ICOM_THIS(IShellViewImpl, iface);
1641 TRACE("(%p)\n",This);
1643 ListView_DeleteAllItems(This->hWndList);
1644 ShellView_FillList(This);
1646 return S_OK;
1649 static HRESULT WINAPI IShellView_fnCreateViewWindow(
1650 IShellView * iface,
1651 IShellView *lpPrevView,
1652 LPCFOLDERSETTINGS lpfs,
1653 IShellBrowser * psb,
1654 RECT * prcView,
1655 HWND *phWnd)
1657 ICOM_THIS(IShellViewImpl, iface);
1659 WNDCLASSA wc;
1660 *phWnd = 0;
1663 TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This, lpPrevView,lpfs, psb, prcView, phWnd);
1664 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);
1666 /*set up the member variables*/
1667 This->pShellBrowser = psb;
1668 This->FolderSettings = *lpfs;
1670 /*get our parent window*/
1671 IShellBrowser_AddRef(This->pShellBrowser);
1672 IShellBrowser_GetWindow(This->pShellBrowser, &(This->hWndParent));
1674 /* try to get the ICommDlgBrowserInterface, adds a reference !!! */
1675 This->pCommDlgBrowser=NULL;
1676 if ( SUCCEEDED (IShellBrowser_QueryInterface( This->pShellBrowser,
1677 (REFIID)&IID_ICommDlgBrowser, (LPVOID*) &This->pCommDlgBrowser)))
1679 TRACE("-- CommDlgBrowser\n");
1682 /*if our window class has not been registered, then do so*/
1683 if(!GetClassInfoA(shell32_hInstance, SV_CLASS_NAME, &wc))
1685 ZeroMemory(&wc, sizeof(wc));
1686 wc.style = CS_HREDRAW | CS_VREDRAW;
1687 wc.lpfnWndProc = (WNDPROC) ShellView_WndProc;
1688 wc.cbClsExtra = 0;
1689 wc.cbWndExtra = 0;
1690 wc.hInstance = shell32_hInstance;
1691 wc.hIcon = 0;
1692 wc.hCursor = LoadCursorA (0, IDC_ARROWA);
1693 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
1694 wc.lpszMenuName = NULL;
1695 wc.lpszClassName = SV_CLASS_NAME;
1697 if(!RegisterClassA(&wc))
1698 return E_FAIL;
1701 *phWnd = CreateWindowExA(0,
1702 SV_CLASS_NAME,
1703 NULL,
1704 WS_CHILD | WS_VISIBLE | WS_TABSTOP,
1705 prcView->left,
1706 prcView->top,
1707 prcView->right - prcView->left,
1708 prcView->bottom - prcView->top,
1709 This->hWndParent,
1711 shell32_hInstance,
1712 (LPVOID)This);
1714 CheckToolbar(This);
1716 if(!*phWnd) return E_FAIL;
1718 return S_OK;
1721 static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView * iface)
1723 ICOM_THIS(IShellViewImpl, iface);
1725 TRACE("(%p)\n",This);
1727 /*Make absolutely sure all our UI is cleaned up.*/
1728 IShellView_UIActivate((IShellView*)This, SVUIA_DEACTIVATE);
1730 if(This->hMenu)
1732 DestroyMenu(This->hMenu);
1735 DestroyWindow(This->hWnd);
1736 IShellBrowser_Release(This->pShellBrowser);
1738 return S_OK;
1741 static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView * iface, LPFOLDERSETTINGS lpfs)
1743 ICOM_THIS(IShellViewImpl, iface);
1745 TRACE("(%p)->(%p) vmode=%x flags=%x\n",This, lpfs,
1746 This->FolderSettings.ViewMode, This->FolderSettings.fFlags);
1748 if (!lpfs) return E_INVALIDARG;
1750 *lpfs = This->FolderSettings;
1751 return NOERROR;
1754 static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView * iface, DWORD dwReserved,LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
1756 ICOM_THIS(IShellViewImpl, iface);
1758 FIXME("(%p) stub\n",This);
1760 return E_NOTIMPL;
1763 static HRESULT WINAPI IShellView_fnSaveViewState(IShellView * iface)
1765 ICOM_THIS(IShellViewImpl, iface);
1767 FIXME("(%p) stub\n",This);
1769 return S_OK;
1772 static HRESULT WINAPI IShellView_fnSelectItem(
1773 IShellView * iface,
1774 LPCITEMIDLIST pidl,
1775 UINT uFlags)
1777 ICOM_THIS(IShellViewImpl, iface);
1778 int i;
1780 TRACE("(%p)->(pidl=%p, 0x%08x) stub\n",This, pidl, uFlags);
1782 i = LV_FindItemByPidl(This, pidl);
1784 if (i != -1)
1786 LVITEMA lvItem;
1788 if(uFlags & SVSI_ENSUREVISIBLE)
1789 ListView_EnsureVisible(This->hWndList, i, 0);
1791 ZeroMemory(&lvItem, sizeof(LVITEMA));
1792 lvItem.mask = LVIF_STATE;
1793 lvItem.iItem = 0;
1795 while(ListView_GetItemA(This->hWndList, &lvItem))
1797 if (lvItem.iItem == i)
1799 if (uFlags & SVSI_SELECT)
1800 lvItem.state |= LVIS_SELECTED;
1801 else
1802 lvItem.state &= ~LVIS_SELECTED;
1804 if(uFlags & SVSI_FOCUSED)
1805 lvItem.state &= ~LVIS_FOCUSED;
1807 else
1809 if (uFlags & SVSI_DESELECTOTHERS)
1810 lvItem.state &= ~LVIS_SELECTED;
1812 ListView_SetItemA(This->hWndList, &lvItem);
1813 lvItem.iItem++;
1817 if(uFlags & SVSI_EDIT)
1818 ListView_EditLabelA(This->hWndList, i);
1821 return S_OK;
1824 static HRESULT WINAPI IShellView_fnGetItemObject(IShellView * iface, UINT uItem, REFIID riid, LPVOID *ppvOut)
1826 ICOM_THIS(IShellViewImpl, iface);
1828 TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This, uItem, debugstr_guid(riid), ppvOut);
1830 *ppvOut = NULL;
1832 switch(uItem)
1834 case SVGIO_BACKGROUND:
1835 *ppvOut = ISvBgCm_Constructor(This->pSFParent);
1836 break;
1838 case SVGIO_SELECTION:
1839 ShellView_GetSelections(This);
1840 IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, riid, 0, ppvOut);
1841 break;
1843 TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
1845 if(!*ppvOut) return E_OUTOFMEMORY;
1847 return S_OK;
1850 static HRESULT WINAPI IShellView_fnEditItem(
1851 IShellView * iface,
1852 LPITEMIDLIST pidl)
1854 ICOM_THIS(IShellViewImpl, iface);
1855 int i;
1857 TRACE("(%p)->(pidl=%p)\n",This, pidl);
1859 i = LV_FindItemByPidl(This, pidl);
1860 if (i != -1)
1862 SetFocus(This->hWndList);
1863 ListView_EditLabelA(This->hWndList, i);
1865 return S_OK;
1868 static struct ICOM_VTABLE(IShellView) svvt =
1870 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1871 IShellView_fnQueryInterface,
1872 IShellView_fnAddRef,
1873 IShellView_fnRelease,
1874 IShellView_fnGetWindow,
1875 IShellView_fnContextSensitiveHelp,
1876 IShellView_fnTranslateAccelerator,
1877 IShellView_fnEnableModeless,
1878 IShellView_fnUIActivate,
1879 IShellView_fnRefresh,
1880 IShellView_fnCreateViewWindow,
1881 IShellView_fnDestroyViewWindow,
1882 IShellView_fnGetCurrentInfo,
1883 IShellView_fnAddPropertySheetPages,
1884 IShellView_fnSaveViewState,
1885 IShellView_fnSelectItem,
1886 IShellView_fnGetItemObject,
1887 IShellView_fnEditItem
1891 /**********************************************************
1892 * ISVOleCmdTarget_QueryInterface (IUnknown)
1894 static HRESULT WINAPI ISVOleCmdTarget_QueryInterface(
1895 IOleCommandTarget * iface,
1896 REFIID iid,
1897 LPVOID* ppvObj)
1899 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1901 return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj);
1904 /**********************************************************
1905 * ISVOleCmdTarget_AddRef (IUnknown)
1907 static ULONG WINAPI ISVOleCmdTarget_AddRef(
1908 IOleCommandTarget * iface)
1910 _ICOM_THIS_From_IOleCommandTarget(IShellFolder, iface);
1912 return IShellFolder_AddRef((IShellFolder*)This);
1915 /**********************************************************
1916 * ISVOleCmdTarget_Release (IUnknown)
1918 static ULONG WINAPI ISVOleCmdTarget_Release(
1919 IOleCommandTarget * iface)
1921 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1923 return IShellFolder_Release((IShellFolder*)This);
1926 /**********************************************************
1927 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
1929 static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
1930 IOleCommandTarget *iface,
1931 const GUID* pguidCmdGroup,
1932 ULONG cCmds,
1933 OLECMD * prgCmds,
1934 OLECMDTEXT* pCmdText)
1936 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1938 FIXME("(%p)->(%p(%s) 0x%08lx %p %p\n",
1939 This, pguidCmdGroup, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
1940 return E_NOTIMPL;
1943 /**********************************************************
1944 * ISVOleCmdTarget_Exec (IOleCommandTarget)
1946 * nCmdID is the OLECMDID_* enumeration
1948 static HRESULT WINAPI ISVOleCmdTarget_Exec(
1949 IOleCommandTarget *iface,
1950 const GUID* pguidCmdGroup,
1951 DWORD nCmdID,
1952 DWORD nCmdexecopt,
1953 VARIANT* pvaIn,
1954 VARIANT* pvaOut)
1956 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1958 FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08lx Opt:0x%08lx %p %p)\n",
1959 This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, pvaIn, pvaOut);
1960 return E_NOTIMPL;
1963 static ICOM_VTABLE(IOleCommandTarget) ctvt =
1965 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1966 ISVOleCmdTarget_QueryInterface,
1967 ISVOleCmdTarget_AddRef,
1968 ISVOleCmdTarget_Release,
1969 ISVOleCmdTarget_QueryStatus,
1970 ISVOleCmdTarget_Exec
1973 /**********************************************************
1974 * ISVDropTarget implementation
1977 static HRESULT WINAPI ISVDropTarget_QueryInterface(
1978 IDropTarget *iface,
1979 REFIID riid,
1980 LPVOID *ppvObj)
1982 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1984 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1986 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
1989 static ULONG WINAPI ISVDropTarget_AddRef( IDropTarget *iface)
1991 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1993 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1995 return IShellFolder_AddRef((IShellFolder*)This);
1998 static ULONG WINAPI ISVDropTarget_Release( IDropTarget *iface)
2000 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2002 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2004 return IShellFolder_Release((IShellFolder*)This);
2007 static HRESULT WINAPI ISVDropTarget_DragEnter(
2008 IDropTarget *iface,
2009 IDataObject *pDataObject,
2010 DWORD grfKeyState,
2011 POINTL pt,
2012 DWORD *pdwEffect)
2015 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2017 FIXME("Stub: This=%p, DataObject=%p\n",This,pDataObject);
2019 return E_NOTIMPL;
2022 static HRESULT WINAPI ISVDropTarget_DragOver(
2023 IDropTarget *iface,
2024 DWORD grfKeyState,
2025 POINTL pt,
2026 DWORD *pdwEffect)
2028 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2030 FIXME("Stub: This=%p\n",This);
2032 return E_NOTIMPL;
2035 static HRESULT WINAPI ISVDropTarget_DragLeave(
2036 IDropTarget *iface)
2038 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2040 FIXME("Stub: This=%p\n",This);
2042 return E_NOTIMPL;
2045 static HRESULT WINAPI ISVDropTarget_Drop(
2046 IDropTarget *iface,
2047 IDataObject* pDataObject,
2048 DWORD grfKeyState,
2049 POINTL pt,
2050 DWORD *pdwEffect)
2052 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2054 FIXME("Stub: This=%p\n",This);
2056 return E_NOTIMPL;
2059 static struct ICOM_VTABLE(IDropTarget) dtvt =
2061 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2062 ISVDropTarget_QueryInterface,
2063 ISVDropTarget_AddRef,
2064 ISVDropTarget_Release,
2065 ISVDropTarget_DragEnter,
2066 ISVDropTarget_DragOver,
2067 ISVDropTarget_DragLeave,
2068 ISVDropTarget_Drop
2071 /**********************************************************
2072 * ISVDropSource implementation
2075 static HRESULT WINAPI ISVDropSource_QueryInterface(
2076 IDropSource *iface,
2077 REFIID riid,
2078 LPVOID *ppvObj)
2080 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2082 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2084 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2087 static ULONG WINAPI ISVDropSource_AddRef( IDropSource *iface)
2089 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2091 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2093 return IShellFolder_AddRef((IShellFolder*)This);
2096 static ULONG WINAPI ISVDropSource_Release( IDropSource *iface)
2098 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2100 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2102 return IShellFolder_Release((IShellFolder*)This);
2104 static HRESULT WINAPI ISVDropSource_QueryContinueDrag(
2105 IDropSource *iface,
2106 BOOL fEscapePressed,
2107 DWORD grfKeyState)
2109 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2110 TRACE("(%p)\n",This);
2112 if (fEscapePressed)
2113 return DRAGDROP_S_CANCEL;
2114 else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
2115 return DRAGDROP_S_DROP;
2116 else
2117 return NOERROR;
2120 static HRESULT WINAPI ISVDropSource_GiveFeedback(
2121 IDropSource *iface,
2122 DWORD dwEffect)
2124 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2125 TRACE("(%p)\n",This);
2127 return DRAGDROP_S_USEDEFAULTCURSORS;
2130 static struct ICOM_VTABLE(IDropSource) dsvt =
2132 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2133 ISVDropSource_QueryInterface,
2134 ISVDropSource_AddRef,
2135 ISVDropSource_Release,
2136 ISVDropSource_QueryContinueDrag,
2137 ISVDropSource_GiveFeedback
2139 /**********************************************************
2140 * ISVViewObject implementation
2143 static HRESULT WINAPI ISVViewObject_QueryInterface(
2144 IViewObject *iface,
2145 REFIID riid,
2146 LPVOID *ppvObj)
2148 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2150 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2152 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2155 static ULONG WINAPI ISVViewObject_AddRef( IViewObject *iface)
2157 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2159 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2161 return IShellFolder_AddRef((IShellFolder*)This);
2164 static ULONG WINAPI ISVViewObject_Release( IViewObject *iface)
2166 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2168 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2170 return IShellFolder_Release((IShellFolder*)This);
2173 static HRESULT WINAPI ISVViewObject_Draw(
2174 IViewObject *iface,
2175 DWORD dwDrawAspect,
2176 LONG lindex,
2177 void* pvAspect,
2178 DVTARGETDEVICE* ptd,
2179 HDC hdcTargetDev,
2180 HDC hdcDraw,
2181 LPCRECTL lprcBounds,
2182 LPCRECTL lprcWBounds,
2183 IVO_ContCallback pfnContinue,
2184 DWORD dwContinue)
2187 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2189 FIXME("Stub: This=%p\n",This);
2191 return E_NOTIMPL;
2193 static HRESULT WINAPI ISVViewObject_GetColorSet(
2194 IViewObject *iface,
2195 DWORD dwDrawAspect,
2196 LONG lindex,
2197 void *pvAspect,
2198 DVTARGETDEVICE* ptd,
2199 HDC hicTargetDevice,
2200 LOGPALETTE** ppColorSet)
2203 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2205 FIXME("Stub: This=%p\n",This);
2207 return E_NOTIMPL;
2209 static HRESULT WINAPI ISVViewObject_Freeze(
2210 IViewObject *iface,
2211 DWORD dwDrawAspect,
2212 LONG lindex,
2213 void* pvAspect,
2214 DWORD* pdwFreeze)
2217 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2219 FIXME("Stub: This=%p\n",This);
2221 return E_NOTIMPL;
2223 static HRESULT WINAPI ISVViewObject_Unfreeze(
2224 IViewObject *iface,
2225 DWORD dwFreeze)
2228 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2230 FIXME("Stub: This=%p\n",This);
2232 return E_NOTIMPL;
2234 static HRESULT WINAPI ISVViewObject_SetAdvise(
2235 IViewObject *iface,
2236 DWORD aspects,
2237 DWORD advf,
2238 IAdviseSink* pAdvSink)
2241 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2243 FIXME("Stub: This=%p\n",This);
2245 return E_NOTIMPL;
2247 static HRESULT WINAPI ISVViewObject_GetAdvise(
2248 IViewObject *iface,
2249 DWORD* pAspects,
2250 DWORD* pAdvf,
2251 IAdviseSink** ppAdvSink)
2254 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2256 FIXME("Stub: This=%p\n",This);
2258 return E_NOTIMPL;
2262 static struct ICOM_VTABLE(IViewObject) vovt =
2264 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2265 ISVViewObject_QueryInterface,
2266 ISVViewObject_AddRef,
2267 ISVViewObject_Release,
2268 ISVViewObject_Draw,
2269 ISVViewObject_GetColorSet,
2270 ISVViewObject_Freeze,
2271 ISVViewObject_Unfreeze,
2272 ISVViewObject_SetAdvise,
2273 ISVViewObject_GetAdvise