Do not allow creation of not aligned EMF records by GDI code.
[wine.git] / dlls / shell32 / shlview.c
blob5a629e294807f5c5218a73eea66d579432dbc609
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 "config.h"
40 #include "wine/port.h"
42 #include <stdarg.h>
43 #include <stdlib.h>
44 #include <string.h>
46 #include "windef.h"
47 #include "winerror.h"
48 #include "winbase.h"
49 #include "winnls.h"
50 #include "servprov.h"
51 #include "shlguid.h"
52 #include "wingdi.h"
53 #include "winuser.h"
54 #include "shlobj.h"
55 #include "undocshell.h"
56 #include "shresdef.h"
57 #include "wine/debug.h"
59 #include "docobj.h"
60 #include "pidl.h"
61 #include "shell32_main.h"
62 #include "shellfolder.h"
64 WINE_DEFAULT_DEBUG_CHANNEL(shell);
66 typedef struct
67 { BOOL bIsAscending;
68 INT nHeaderID;
69 INT nLastHeaderID;
70 }LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO;
72 typedef struct
73 { ICOM_VFIELD(IShellView);
74 DWORD ref;
75 ICOM_VTABLE(IOleCommandTarget)* lpvtblOleCommandTarget;
76 ICOM_VTABLE(IDropTarget)* lpvtblDropTarget;
77 ICOM_VTABLE(IDropSource)* lpvtblDropSource;
78 ICOM_VTABLE(IViewObject)* lpvtblViewObject;
79 IShellFolder* pSFParent;
80 IShellFolder2* pSF2Parent;
81 IShellBrowser* pShellBrowser;
82 ICommDlgBrowser* pCommDlgBrowser;
83 HWND hWnd; /* SHELLDLL_DefView */
84 HWND hWndList; /* ListView control */
85 HWND hWndParent;
86 FOLDERSETTINGS FolderSettings;
87 HMENU hMenu;
88 UINT uState;
89 UINT cidl;
90 LPITEMIDLIST *apidl;
91 LISTVIEW_SORT_INFO ListViewSortInfo;
92 ULONG hNotify; /* change notification handle */
93 HANDLE hAccel;
94 } IShellViewImpl;
96 static struct ICOM_VTABLE(IShellView) svvt;
98 static struct ICOM_VTABLE(IOleCommandTarget) ctvt;
99 #define _IOleCommandTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblOleCommandTarget)))
100 #define _ICOM_THIS_From_IOleCommandTarget(class, name) class* This = (class*)(((char*)name)-_IOleCommandTarget_Offset);
102 static struct ICOM_VTABLE(IDropTarget) dtvt;
103 #define _IDropTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropTarget)))
104 #define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
106 static struct ICOM_VTABLE(IDropSource) dsvt;
107 #define _IDropSource_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropSource)))
108 #define _ICOM_THIS_From_IDropSource(class, name) class* This = (class*)(((char*)name)-_IDropSource_Offset);
110 static struct ICOM_VTABLE(IViewObject) vovt;
111 #define _IViewObject_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblViewObject)))
112 #define _ICOM_THIS_From_IViewObject(class, name) class* This = (class*)(((char*)name)-_IViewObject_Offset);
114 /* ListView Header ID's */
115 #define LISTVIEW_COLUMN_NAME 0
116 #define LISTVIEW_COLUMN_SIZE 1
117 #define LISTVIEW_COLUMN_TYPE 2
118 #define LISTVIEW_COLUMN_TIME 3
119 #define LISTVIEW_COLUMN_ATTRIB 4
121 /*menu items */
122 #define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500)
123 #define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501)
124 #define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502)
126 #define ID_LISTVIEW 2000
128 #define SHV_CHANGE_NOTIFY WM_USER + 0x1111
130 /*windowsx.h */
131 #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
132 #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
133 #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
135 extern void WINAPI _InsertMenuItem (HMENU hmenu, UINT indexMenu, BOOL fByPosition,
136 UINT wID, UINT fType, LPSTR dwTypeData, UINT fState);
139 Items merged into the toolbar and and the filemenu
141 typedef struct
142 { int idCommand;
143 int iImage;
144 int idButtonString;
145 int idMenuString;
146 BYTE bState;
147 BYTE bStyle;
148 } MYTOOLINFO, *LPMYTOOLINFO;
150 MYTOOLINFO Tools[] =
152 { FCIDM_SHVIEW_BIGICON, 0, 0, IDS_VIEW_LARGE, TBSTATE_ENABLED, BTNS_BUTTON },
153 { FCIDM_SHVIEW_SMALLICON, 0, 0, IDS_VIEW_SMALL, TBSTATE_ENABLED, BTNS_BUTTON },
154 { FCIDM_SHVIEW_LISTVIEW, 0, 0, IDS_VIEW_LIST, TBSTATE_ENABLED, BTNS_BUTTON },
155 { FCIDM_SHVIEW_REPORTVIEW, 0, 0, IDS_VIEW_DETAILS, TBSTATE_ENABLED, BTNS_BUTTON },
156 { -1, 0, 0, 0, 0, 0}
159 typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
161 /**********************************************************
162 * IShellView_Constructor
164 IShellView * IShellView_Constructor( IShellFolder * pFolder)
165 { IShellViewImpl * sv;
166 sv=(IShellViewImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl));
167 sv->ref=1;
168 sv->lpVtbl=&svvt;
169 sv->lpvtblOleCommandTarget=&ctvt;
170 sv->lpvtblDropTarget=&dtvt;
171 sv->lpvtblDropSource=&dsvt;
172 sv->lpvtblViewObject=&vovt;
174 sv->pSFParent = pFolder;
175 if(pFolder) IShellFolder_AddRef(pFolder);
176 IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (LPVOID*)&sv->pSF2Parent);
178 TRACE("(%p)->(%p)\n",sv, pFolder);
179 return (IShellView *) sv;
182 /**********************************************************
184 * ##### helperfunctions for communication with ICommDlgBrowser #####
186 static BOOL IsInCommDlg(IShellViewImpl * This)
187 { return(This->pCommDlgBrowser != NULL);
190 static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl)
192 HRESULT ret = S_OK;
194 if ( IsInCommDlg(This) )
196 TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
197 ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView*)This, pidl);
198 TRACE("--0x%08lx\n", ret);
200 return ret;
203 static HRESULT OnDefaultCommand(IShellViewImpl * This)
205 HRESULT ret = S_FALSE;
207 if (IsInCommDlg(This))
209 TRACE("ICommDlgBrowser::OnDefaultCommand\n");
210 ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView*)This);
211 TRACE("--\n");
213 return ret;
216 static HRESULT OnStateChange(IShellViewImpl * This, UINT uFlags)
218 HRESULT ret = S_FALSE;
220 if (IsInCommDlg(This))
222 TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags);
223 ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView*)This, uFlags);
224 TRACE("--\n");
226 return ret;
228 /**********************************************************
229 * set the toolbar of the filedialog buttons
231 * - activates the buttons from the shellbrowser according to
232 * the view state
234 static void CheckToolbar(IShellViewImpl * This)
236 LRESULT result;
238 TRACE("\n");
240 if (IsInCommDlg(This))
242 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
243 FCIDM_TB_SMALLICON, (This->FolderSettings.ViewMode==FVM_LIST)? TRUE : FALSE, &result);
244 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
245 FCIDM_TB_REPORTVIEW, (This->FolderSettings.ViewMode==FVM_DETAILS)? TRUE : FALSE, &result);
246 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
247 FCIDM_TB_SMALLICON, TRUE, &result);
248 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
249 FCIDM_TB_REPORTVIEW, TRUE, &result);
253 /**********************************************************
255 * ##### helperfunctions for initializing the view #####
257 /**********************************************************
258 * change the style of the listview control
260 static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove)
262 DWORD tmpstyle;
264 TRACE("(%p)\n", This);
266 tmpstyle = GetWindowLongA(This->hWndList, GWL_STYLE);
267 SetWindowLongA(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove));
270 /**********************************************************
271 * ShellView_CreateList()
273 * - creates the list view window
275 static BOOL ShellView_CreateList (IShellViewImpl * This)
276 { DWORD dwStyle, dwExStyle;
278 TRACE("%p\n",This);
280 dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
281 LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_AUTOARRANGE;
282 dwExStyle = WS_EX_CLIENTEDGE;
284 switch (This->FolderSettings.ViewMode)
286 case FVM_ICON: dwStyle |= LVS_ICON; break;
287 case FVM_DETAILS: dwStyle |= LVS_REPORT; break;
288 case FVM_SMALLICON: dwStyle |= LVS_SMALLICON; break;
289 case FVM_LIST: dwStyle |= LVS_LIST; break;
290 default: dwStyle |= LVS_LIST; break;
293 if (This->FolderSettings.fFlags & FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE;
294 if (This->FolderSettings.fFlags & FWF_DESKTOP)
295 This->FolderSettings.fFlags |= FWF_NOCLIENTEDGE | FWF_NOSCROLL;
296 if (This->FolderSettings.fFlags & FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL;
297 if (This->FolderSettings.fFlags & FWF_NOCLIENTEDGE)
298 dwExStyle &= ~WS_EX_CLIENTEDGE;
300 This->hWndList=CreateWindowExA( dwExStyle,
301 WC_LISTVIEWA,
302 NULL,
303 dwStyle,
304 0,0,0,0,
305 This->hWnd,
306 (HMENU)ID_LISTVIEW,
307 shell32_hInstance,
308 NULL);
310 if(!This->hWndList)
311 return FALSE;
313 This->ListViewSortInfo.bIsAscending = TRUE;
314 This->ListViewSortInfo.nHeaderID = -1;
315 This->ListViewSortInfo.nLastHeaderID = -1;
317 if (This->FolderSettings.fFlags & FWF_DESKTOP) {
318 if (0) /* FIXME: look into registry vale HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ListviewShadow and activate drop shadows */
319 ListView_SetTextBkColor(This->hWndList, CLR_NONE);
320 else
321 ListView_SetTextBkColor(This->hWndList, GetSysColor(COLOR_DESKTOP));
323 ListView_SetTextColor(This->hWndList, RGB(255,255,255));
326 /* UpdateShellSettings(); */
327 return TRUE;
330 /**********************************************************
331 * ShellView_InitList()
333 * - adds all needed columns to the shellview
335 static BOOL ShellView_InitList(IShellViewImpl * This)
337 LVCOLUMNA lvColumn;
338 SHELLDETAILS sd;
339 int i;
340 char szTemp[50];
342 TRACE("%p\n",This);
344 ListView_DeleteAllItems(This->hWndList);
346 lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
347 lvColumn.pszText = szTemp;
349 if (This->pSF2Parent)
351 for (i=0; 1; i++)
353 if (!SUCCEEDED(IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, i, &sd)))
354 break;
355 lvColumn.fmt = sd.fmt;
356 lvColumn.cx = sd.cxChar*8; /* chars->pixel */
357 StrRetToStrNA( szTemp, 50, &sd.str, NULL);
358 ListView_InsertColumnA(This->hWndList, i, &lvColumn);
361 else
363 FIXME("no SF2\n");
366 ListView_SetImageList(This->hWndList, ShellSmallIconList, LVSIL_SMALL);
367 ListView_SetImageList(This->hWndList, ShellBigIconList, LVSIL_NORMAL);
369 return TRUE;
371 /**********************************************************
372 * ShellView_CompareItems()
374 * NOTES
375 * internal, CALLBACK for DSA_Sort
377 static INT CALLBACK ShellView_CompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
379 int ret;
380 TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1, lParam2, (LPVOID) lpData);
382 if(!lpData) return 0;
384 ret = (SHORT) SCODE_CODE(IShellFolder_CompareIDs((LPSHELLFOLDER)lpData, 0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2));
385 TRACE("ret=%i\n",ret);
386 return ret;
389 /*************************************************************************
390 * ShellView_ListViewCompareItems
392 * Compare Function for the Listview (FileOpen Dialog)
394 * PARAMS
395 * lParam1 [I] the first ItemIdList to compare with
396 * lParam2 [I] the second ItemIdList to compare with
397 * lpData [I] The column ID for the header Ctrl to process
399 * RETURNS
400 * A negative value if the first item should precede the second,
401 * a positive value if the first item should follow the second,
402 * or zero if the two items are equivalent
404 * NOTES
405 * FIXME: function does what ShellView_CompareItems is supposed to do.
406 * unify it and figure out how to use the undocumented first parameter
407 * of IShellFolder_CompareIDs to do the job this function does and
408 * move this code to IShellFolder.
409 * make LISTVIEW_SORT_INFO obsolete
410 * the way this function works is only usable if we had only
411 * filesystemfolders (25/10/99 jsch)
413 static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
415 INT nDiff=0;
416 FILETIME fd1, fd2;
417 char strName1[MAX_PATH], strName2[MAX_PATH];
418 BOOL bIsFolder1, bIsFolder2,bIsBothFolder;
419 LPITEMIDLIST pItemIdList1 = (LPITEMIDLIST) lParam1;
420 LPITEMIDLIST pItemIdList2 = (LPITEMIDLIST) lParam2;
421 LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData;
424 bIsFolder1 = _ILIsFolder(pItemIdList1);
425 bIsFolder2 = _ILIsFolder(pItemIdList2);
426 bIsBothFolder = bIsFolder1 && bIsFolder2;
428 /* When sorting between a File and a Folder, the Folder gets sorted first */
429 if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder)
431 nDiff = bIsFolder1 ? -1 : 1;
433 else
435 /* Sort by Time: Folders or Files can be sorted */
437 if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)
439 _ILGetFileDateTime(pItemIdList1, &fd1);
440 _ILGetFileDateTime(pItemIdList2, &fd2);
441 nDiff = CompareFileTime(&fd2, &fd1);
443 /* Sort by Attribute: Folder or Files can be sorted */
444 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB)
446 _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH);
447 _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH);
448 nDiff = strcasecmp(strName1, strName2);
450 /* Sort by FileName: Folder or Files can be sorted */
451 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder)
453 /* Sort by Text */
454 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
455 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
456 nDiff = strcasecmp(strName1, strName2);
458 /* Sort by File Size, Only valid for Files */
459 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)
461 nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0));
463 /* Sort by File Type, Only valid for Files */
464 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)
466 /* Sort by Type */
467 _ILGetFileType(pItemIdList1, strName1, MAX_PATH);
468 _ILGetFileType(pItemIdList2, strName2, MAX_PATH);
469 nDiff = strcasecmp(strName1, strName2);
472 /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
474 if(nDiff == 0)
476 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
477 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
478 nDiff = strcasecmp(strName1, strName2);
481 if(!pSortInfo->bIsAscending)
483 nDiff = -nDiff;
486 return nDiff;
490 /**********************************************************
491 * LV_FindItemByPidl()
493 static int LV_FindItemByPidl(
494 IShellViewImpl * This,
495 LPCITEMIDLIST pidl)
497 LVITEMA lvItem;
498 ZeroMemory(&lvItem, sizeof(LVITEMA));
499 lvItem.mask = LVIF_PARAM;
500 for(lvItem.iItem = 0; ListView_GetItemA(This->hWndList, &lvItem); lvItem.iItem++)
502 LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam;
503 HRESULT hr = IShellFolder_CompareIDs(This->pSFParent, 0, pidl, currentpidl);
504 if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
506 return lvItem.iItem;
509 return -1;
512 /**********************************************************
513 * LV_AddItem()
515 static BOOLEAN LV_AddItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
517 LVITEMA lvItem;
519 TRACE("(%p)(pidl=%p)\n", This, pidl);
521 ZeroMemory(&lvItem, sizeof(lvItem)); /* create the listview item*/
522 lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; /*set the mask*/
523 lvItem.iItem = ListView_GetItemCount(This->hWndList); /*add the item to the end of the list*/
524 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidl)); /*set the item's data*/
525 lvItem.pszText = LPSTR_TEXTCALLBACKA; /*get text on a callback basis*/
526 lvItem.iImage = I_IMAGECALLBACK; /*get the image on a callback basis*/
527 return (-1==ListView_InsertItemA(This->hWndList, &lvItem))? FALSE: TRUE;
530 /**********************************************************
531 * LV_DeleteItem()
533 static BOOLEAN LV_DeleteItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
535 int nIndex;
537 TRACE("(%p)(pidl=%p)\n", This, pidl);
539 nIndex = LV_FindItemByPidl(This, ILFindLastID(pidl));
540 return (-1==ListView_DeleteItem(This->hWndList, nIndex))? FALSE: TRUE;
543 /**********************************************************
544 * LV_RenameItem()
546 static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew )
548 int nItem;
549 LVITEMA lvItem;
551 TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew);
553 nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld));
554 if ( -1 != nItem )
556 ZeroMemory(&lvItem, sizeof(lvItem)); /* create the listview item*/
557 lvItem.mask = LVIF_PARAM; /* only the pidl */
558 lvItem.iItem = nItem;
559 ListView_GetItemA(This->hWndList, &lvItem);
561 SHFree((LPITEMIDLIST)lvItem.lParam);
562 lvItem.mask = LVIF_PARAM;
563 lvItem.iItem = nItem;
564 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew)); /* set the item's data */
565 ListView_SetItemA(This->hWndList, &lvItem);
566 ListView_Update(This->hWndList, nItem);
567 return TRUE; /* FIXME: better handling */
569 return FALSE;
571 /**********************************************************
572 * ShellView_FillList()
574 * - gets the objectlist from the shellfolder
575 * - sorts the list
576 * - fills the list into the view
579 static INT CALLBACK fill_list( LPVOID ptr, LPVOID arg )
581 LPITEMIDLIST pidl = ptr;
582 IShellViewImpl *This = arg;
583 /* in a commdlg This works as a filemask*/
584 if ( IncludeObject(This, pidl)==S_OK ) LV_AddItem(This, pidl);
585 SHFree(pidl);
586 return TRUE;
589 static HRESULT ShellView_FillList(IShellViewImpl * This)
591 LPENUMIDLIST pEnumIDList;
592 LPITEMIDLIST pidl;
593 DWORD dwFetched;
594 HRESULT hRes;
595 HDPA hdpa;
597 TRACE("%p\n",This);
599 /* get the itemlist from the shfolder*/
600 hRes = IShellFolder_EnumObjects(This->pSFParent,This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList);
601 if (hRes != S_OK)
603 if (hRes==S_FALSE)
604 return(NOERROR);
605 return(hRes);
608 /* create a pointer array */
609 hdpa = DPA_Create(16);
610 if (!hdpa)
612 return(E_OUTOFMEMORY);
615 /* copy the items into the array*/
616 while((S_OK == IEnumIDList_Next(pEnumIDList,1, &pidl, &dwFetched)) && dwFetched)
618 if (DPA_InsertPtr(hdpa, 0x7fff, pidl) == -1)
620 SHFree(pidl);
624 /* sort the array */
625 DPA_Sort(hdpa, ShellView_CompareItems, (LPARAM)This->pSFParent);
627 /*turn the listview's redrawing off*/
628 SendMessageA(This->hWndList, WM_SETREDRAW, FALSE, 0);
630 DPA_DestroyCallback( hdpa, fill_list, This );
632 /*turn the listview's redrawing back on and force it to draw*/
633 SendMessageA(This->hWndList, WM_SETREDRAW, TRUE, 0);
635 IEnumIDList_Release(pEnumIDList); /* destroy the list*/
637 return S_OK;
640 /**********************************************************
641 * ShellView_OnCreate()
643 static LRESULT ShellView_OnCreate(IShellViewImpl * This)
645 IDropTarget* pdt;
646 SHChangeNotifyEntry ntreg;
647 IPersistFolder2 * ppf2 = NULL;
649 TRACE("%p\n",This);
651 if(ShellView_CreateList(This))
653 if(ShellView_InitList(This))
655 ShellView_FillList(This);
659 if (SUCCEEDED(IShellFolder_CreateViewObject(This->pSFParent, This->hWnd, &IID_IDropTarget, (LPVOID*)&pdt)))
661 RegisterDragDrop(This->hWnd, pdt);
662 IDropTarget_Release(pdt);
665 /* register for receiving notifications */
666 IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2);
667 if (ppf2)
669 IPersistFolder2_GetCurFolder(ppf2, (LPITEMIDLIST*)&ntreg.pidl);
670 ntreg.fRecursive = TRUE;
671 This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNF_IDLIST, SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg);
672 SHFree((LPITEMIDLIST)ntreg.pidl);
673 IPersistFolder2_Release(ppf2);
676 This->hAccel = LoadAcceleratorsA(shell32_hInstance, "shv_accel");
678 return S_OK;
681 /**********************************************************
682 * #### Handling of the menus ####
685 /**********************************************************
686 * ShellView_BuildFileMenu()
688 static HMENU ShellView_BuildFileMenu(IShellViewImpl * This)
689 { CHAR szText[MAX_PATH];
690 MENUITEMINFOA mii;
691 int nTools,i;
692 HMENU hSubMenu;
694 TRACE("(%p)\n",This);
696 hSubMenu = CreatePopupMenu();
697 if(hSubMenu)
698 { /*get the number of items in our global array*/
699 for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){}
701 /*add the menu items*/
702 for(i = 0; i < nTools; i++)
704 LoadStringA(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH);
706 ZeroMemory(&mii, sizeof(mii));
707 mii.cbSize = sizeof(mii);
708 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
710 if(BTNS_SEP != Tools[i].bStyle) /* no separator*/
712 mii.fType = MFT_STRING;
713 mii.fState = MFS_ENABLED;
714 mii.dwTypeData = szText;
715 mii.wID = Tools[i].idCommand;
717 else
719 mii.fType = MFT_SEPARATOR;
721 /* tack This item onto the end of the menu */
722 InsertMenuItemA(hSubMenu, (UINT)-1, TRUE, &mii);
725 TRACE("-- return (menu=%p)\n",hSubMenu);
726 return hSubMenu;
728 /**********************************************************
729 * ShellView_MergeFileMenu()
731 static void ShellView_MergeFileMenu(IShellViewImpl * This, HMENU hSubMenu)
732 { TRACE("(%p)->(submenu=%p) stub\n",This,hSubMenu);
734 if(hSubMenu)
735 { /*insert This item at the beginning of the menu */
736 _InsertMenuItem(hSubMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
737 _InsertMenuItem(hSubMenu, 0, TRUE, IDM_MYFILEITEM, MFT_STRING, "dummy45", MFS_ENABLED);
740 TRACE("--\n");
743 /**********************************************************
744 * ShellView_MergeViewMenu()
747 static void ShellView_MergeViewMenu(IShellViewImpl * This, HMENU hSubMenu)
748 { MENUITEMINFOA mii;
750 TRACE("(%p)->(submenu=%p)\n",This,hSubMenu);
752 if(hSubMenu)
753 { /*add a separator at the correct position in the menu*/
754 _InsertMenuItem(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
756 ZeroMemory(&mii, sizeof(mii));
757 mii.cbSize = sizeof(mii);
758 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;
759 mii.fType = MFT_STRING;
760 mii.dwTypeData = "View";
761 mii.hSubMenu = LoadMenuA(shell32_hInstance, "MENU_001");
762 InsertMenuItemA(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
766 /**********************************************************
767 * ShellView_GetSelections()
769 * - fills the this->apidl list with the selected objects
771 * RETURNS
772 * number of selected items
774 static UINT ShellView_GetSelections(IShellViewImpl * This)
776 LVITEMA lvItem;
777 UINT i = 0;
779 if (This->apidl)
781 SHFree(This->apidl);
784 This->cidl = ListView_GetSelectedCount(This->hWndList);
785 This->apidl = (LPITEMIDLIST*)SHAlloc(This->cidl * sizeof(LPITEMIDLIST));
787 TRACE("selected=%i\n", This->cidl);
789 if(This->apidl)
791 TRACE("-- Items selected =%u\n", This->cidl);
793 ZeroMemory(&lvItem, sizeof(lvItem));
794 lvItem.mask = LVIF_STATE | LVIF_PARAM;
795 lvItem.stateMask = LVIS_SELECTED;
797 while(ListView_GetItemA(This->hWndList, &lvItem) && (i < This->cidl))
799 if(lvItem.state & LVIS_SELECTED)
801 This->apidl[i] = (LPITEMIDLIST)lvItem.lParam;
802 i++;
803 TRACE("-- selected Item found\n");
805 lvItem.iItem++;
808 return This->cidl;
811 /**********************************************************
812 * ShellView_DoContextMenu()
814 static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL bDefault)
815 { UINT uCommand;
816 DWORD wFlags;
817 HMENU hMenu;
818 BOOL fExplore = FALSE;
819 HWND hwndTree = 0;
820 LPCONTEXTMENU pContextMenu = NULL;
821 IContextMenu2 *pCM = NULL;
822 CMINVOKECOMMANDINFO cmi;
824 TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, bDefault);
826 /* look, what's selected and create a context menu object of it*/
827 if( ShellView_GetSelections(This) )
829 IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, (LPCITEMIDLIST*)This->apidl,
830 (REFIID)&IID_IContextMenu, NULL, (LPVOID *)&pContextMenu);
832 if(pContextMenu)
834 TRACE("-- pContextMenu\n");
835 hMenu = CreatePopupMenu();
837 if( hMenu )
839 /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
840 if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree)
842 TRACE("-- explore mode\n");
843 fExplore = TRUE;
846 /* build the flags depending on what we can do with the selected item */
847 wFlags = CMF_NORMAL | (This->cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0);
849 /* let the ContextMenu merge its items in */
850 if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags )))
852 if( bDefault )
854 TRACE("-- get menu default command\n");
855 uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS);
857 else
859 TRACE("-- track popup\n");
860 uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
863 if(uCommand > 0)
865 TRACE("-- uCommand=%u\n", uCommand);
866 if (IsInCommDlg(This) && ((uCommand==FCIDM_SHVIEW_EXPLORE) || (uCommand==FCIDM_SHVIEW_OPEN)))
868 TRACE("-- dlg: OnDefaultCommand\n");
869 OnDefaultCommand(This);
871 else
873 TRACE("-- explore -- invoke command\n");
874 ZeroMemory(&cmi, sizeof(cmi));
875 cmi.cbSize = sizeof(cmi);
876 cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */
877 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
878 IContextMenu_InvokeCommand(pContextMenu, &cmi);
881 DestroyMenu(hMenu);
884 if (pContextMenu)
885 IContextMenu_Release(pContextMenu);
888 else /* background context menu */
890 hMenu = CreatePopupMenu();
892 pCM = ISvBgCm_Constructor(This->pSFParent);
893 IContextMenu2_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
895 uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
896 DestroyMenu(hMenu);
898 TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand);
900 ZeroMemory(&cmi, sizeof(cmi));
901 cmi.cbSize = sizeof(cmi);
902 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
903 cmi.hwnd = This->hWndParent;
904 IContextMenu2_InvokeCommand(pCM, &cmi);
906 IContextMenu2_Release(pCM);
910 /**********************************************************
911 * ##### message handling #####
914 /**********************************************************
915 * ShellView_OnSize()
917 static LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight)
919 TRACE("%p width=%u height=%u\n",This, wWidth,wHeight);
921 /*resize the ListView to fit our window*/
922 if(This->hWndList)
924 MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE);
927 return S_OK;
929 /**********************************************************
930 * ShellView_OnDeactivate()
932 * NOTES
933 * internal
935 static void ShellView_OnDeactivate(IShellViewImpl * This)
937 TRACE("%p\n",This);
939 if(This->uState != SVUIA_DEACTIVATE)
941 if(This->hMenu)
943 IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0);
944 IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu);
945 DestroyMenu(This->hMenu);
946 This->hMenu = 0;
949 This->uState = SVUIA_DEACTIVATE;
953 /**********************************************************
954 * ShellView_OnActivate()
956 static LRESULT ShellView_OnActivate(IShellViewImpl * This, UINT uState)
957 { OLEMENUGROUPWIDTHS omw = { {0, 0, 0, 0, 0, 0} };
958 MENUITEMINFOA mii;
959 CHAR szText[MAX_PATH];
961 TRACE("%p uState=%x\n",This,uState);
963 /*don't do anything if the state isn't really changing */
964 if(This->uState == uState)
966 return S_OK;
969 ShellView_OnDeactivate(This);
971 /*only do This if we are active */
972 if(uState != SVUIA_DEACTIVATE)
974 /*merge the menus */
975 This->hMenu = CreateMenu();
977 if(This->hMenu)
979 IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw);
980 TRACE("-- after fnInsertMenusSB\n");
982 /*build the top level menu get the menu item's text*/
983 strcpy(szText,"dummy 31");
985 ZeroMemory(&mii, sizeof(mii));
986 mii.cbSize = sizeof(mii);
987 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
988 mii.fType = MFT_STRING;
989 mii.fState = MFS_ENABLED;
990 mii.dwTypeData = szText;
991 mii.hSubMenu = ShellView_BuildFileMenu(This);
993 /*insert our menu into the menu bar*/
994 if(mii.hSubMenu)
996 InsertMenuItemA(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii);
999 /*get the view menu so we can merge with it*/
1000 ZeroMemory(&mii, sizeof(mii));
1001 mii.cbSize = sizeof(mii);
1002 mii.fMask = MIIM_SUBMENU;
1004 if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii))
1006 ShellView_MergeViewMenu(This, mii.hSubMenu);
1009 /*add the items that should only be added if we have the focus*/
1010 if(SVUIA_ACTIVATE_FOCUS == uState)
1012 /*get the file menu so we can merge with it */
1013 ZeroMemory(&mii, sizeof(mii));
1014 mii.cbSize = sizeof(mii);
1015 mii.fMask = MIIM_SUBMENU;
1017 if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii))
1019 ShellView_MergeFileMenu(This, mii.hSubMenu);
1022 TRACE("-- before fnSetMenuSB\n");
1023 IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd);
1026 This->uState = uState;
1027 TRACE("--\n");
1028 return S_OK;
1031 /**********************************************************
1032 * ShellView_OnSetFocus()
1035 static LRESULT ShellView_OnSetFocus(IShellViewImpl * This)
1037 TRACE("%p\n",This);
1039 /* Tell the browser one of our windows has received the focus. This
1040 should always be done before merging menus (OnActivate merges the
1041 menus) if one of our windows has the focus.*/
1043 IShellBrowser_OnViewWindowActive(This->pShellBrowser,(IShellView*) This);
1044 ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS);
1046 /* Set the focus to the listview */
1047 SetFocus(This->hWndList);
1049 /* Notify the ICommDlgBrowser interface */
1050 OnStateChange(This,CDBOSC_SETFOCUS);
1052 return 0;
1055 /**********************************************************
1056 * ShellView_OnKillFocus()
1058 static LRESULT ShellView_OnKillFocus(IShellViewImpl * This)
1060 TRACE("(%p) stub\n",This);
1062 ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS);
1063 /* Notify the ICommDlgBrowser */
1064 OnStateChange(This,CDBOSC_KILLFOCUS);
1066 return 0;
1069 /**********************************************************
1070 * ShellView_OnCommand()
1072 * NOTES
1073 * the CmdID's are the ones from the context menu
1075 static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd)
1077 TRACE("(%p)->(0x%08lx 0x%08lx %p) stub\n",This, dwCmdID, dwCmd, hwndCmd);
1079 switch(dwCmdID)
1081 case FCIDM_SHVIEW_SMALLICON:
1082 This->FolderSettings.ViewMode = FVM_SMALLICON;
1083 SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK);
1084 CheckToolbar(This);
1085 break;
1087 case FCIDM_SHVIEW_BIGICON:
1088 This->FolderSettings.ViewMode = FVM_ICON;
1089 SetStyle (This, LVS_ICON, LVS_TYPEMASK);
1090 CheckToolbar(This);
1091 break;
1093 case FCIDM_SHVIEW_LISTVIEW:
1094 This->FolderSettings.ViewMode = FVM_LIST;
1095 SetStyle (This, LVS_LIST, LVS_TYPEMASK);
1096 CheckToolbar(This);
1097 break;
1099 case FCIDM_SHVIEW_REPORTVIEW:
1100 This->FolderSettings.ViewMode = FVM_DETAILS;
1101 SetStyle (This, LVS_REPORT, LVS_TYPEMASK);
1102 CheckToolbar(This);
1103 break;
1105 /* the menu-ID's for sorting are 0x30... see shrec.rc */
1106 case 0x30:
1107 case 0x31:
1108 case 0x32:
1109 case 0x33:
1110 This->ListViewSortInfo.nHeaderID = (LPARAM) (dwCmdID - 0x30);
1111 This->ListViewSortInfo.bIsAscending = TRUE;
1112 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1113 ListView_SortItems(This->hWndList, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1114 break;
1116 default:
1117 TRACE("-- COMMAND 0x%04lx unhandled\n", dwCmdID);
1119 return 0;
1122 /**********************************************************
1123 * ShellView_OnNotify()
1126 static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
1127 { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
1128 NMLVDISPINFOA *lpdi = (NMLVDISPINFOA *)lpnmh;
1129 LPITEMIDLIST pidl;
1131 TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code);
1133 switch(lpnmh->code)
1135 case NM_SETFOCUS:
1136 TRACE("-- NM_SETFOCUS %p\n",This);
1137 ShellView_OnSetFocus(This);
1138 break;
1140 case NM_KILLFOCUS:
1141 TRACE("-- NM_KILLFOCUS %p\n",This);
1142 ShellView_OnDeactivate(This);
1143 /* Notify the ICommDlgBrowser interface */
1144 OnStateChange(This,CDBOSC_KILLFOCUS);
1145 break;
1147 case HDN_ENDTRACKA:
1148 TRACE("-- HDN_ENDTRACKA %p\n",This);
1149 /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
1150 nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
1151 break;
1153 case LVN_DELETEITEM:
1154 TRACE("-- LVN_DELETEITEM %p\n",This);
1155 SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/
1156 break;
1158 case LVN_INSERTITEM:
1159 TRACE("-- LVN_INSERTITEM (STUB)%p\n",This);
1160 break;
1162 case LVN_ITEMACTIVATE:
1163 TRACE("-- LVN_ITEMACTIVATE %p\n",This);
1164 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1165 ShellView_DoContextMenu(This, 0, 0, TRUE);
1166 break;
1168 case LVN_COLUMNCLICK:
1169 This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem;
1170 if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID)
1172 This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending;
1174 else
1176 This->ListViewSortInfo.bIsAscending = TRUE;
1178 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1180 ListView_SortItems(lpnmlv->hdr.hwndFrom, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1181 break;
1183 case LVN_GETDISPINFOA:
1184 case LVN_GETDISPINFOW:
1185 TRACE("-- LVN_GETDISPINFO %p\n",This);
1186 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1188 if(lpdi->item.mask & LVIF_TEXT) /* text requested */
1190 if (This->pSF2Parent)
1192 SHELLDETAILS sd;
1193 IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
1194 if (lpnmh->code == LVN_GETDISPINFOA)
1196 StrRetToStrNA( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1197 TRACE("-- text=%s\n",lpdi->item.pszText);
1199 else /* LVN_GETDISPINFOW */
1201 StrRetToStrNW( ((NMLVDISPINFOW *)lpdi)->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1202 TRACE("-- text=%s\n",debugstr_w((WCHAR*)(lpdi->item.pszText)));
1205 else
1207 FIXME("no SF2\n");
1210 if(lpdi->item.mask & LVIF_IMAGE) /* image requested */
1212 lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
1214 break;
1216 case LVN_ITEMCHANGED:
1217 TRACE("-- LVN_ITEMCHANGED %p\n",This);
1218 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1219 break;
1221 case LVN_BEGINDRAG:
1222 case LVN_BEGINRDRAG:
1223 TRACE("-- LVN_BEGINDRAG\n");
1225 if (ShellView_GetSelections(This))
1227 IDataObject * pda;
1228 DWORD dwAttributes = SFGAO_CANLINK;
1229 DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
1231 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
1233 IDropSource * pds = (IDropSource*)&(This->lpvtblDropSource); /* own DropSource interface */
1235 if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, (LPCITEMIDLIST*)This->apidl, &dwAttributes)))
1237 if (dwAttributes & SFGAO_CANLINK)
1239 dwEffect |= DROPEFFECT_LINK;
1243 if (pds)
1245 DWORD dwEffect;
1246 DoDragDrop(pda, pds, dwEffect, &dwEffect);
1248 IDataObject_Release(pda);
1251 break;
1253 case LVN_BEGINLABELEDITA:
1255 DWORD dwAttr = SFGAO_CANRENAME;
1256 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1258 TRACE("-- LVN_BEGINLABELEDITA %p\n",This);
1260 IShellFolder_GetAttributesOf(This->pSFParent, 1, (LPCITEMIDLIST*)&pidl, &dwAttr);
1261 if (SFGAO_CANRENAME & dwAttr)
1263 return FALSE;
1265 return TRUE;
1267 break;
1269 case LVN_ENDLABELEDITA:
1271 TRACE("-- LVN_ENDLABELEDITA %p\n",This);
1272 if (lpdi->item.pszText)
1274 HRESULT hr;
1275 WCHAR wszNewName[MAX_PATH];
1276 LVITEMA lvItem;
1278 ZeroMemory(&lvItem, sizeof(LVITEMA));
1279 lvItem.iItem = lpdi->item.iItem;
1280 lvItem.mask = LVIF_PARAM;
1281 ListView_GetItemA(This->hWndList, &lvItem);
1283 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1284 if (!MultiByteToWideChar( CP_ACP, 0, lpdi->item.pszText, -1, wszNewName, MAX_PATH ))
1285 wszNewName[MAX_PATH-1] = 0;
1286 hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, wszNewName, SHGDN_INFOLDER, &pidl);
1288 if(SUCCEEDED(hr) && pidl)
1290 lvItem.mask = LVIF_PARAM;
1291 lvItem.lParam = (LPARAM)pidl;
1292 ListView_SetItemA(This->hWndList, &lvItem);
1293 return TRUE;
1296 return FALSE;
1298 break;
1300 case LVN_KEYDOWN:
1302 /* MSG msg;
1303 msg.hwnd = This->hWnd;
1304 msg.message = WM_KEYDOWN;
1305 msg.wParam = plvKeyDown->wVKey;
1306 msg.lParam = 0;
1307 msg.time = 0;
1308 msg.pt = 0;*/
1310 LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
1312 /* initiate a rename of the selected file or directory */
1313 if(plvKeyDown->wVKey == VK_F2)
1315 /* see how many files are selected */
1316 int i = ListView_GetSelectedCount(This->hWndList);
1318 /* get selected item */
1319 if(i == 1)
1321 /* get selected item */
1322 i = ListView_GetNextItem(This->hWndList, -1,
1323 LVNI_SELECTED);
1325 ListView_EnsureVisible(This->hWndList, i, 0);
1326 ListView_EditLabelA(This->hWndList, i);
1329 #if 0
1330 TranslateAccelerator(This->hWnd, This->hAccel, &msg)
1331 #endif
1332 else if(plvKeyDown->wVKey == VK_DELETE)
1334 UINT i;
1335 int item_index;
1336 LVITEMA item;
1337 LPITEMIDLIST* pItems;
1338 ISFHelper *psfhlp;
1340 IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper,
1341 (LPVOID*)&psfhlp);
1343 if(!(i = ListView_GetSelectedCount(This->hWndList)))
1344 break;
1346 /* allocate memory for the pidl array */
1347 pItems = HeapAlloc(GetProcessHeap(), 0,
1348 sizeof(LPITEMIDLIST) * i);
1350 /* retrieve all selected items */
1351 i = 0;
1352 item_index = -1;
1353 while(ListView_GetSelectedCount(This->hWndList) > i)
1355 /* get selected item */
1356 item_index = ListView_GetNextItem(This->hWndList,
1357 item_index, LVNI_SELECTED);
1358 item.iItem = item_index;
1359 item.mask |= LVIF_PARAM;
1360 ListView_GetItemA(This->hWndList, &item);
1362 /* get item pidl */
1363 pItems[i] = (LPITEMIDLIST)item.lParam;
1365 i++;
1368 /* perform the item deletion */
1369 ISFHelper_DeleteItems(psfhlp, i, (LPCITEMIDLIST*)pItems);
1371 /* free pidl array memory */
1372 HeapFree(GetProcessHeap(), 0, pItems);
1374 else
1375 FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey);
1377 break;
1379 default:
1380 TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code);
1381 break;
1383 return 0;
1386 /**********************************************************
1387 * ShellView_OnChange()
1390 static LRESULT ShellView_OnChange(IShellViewImpl * This, LPITEMIDLIST * Pidls, LONG wEventId)
1393 TRACE("(%p)(%p,%p,0x%08lx)\n", This, Pidls[0], Pidls[1], wEventId);
1394 switch(wEventId)
1396 case SHCNE_MKDIR:
1397 case SHCNE_CREATE:
1398 LV_AddItem(This, Pidls[0]);
1399 break;
1400 case SHCNE_RMDIR:
1401 case SHCNE_DELETE:
1402 LV_DeleteItem(This, Pidls[0]);
1403 break;
1404 case SHCNE_RENAMEFOLDER:
1405 case SHCNE_RENAMEITEM:
1406 LV_RenameItem(This, Pidls[0], Pidls[1]);
1407 break;
1408 case SHCNE_UPDATEITEM:
1409 break;
1411 return TRUE;
1413 /**********************************************************
1414 * ShellView_WndProc
1417 static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1419 IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongA(hWnd, GWL_USERDATA);
1420 LPCREATESTRUCTA lpcs;
1422 TRACE("(hwnd=%p msg=%x wparm=%x lparm=%lx)\n",hWnd, uMessage, wParam, lParam);
1424 switch (uMessage)
1426 case WM_NCCREATE:
1427 lpcs = (LPCREATESTRUCTA)lParam;
1428 pThis = (IShellViewImpl*)(lpcs->lpCreateParams);
1429 SetWindowLongA(hWnd, GWL_USERDATA, (LONG)pThis);
1430 pThis->hWnd = hWnd; /*set the window handle*/
1431 break;
1433 case WM_SIZE: return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam));
1434 case WM_SETFOCUS: return ShellView_OnSetFocus(pThis);
1435 case WM_KILLFOCUS: return ShellView_OnKillFocus(pThis);
1436 case WM_CREATE: return ShellView_OnCreate(pThis);
1437 case WM_ACTIVATE: return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS);
1438 case WM_NOTIFY: return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam);
1439 case WM_COMMAND: return ShellView_OnCommand(pThis,
1440 GET_WM_COMMAND_ID(wParam, lParam),
1441 GET_WM_COMMAND_CMD(wParam, lParam),
1442 GET_WM_COMMAND_HWND(wParam, lParam));
1443 case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (LPITEMIDLIST*)wParam, (LONG)lParam);
1445 case WM_CONTEXTMENU: ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE);
1446 return 0;
1448 case WM_SHOWWINDOW: UpdateWindow(pThis->hWndList);
1449 break;
1451 case WM_GETDLGCODE: return SendMessageA(pThis->hWndList,uMessage,0,0);
1453 case WM_DESTROY:
1454 RevokeDragDrop(pThis->hWnd);
1455 SHChangeNotifyDeregister(pThis->hNotify);
1456 break;
1458 case WM_ERASEBKGND:
1459 if ((pThis->FolderSettings.fFlags & FWF_DESKTOP) ||
1460 (pThis->FolderSettings.fFlags & FWF_TRANSPARENT))
1461 return 1;
1462 break;
1465 return DefWindowProcA (hWnd, uMessage, wParam, lParam);
1467 /**********************************************************
1470 * The INTERFACE of the IShellView object
1473 **********************************************************
1474 * IShellView_QueryInterface
1476 static HRESULT WINAPI IShellView_fnQueryInterface(IShellView * iface,REFIID riid, LPVOID *ppvObj)
1478 ICOM_THIS(IShellViewImpl, iface);
1480 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1482 *ppvObj = NULL;
1484 if(IsEqualIID(riid, &IID_IUnknown))
1486 *ppvObj = This;
1488 else if(IsEqualIID(riid, &IID_IShellView))
1490 *ppvObj = (IShellView*)This;
1492 else if(IsEqualIID(riid, &IID_IOleCommandTarget))
1494 *ppvObj = (IOleCommandTarget*)&(This->lpvtblOleCommandTarget);
1496 else if(IsEqualIID(riid, &IID_IDropTarget))
1498 *ppvObj = (IDropTarget*)&(This->lpvtblDropTarget);
1500 else if(IsEqualIID(riid, &IID_IDropSource))
1502 *ppvObj = (IDropSource*)&(This->lpvtblDropSource);
1504 else if(IsEqualIID(riid, &IID_IViewObject))
1506 *ppvObj = (IViewObject*)&(This->lpvtblViewObject);
1509 if(*ppvObj)
1511 IUnknown_AddRef( (IUnknown*)*ppvObj );
1512 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1513 return S_OK;
1515 TRACE("-- Interface: E_NOINTERFACE\n");
1516 return E_NOINTERFACE;
1519 /**********************************************************
1520 * IShellView_AddRef
1522 static ULONG WINAPI IShellView_fnAddRef(IShellView * iface)
1524 ICOM_THIS(IShellViewImpl, iface);
1526 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1528 return ++(This->ref);
1530 /**********************************************************
1531 * IShellView_Release
1533 static ULONG WINAPI IShellView_fnRelease(IShellView * iface)
1535 ICOM_THIS(IShellViewImpl, iface);
1537 TRACE("(%p)->()\n",This);
1539 if (!--(This->ref))
1541 TRACE(" destroying IShellView(%p)\n",This);
1543 if(This->pSFParent)
1544 IShellFolder_Release(This->pSFParent);
1546 if(This->pSF2Parent)
1547 IShellFolder2_Release(This->pSF2Parent);
1549 if (This->apidl)
1550 SHFree(This->apidl);
1552 HeapFree(GetProcessHeap(),0,This);
1553 return 0;
1555 return This->ref;
1558 /**********************************************************
1559 * ShellView_GetWindow
1561 static HRESULT WINAPI IShellView_fnGetWindow(IShellView * iface,HWND * phWnd)
1563 ICOM_THIS(IShellViewImpl, iface);
1565 TRACE("(%p)\n",This);
1567 *phWnd = This->hWnd;
1569 return S_OK;
1572 static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView * iface,BOOL fEnterMode)
1574 ICOM_THIS(IShellViewImpl, iface);
1576 FIXME("(%p) stub\n",This);
1578 return E_NOTIMPL;
1581 /**********************************************************
1582 * IShellView_TranslateAccelerator
1584 * FIXME:
1585 * use the accel functions
1587 static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg)
1589 #if 0
1590 ICOM_THIS(IShellViewImpl, iface);
1592 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1593 #endif
1595 if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST))
1597 TRACE("-- key=0x04%x\n",lpmsg->wParam) ;
1599 return S_FALSE; /* not handled */
1602 static HRESULT WINAPI IShellView_fnEnableModeless(IShellView * iface,BOOL fEnable)
1604 ICOM_THIS(IShellViewImpl, iface);
1606 FIXME("(%p) stub\n",This);
1608 return E_NOTIMPL;
1611 static HRESULT WINAPI IShellView_fnUIActivate(IShellView * iface,UINT uState)
1613 ICOM_THIS(IShellViewImpl, iface);
1616 CHAR szName[MAX_PATH];
1618 LRESULT lResult;
1619 int nPartArray[1] = {-1};
1621 TRACE("(%p)->(state=%x) stub\n",This, uState);
1623 /*don't do anything if the state isn't really changing*/
1624 if(This->uState == uState)
1626 return S_OK;
1629 /*OnActivate handles the menu merging and internal state*/
1630 ShellView_OnActivate(This, uState);
1632 /*only do This if we are active*/
1633 if(uState != SVUIA_DEACTIVATE)
1637 GetFolderPath is not a method of IShellFolder
1638 IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1640 /* set the number of parts */
1641 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1642 (LPARAM)nPartArray, &lResult);
1644 /* set the text for the parts */
1646 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1647 0, (LPARAM)szName, &lResult);
1651 return S_OK;
1654 static HRESULT WINAPI IShellView_fnRefresh(IShellView * iface)
1656 ICOM_THIS(IShellViewImpl, iface);
1658 TRACE("(%p)\n",This);
1660 ListView_DeleteAllItems(This->hWndList);
1661 ShellView_FillList(This);
1663 return S_OK;
1666 static HRESULT WINAPI IShellView_fnCreateViewWindow(
1667 IShellView * iface,
1668 IShellView *lpPrevView,
1669 LPCFOLDERSETTINGS lpfs,
1670 IShellBrowser * psb,
1671 RECT * prcView,
1672 HWND *phWnd)
1674 ICOM_THIS(IShellViewImpl, iface);
1676 WNDCLASSA wc;
1677 *phWnd = 0;
1680 TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This, lpPrevView,lpfs, psb, prcView, phWnd);
1681 TRACE("-- vmode=%x flags=%x left=%li top=%li right=%li bottom=%li\n",lpfs->ViewMode, lpfs->fFlags ,prcView->left,prcView->top, prcView->right, prcView->bottom);
1683 /*set up the member variables*/
1684 This->pShellBrowser = psb;
1685 This->FolderSettings = *lpfs;
1687 /*get our parent window*/
1688 IShellBrowser_AddRef(This->pShellBrowser);
1689 IShellBrowser_GetWindow(This->pShellBrowser, &(This->hWndParent));
1691 /* try to get the ICommDlgBrowserInterface, adds a reference !!! */
1692 This->pCommDlgBrowser=NULL;
1693 if ( SUCCEEDED (IShellBrowser_QueryInterface( This->pShellBrowser,
1694 (REFIID)&IID_ICommDlgBrowser, (LPVOID*) &This->pCommDlgBrowser)))
1696 TRACE("-- CommDlgBrowser\n");
1699 /*if our window class has not been registered, then do so*/
1700 if(!GetClassInfoA(shell32_hInstance, SV_CLASS_NAME, &wc))
1702 ZeroMemory(&wc, sizeof(wc));
1703 wc.style = CS_HREDRAW | CS_VREDRAW;
1704 wc.lpfnWndProc = (WNDPROC) ShellView_WndProc;
1705 wc.cbClsExtra = 0;
1706 wc.cbWndExtra = 0;
1707 wc.hInstance = shell32_hInstance;
1708 wc.hIcon = 0;
1709 wc.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW);
1710 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
1711 wc.lpszMenuName = NULL;
1712 wc.lpszClassName = SV_CLASS_NAME;
1714 if(!RegisterClassA(&wc))
1715 return E_FAIL;
1718 *phWnd = CreateWindowExA(0,
1719 SV_CLASS_NAME,
1720 NULL,
1721 WS_CHILD | WS_VISIBLE | WS_TABSTOP,
1722 prcView->left,
1723 prcView->top,
1724 prcView->right - prcView->left,
1725 prcView->bottom - prcView->top,
1726 This->hWndParent,
1728 shell32_hInstance,
1729 (LPVOID)This);
1731 CheckToolbar(This);
1733 if(!*phWnd) return E_FAIL;
1735 return S_OK;
1738 static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView * iface)
1740 ICOM_THIS(IShellViewImpl, iface);
1742 TRACE("(%p)\n",This);
1744 /*Make absolutely sure all our UI is cleaned up.*/
1745 IShellView_UIActivate((IShellView*)This, SVUIA_DEACTIVATE);
1747 if(This->hMenu)
1749 DestroyMenu(This->hMenu);
1752 DestroyWindow(This->hWnd);
1753 if(This->pShellBrowser) IShellBrowser_Release(This->pShellBrowser);
1754 if(This->pCommDlgBrowser) ICommDlgBrowser_Release(This->pCommDlgBrowser);
1757 return S_OK;
1760 static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView * iface, LPFOLDERSETTINGS lpfs)
1762 ICOM_THIS(IShellViewImpl, iface);
1764 TRACE("(%p)->(%p) vmode=%x flags=%x\n",This, lpfs,
1765 This->FolderSettings.ViewMode, This->FolderSettings.fFlags);
1767 if (!lpfs) return E_INVALIDARG;
1769 *lpfs = This->FolderSettings;
1770 return NOERROR;
1773 static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView * iface, DWORD dwReserved,LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
1775 ICOM_THIS(IShellViewImpl, iface);
1777 FIXME("(%p) stub\n",This);
1779 return E_NOTIMPL;
1782 static HRESULT WINAPI IShellView_fnSaveViewState(IShellView * iface)
1784 ICOM_THIS(IShellViewImpl, iface);
1786 FIXME("(%p) stub\n",This);
1788 return S_OK;
1791 static HRESULT WINAPI IShellView_fnSelectItem(
1792 IShellView * iface,
1793 LPCITEMIDLIST pidl,
1794 UINT uFlags)
1796 ICOM_THIS(IShellViewImpl, iface);
1797 int i;
1799 TRACE("(%p)->(pidl=%p, 0x%08x) stub\n",This, pidl, uFlags);
1801 i = LV_FindItemByPidl(This, pidl);
1803 if (i != -1)
1805 LVITEMA lvItem;
1807 if(uFlags & SVSI_ENSUREVISIBLE)
1808 ListView_EnsureVisible(This->hWndList, i, 0);
1810 ZeroMemory(&lvItem, sizeof(LVITEMA));
1811 lvItem.mask = LVIF_STATE;
1812 lvItem.iItem = 0;
1814 while(ListView_GetItemA(This->hWndList, &lvItem))
1816 if (lvItem.iItem == i)
1818 if (uFlags & SVSI_SELECT)
1819 lvItem.state |= LVIS_SELECTED;
1820 else
1821 lvItem.state &= ~LVIS_SELECTED;
1823 if(uFlags & SVSI_FOCUSED)
1824 lvItem.state &= ~LVIS_FOCUSED;
1826 else
1828 if (uFlags & SVSI_DESELECTOTHERS)
1829 lvItem.state &= ~LVIS_SELECTED;
1831 ListView_SetItemA(This->hWndList, &lvItem);
1832 lvItem.iItem++;
1836 if(uFlags & SVSI_EDIT)
1837 ListView_EditLabelA(This->hWndList, i);
1840 return S_OK;
1843 static HRESULT WINAPI IShellView_fnGetItemObject(IShellView * iface, UINT uItem, REFIID riid, LPVOID *ppvOut)
1845 ICOM_THIS(IShellViewImpl, iface);
1847 TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This, uItem, debugstr_guid(riid), ppvOut);
1849 *ppvOut = NULL;
1851 switch(uItem)
1853 case SVGIO_BACKGROUND:
1854 *ppvOut = ISvBgCm_Constructor(This->pSFParent);
1855 break;
1857 case SVGIO_SELECTION:
1858 ShellView_GetSelections(This);
1859 IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, riid, 0, ppvOut);
1860 break;
1862 TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
1864 if(!*ppvOut) return E_OUTOFMEMORY;
1866 return S_OK;
1869 static struct ICOM_VTABLE(IShellView) svvt =
1871 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1872 IShellView_fnQueryInterface,
1873 IShellView_fnAddRef,
1874 IShellView_fnRelease,
1875 IShellView_fnGetWindow,
1876 IShellView_fnContextSensitiveHelp,
1877 IShellView_fnTranslateAccelerator,
1878 IShellView_fnEnableModeless,
1879 IShellView_fnUIActivate,
1880 IShellView_fnRefresh,
1881 IShellView_fnCreateViewWindow,
1882 IShellView_fnDestroyViewWindow,
1883 IShellView_fnGetCurrentInfo,
1884 IShellView_fnAddPropertySheetPages,
1885 IShellView_fnSaveViewState,
1886 IShellView_fnSelectItem,
1887 IShellView_fnGetItemObject
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 UINT i;
1937 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1939 FIXME("(%p)->(%p(%s) 0x%08lx %p %p\n",
1940 This, pguidCmdGroup, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
1942 if (!prgCmds)
1943 return E_POINTER;
1944 for (i = 0; i < cCmds; i++)
1946 FIXME("\tprgCmds[%d].cmdID = %ld\n", i, prgCmds[i].cmdID);
1947 prgCmds[i].cmdf = 0;
1949 return OLECMDERR_E_UNKNOWNGROUP;
1952 /**********************************************************
1953 * ISVOleCmdTarget_Exec (IOleCommandTarget)
1955 * nCmdID is the OLECMDID_* enumeration
1957 static HRESULT WINAPI ISVOleCmdTarget_Exec(
1958 IOleCommandTarget *iface,
1959 const GUID* pguidCmdGroup,
1960 DWORD nCmdID,
1961 DWORD nCmdexecopt,
1962 VARIANT* pvaIn,
1963 VARIANT* pvaOut)
1965 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1967 FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08lx Opt:0x%08lx %p %p)\n",
1968 This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, pvaIn, pvaOut);
1970 if (IsEqualIID(pguidCmdGroup, &CGID_Explorer) &&
1971 (nCmdID == 0x29) &&
1972 (nCmdexecopt == 4) && pvaOut)
1973 return S_OK;
1974 if (IsEqualIID(pguidCmdGroup, &CGID_ShellDocView) &&
1975 (nCmdID == 9) &&
1976 (nCmdexecopt == 0))
1977 return 1;
1979 return OLECMDERR_E_UNKNOWNGROUP;
1982 static ICOM_VTABLE(IOleCommandTarget) ctvt =
1984 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1985 ISVOleCmdTarget_QueryInterface,
1986 ISVOleCmdTarget_AddRef,
1987 ISVOleCmdTarget_Release,
1988 ISVOleCmdTarget_QueryStatus,
1989 ISVOleCmdTarget_Exec
1992 /**********************************************************
1993 * ISVDropTarget implementation
1996 static HRESULT WINAPI ISVDropTarget_QueryInterface(
1997 IDropTarget *iface,
1998 REFIID riid,
1999 LPVOID *ppvObj)
2001 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2003 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2005 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2008 static ULONG WINAPI ISVDropTarget_AddRef( IDropTarget *iface)
2010 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2012 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2014 return IShellFolder_AddRef((IShellFolder*)This);
2017 static ULONG WINAPI ISVDropTarget_Release( IDropTarget *iface)
2019 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2021 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2023 return IShellFolder_Release((IShellFolder*)This);
2026 static HRESULT WINAPI ISVDropTarget_DragEnter(
2027 IDropTarget *iface,
2028 IDataObject *pDataObject,
2029 DWORD grfKeyState,
2030 POINTL pt,
2031 DWORD *pdwEffect)
2034 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2036 FIXME("Stub: This=%p, DataObject=%p\n",This,pDataObject);
2038 return E_NOTIMPL;
2041 static HRESULT WINAPI ISVDropTarget_DragOver(
2042 IDropTarget *iface,
2043 DWORD grfKeyState,
2044 POINTL pt,
2045 DWORD *pdwEffect)
2047 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2049 FIXME("Stub: This=%p\n",This);
2051 return E_NOTIMPL;
2054 static HRESULT WINAPI ISVDropTarget_DragLeave(
2055 IDropTarget *iface)
2057 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2059 FIXME("Stub: This=%p\n",This);
2061 return E_NOTIMPL;
2064 static HRESULT WINAPI ISVDropTarget_Drop(
2065 IDropTarget *iface,
2066 IDataObject* pDataObject,
2067 DWORD grfKeyState,
2068 POINTL pt,
2069 DWORD *pdwEffect)
2071 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2073 FIXME("Stub: This=%p\n",This);
2075 return E_NOTIMPL;
2078 static struct ICOM_VTABLE(IDropTarget) dtvt =
2080 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2081 ISVDropTarget_QueryInterface,
2082 ISVDropTarget_AddRef,
2083 ISVDropTarget_Release,
2084 ISVDropTarget_DragEnter,
2085 ISVDropTarget_DragOver,
2086 ISVDropTarget_DragLeave,
2087 ISVDropTarget_Drop
2090 /**********************************************************
2091 * ISVDropSource implementation
2094 static HRESULT WINAPI ISVDropSource_QueryInterface(
2095 IDropSource *iface,
2096 REFIID riid,
2097 LPVOID *ppvObj)
2099 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2101 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2103 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2106 static ULONG WINAPI ISVDropSource_AddRef( IDropSource *iface)
2108 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2110 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2112 return IShellFolder_AddRef((IShellFolder*)This);
2115 static ULONG WINAPI ISVDropSource_Release( IDropSource *iface)
2117 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2119 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2121 return IShellFolder_Release((IShellFolder*)This);
2123 static HRESULT WINAPI ISVDropSource_QueryContinueDrag(
2124 IDropSource *iface,
2125 BOOL fEscapePressed,
2126 DWORD grfKeyState)
2128 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2129 TRACE("(%p)\n",This);
2131 if (fEscapePressed)
2132 return DRAGDROP_S_CANCEL;
2133 else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
2134 return DRAGDROP_S_DROP;
2135 else
2136 return NOERROR;
2139 static HRESULT WINAPI ISVDropSource_GiveFeedback(
2140 IDropSource *iface,
2141 DWORD dwEffect)
2143 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2144 TRACE("(%p)\n",This);
2146 return DRAGDROP_S_USEDEFAULTCURSORS;
2149 static struct ICOM_VTABLE(IDropSource) dsvt =
2151 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2152 ISVDropSource_QueryInterface,
2153 ISVDropSource_AddRef,
2154 ISVDropSource_Release,
2155 ISVDropSource_QueryContinueDrag,
2156 ISVDropSource_GiveFeedback
2158 /**********************************************************
2159 * ISVViewObject implementation
2162 static HRESULT WINAPI ISVViewObject_QueryInterface(
2163 IViewObject *iface,
2164 REFIID riid,
2165 LPVOID *ppvObj)
2167 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2169 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2171 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2174 static ULONG WINAPI ISVViewObject_AddRef( IViewObject *iface)
2176 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2178 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2180 return IShellFolder_AddRef((IShellFolder*)This);
2183 static ULONG WINAPI ISVViewObject_Release( IViewObject *iface)
2185 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2187 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2189 return IShellFolder_Release((IShellFolder*)This);
2192 static HRESULT WINAPI ISVViewObject_Draw(
2193 IViewObject *iface,
2194 DWORD dwDrawAspect,
2195 LONG lindex,
2196 void* pvAspect,
2197 DVTARGETDEVICE* ptd,
2198 HDC hdcTargetDev,
2199 HDC hdcDraw,
2200 LPCRECTL lprcBounds,
2201 LPCRECTL lprcWBounds,
2202 BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue),
2203 DWORD dwContinue)
2206 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2208 FIXME("Stub: This=%p\n",This);
2210 return E_NOTIMPL;
2212 static HRESULT WINAPI ISVViewObject_GetColorSet(
2213 IViewObject *iface,
2214 DWORD dwDrawAspect,
2215 LONG lindex,
2216 void *pvAspect,
2217 DVTARGETDEVICE* ptd,
2218 HDC hicTargetDevice,
2219 LOGPALETTE** ppColorSet)
2222 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2224 FIXME("Stub: This=%p\n",This);
2226 return E_NOTIMPL;
2228 static HRESULT WINAPI ISVViewObject_Freeze(
2229 IViewObject *iface,
2230 DWORD dwDrawAspect,
2231 LONG lindex,
2232 void* pvAspect,
2233 DWORD* pdwFreeze)
2236 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2238 FIXME("Stub: This=%p\n",This);
2240 return E_NOTIMPL;
2242 static HRESULT WINAPI ISVViewObject_Unfreeze(
2243 IViewObject *iface,
2244 DWORD dwFreeze)
2247 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2249 FIXME("Stub: This=%p\n",This);
2251 return E_NOTIMPL;
2253 static HRESULT WINAPI ISVViewObject_SetAdvise(
2254 IViewObject *iface,
2255 DWORD aspects,
2256 DWORD advf,
2257 IAdviseSink* pAdvSink)
2260 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2262 FIXME("Stub: This=%p\n",This);
2264 return E_NOTIMPL;
2266 static HRESULT WINAPI ISVViewObject_GetAdvise(
2267 IViewObject *iface,
2268 DWORD* pAspects,
2269 DWORD* pAdvf,
2270 IAdviseSink** ppAdvSink)
2273 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2275 FIXME("Stub: This=%p\n",This);
2277 return E_NOTIMPL;
2281 static struct ICOM_VTABLE(IViewObject) vovt =
2283 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2284 ISVViewObject_QueryInterface,
2285 ISVViewObject_AddRef,
2286 ISVViewObject_Release,
2287 ISVViewObject_Draw,
2288 ISVViewObject_GetColorSet,
2289 ISVViewObject_Freeze,
2290 ISVViewObject_Unfreeze,
2291 ISVViewObject_SetAdvise,
2292 ISVViewObject_GetAdvise