msxml3/tests: Added invalid host XHR tests.
[wine.git] / dlls / shell32 / shlview.c
blobc0c027fbd3a2584c99c234e82f5ea33597bee761
1 /*
2 * ShellView
4 * Copyright 1998,1999 <juergen.schmied@debitel.net>
6 * This is the view visualizing the data provided 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * FIXME: The order by part of the background context menu should be
24 * built according to the columns shown.
26 * FIXME: Load/Save the view state from/into the stream provided 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 #define CINTERFACE
47 #define COBJMACROS
48 #define NONAMELESSUNION
50 #include "windef.h"
51 #include "winerror.h"
52 #include "winbase.h"
53 #include "winnls.h"
54 #include "objbase.h"
55 #include "servprov.h"
56 #include "shlguid.h"
57 #include "wingdi.h"
58 #include "winuser.h"
59 #include "shlobj.h"
60 #include "shobjidl.h"
61 #include "undocshell.h"
62 #include "shresdef.h"
63 #include "wine/debug.h"
65 #include "docobj.h"
66 #include "pidl.h"
67 #include "shell32_main.h"
68 #include "shellfolder.h"
70 WINE_DEFAULT_DEBUG_CHANNEL(shell);
72 static const WCHAR SV_CLASS_NAME[] = {'S','H','E','L','L','D','L','L','_','D','e','f','V','i','e','w',0};
74 typedef struct
75 { BOOL bIsAscending;
76 INT nHeaderID;
77 INT nLastHeaderID;
78 }LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO;
80 typedef struct
82 IShellView3 IShellView3_iface;
83 IOleCommandTarget IOleCommandTarget_iface;
84 IDropTarget IDropTarget_iface;
85 IDropSource IDropSource_iface;
86 IViewObject IViewObject_iface;
87 IFolderView2 IFolderView2_iface;
88 IShellFolderView IShellFolderView_iface;
89 IShellFolderViewDual3 IShellFolderViewDual3_iface;
90 LONG ref;
91 IShellFolder* pSFParent;
92 IShellFolder2* pSF2Parent;
93 IShellBrowser* pShellBrowser;
94 ICommDlgBrowser* pCommDlgBrowser;
95 HWND hWnd; /* SHELLDLL_DefView */
96 HWND hWndList; /* ListView control */
97 HWND hWndParent;
98 FOLDERSETTINGS FolderSettings;
99 HMENU hMenu;
100 UINT uState;
101 UINT cidl;
102 LPITEMIDLIST *apidl;
103 LISTVIEW_SORT_INFO ListViewSortInfo;
104 ULONG hNotify; /* change notification handle */
105 HANDLE hAccel;
106 DWORD dwAspects;
107 DWORD dwAdvf;
108 IAdviseSink *pAdvSink;
109 IDropTarget* pCurDropTarget; /* The sub-item, which is currently dragged over */
110 IDataObject* pCurDataObject; /* The dragged data-object */
111 LONG iDragOverItem; /* Dragged over item's index, iff pCurDropTarget != NULL */
112 UINT cScrollDelay; /* Send a WM_*SCROLL msg every 250 ms during drag-scroll */
113 POINT ptLastMousePos; /* Mouse position at last DragOver call */
114 UINT columns; /* Number of shell folder columns */
115 } IShellViewImpl;
117 static inline IShellViewImpl *impl_from_IShellView3(IShellView3 *iface)
119 return CONTAINING_RECORD(iface, IShellViewImpl, IShellView3_iface);
122 static inline IShellViewImpl *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
124 return CONTAINING_RECORD(iface, IShellViewImpl, IOleCommandTarget_iface);
127 static inline IShellViewImpl *impl_from_IDropTarget(IDropTarget *iface)
129 return CONTAINING_RECORD(iface, IShellViewImpl, IDropTarget_iface);
132 static inline IShellViewImpl *impl_from_IDropSource(IDropSource *iface)
134 return CONTAINING_RECORD(iface, IShellViewImpl, IDropSource_iface);
137 static inline IShellViewImpl *impl_from_IViewObject(IViewObject *iface)
139 return CONTAINING_RECORD(iface, IShellViewImpl, IViewObject_iface);
142 static inline IShellViewImpl *impl_from_IFolderView2(IFolderView2 *iface)
144 return CONTAINING_RECORD(iface, IShellViewImpl, IFolderView2_iface);
147 static inline IShellViewImpl *impl_from_IShellFolderView(IShellFolderView *iface)
149 return CONTAINING_RECORD(iface, IShellViewImpl, IShellFolderView_iface);
152 static inline IShellViewImpl *impl_from_IShellFolderViewDual3(IShellFolderViewDual3 *iface)
154 return CONTAINING_RECORD(iface, IShellViewImpl, IShellFolderViewDual3_iface);
157 /* ListView Header IDs */
158 #define LISTVIEW_COLUMN_NAME 0
159 #define LISTVIEW_COLUMN_SIZE 1
160 #define LISTVIEW_COLUMN_TYPE 2
161 #define LISTVIEW_COLUMN_TIME 3
162 #define LISTVIEW_COLUMN_ATTRIB 4
164 /*menu items */
165 #define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500)
166 #define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501)
167 #define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502)
169 #define ID_LISTVIEW 1
171 #define SHV_CHANGE_NOTIFY WM_USER + 0x1111
173 /*windowsx.h */
174 #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
175 #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
176 #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
179 Items merged into the toolbar and the filemenu
181 typedef struct
182 { int idCommand;
183 int iImage;
184 int idButtonString;
185 int idMenuString;
186 BYTE bState;
187 BYTE bStyle;
188 } MYTOOLINFO, *LPMYTOOLINFO;
190 static const MYTOOLINFO Tools[] =
192 { FCIDM_SHVIEW_BIGICON, 0, 0, IDS_VIEW_LARGE, TBSTATE_ENABLED, BTNS_BUTTON },
193 { FCIDM_SHVIEW_SMALLICON, 0, 0, IDS_VIEW_SMALL, TBSTATE_ENABLED, BTNS_BUTTON },
194 { FCIDM_SHVIEW_LISTVIEW, 0, 0, IDS_VIEW_LIST, TBSTATE_ENABLED, BTNS_BUTTON },
195 { FCIDM_SHVIEW_REPORTVIEW, 0, 0, IDS_VIEW_DETAILS, TBSTATE_ENABLED, BTNS_BUTTON },
196 { -1, 0, 0, 0, 0, 0}
199 typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
201 /**********************************************************
203 * ##### helperfunctions for communication with ICommDlgBrowser #####
205 static BOOL IsInCommDlg(IShellViewImpl * This)
207 return This->pCommDlgBrowser != NULL;
210 static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl)
212 HRESULT ret = S_OK;
214 if (IsInCommDlg(This))
216 TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
217 ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView *)&This->IShellView3_iface, pidl);
218 TRACE("-- returns 0x%08x\n", ret);
221 return ret;
224 static HRESULT OnDefaultCommand(IShellViewImpl * This)
226 HRESULT ret = S_FALSE;
228 if (IsInCommDlg(This))
230 TRACE("ICommDlgBrowser::OnDefaultCommand\n");
231 ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView *)&This->IShellView3_iface);
232 TRACE("-- returns 0x%08x\n", ret);
235 return ret;
238 static HRESULT OnStateChange(IShellViewImpl * This, UINT change)
240 HRESULT ret = S_FALSE;
242 if (IsInCommDlg(This))
244 TRACE("ICommDlgBrowser::OnStateChange change=%d\n", change);
245 ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView *)&This->IShellView3_iface, change);
246 TRACE("-- returns 0x%08x\n", ret);
249 return ret;
252 /**********************************************************
253 * set the toolbar of the filedialog buttons
255 * - activates the buttons from the shellbrowser according to
256 * the view state
258 static void CheckToolbar(IShellViewImpl * This)
260 LRESULT result;
262 TRACE("\n");
264 if (IsInCommDlg(This))
266 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
267 FCIDM_TB_SMALLICON, This->FolderSettings.ViewMode == FVM_LIST, &result);
268 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
269 FCIDM_TB_REPORTVIEW, This->FolderSettings.ViewMode == FVM_DETAILS, &result);
270 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
271 FCIDM_TB_SMALLICON, TRUE, &result);
272 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
273 FCIDM_TB_REPORTVIEW, TRUE, &result);
277 /**********************************************************
279 * ##### helperfunctions for initializing the view #####
281 /**********************************************************
282 * change the style of the listview control
284 static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove)
286 DWORD tmpstyle;
288 TRACE("(%p)\n", This);
290 tmpstyle = GetWindowLongW(This->hWndList, GWL_STYLE);
291 SetWindowLongW(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove));
294 static DWORD ViewModeToListStyle(UINT ViewMode)
296 DWORD dwStyle;
298 TRACE("%d\n", ViewMode);
300 switch (ViewMode)
302 case FVM_ICON: dwStyle = LVS_ICON; break;
303 case FVM_DETAILS: dwStyle = LVS_REPORT; break;
304 case FVM_SMALLICON: dwStyle = LVS_SMALLICON; break;
305 case FVM_LIST: dwStyle = LVS_LIST; break;
306 default:
308 FIXME("ViewMode %d not implemented\n", ViewMode);
309 dwStyle = LVS_LIST;
310 break;
314 return dwStyle;
317 /**********************************************************
318 * ShellView_CreateList()
320 * - creates the list view window
322 static BOOL ShellView_CreateList (IShellViewImpl * This)
323 { DWORD dwStyle, dwExStyle;
325 TRACE("%p\n",This);
327 dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
328 LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_AUTOARRANGE;
329 dwExStyle = WS_EX_CLIENTEDGE;
331 dwStyle |= ViewModeToListStyle(This->FolderSettings.ViewMode);
333 if (This->FolderSettings.fFlags & FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE;
334 if (This->FolderSettings.fFlags & FWF_DESKTOP)
335 This->FolderSettings.fFlags |= FWF_NOCLIENTEDGE | FWF_NOSCROLL;
336 if (This->FolderSettings.fFlags & FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL;
337 if (This->FolderSettings.fFlags & FWF_NOCLIENTEDGE)
338 dwExStyle &= ~WS_EX_CLIENTEDGE;
340 This->hWndList=CreateWindowExW( dwExStyle,
341 WC_LISTVIEWW,
342 NULL,
343 dwStyle,
344 0,0,0,0,
345 This->hWnd,
346 (HMENU)ID_LISTVIEW,
347 shell32_hInstance,
348 NULL);
350 if(!This->hWndList)
351 return FALSE;
353 This->ListViewSortInfo.bIsAscending = TRUE;
354 This->ListViewSortInfo.nHeaderID = -1;
355 This->ListViewSortInfo.nLastHeaderID = -1;
357 if (This->FolderSettings.fFlags & FWF_DESKTOP) {
359 * FIXME: look at the registry value
360 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ListviewShadow
361 * and activate drop shadows if necessary
363 if (0)
364 SendMessageW(This->hWndList, LVM_SETTEXTBKCOLOR, 0, CLR_NONE);
365 else
366 SendMessageW(This->hWndList, LVM_SETTEXTBKCOLOR, 0, GetSysColor(COLOR_DESKTOP));
368 SendMessageW(This->hWndList, LVM_SETTEXTCOLOR, 0, RGB(255,255,255));
371 /* UpdateShellSettings(); */
372 return TRUE;
375 /**********************************************************
376 * ShellView_InitList()
378 * - adds all needed columns to the shellview
380 static void ShellView_InitList(IShellViewImpl *This)
382 IShellDetails *details = NULL;
383 HIMAGELIST big_icons, small_icons;
384 LVCOLUMNW lvColumn;
385 SHELLDETAILS sd;
386 WCHAR nameW[50];
387 HRESULT hr;
388 HFONT list_font, old_font;
389 HDC list_dc;
390 TEXTMETRICW tm;
392 TRACE("(%p)\n", This);
394 Shell_GetImageLists( &big_icons, &small_icons );
395 SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0);
396 SendMessageW(This->hWndList, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)small_icons);
397 SendMessageW(This->hWndList, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)big_icons);
399 lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
400 lvColumn.pszText = nameW;
402 if (!This->pSF2Parent)
404 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IShellDetails, (void**)&details);
405 if (hr != S_OK)
407 WARN("IShellFolder2/IShellDetails not supported\n");
408 return;
412 list_font = (HFONT)SendMessageW(This->hWndList, WM_GETFONT, 0, 0);
413 list_dc = GetDC(This->hWndList);
414 old_font = SelectObject(list_dc, list_font);
415 GetTextMetricsW(list_dc, &tm);
416 SelectObject(list_dc, old_font);
417 ReleaseDC(This->hWndList, list_dc);
419 for (This->columns = 0;; This->columns++)
421 if (This->pSF2Parent)
422 hr = IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, This->columns, &sd);
423 else
424 hr = IShellDetails_GetDetailsOf(details, NULL, This->columns, &sd);
425 if (FAILED(hr)) break;
427 lvColumn.fmt = sd.fmt;
428 lvColumn.cx = MulDiv(sd.cxChar, tm.tmAveCharWidth * 3, 2); /* chars->pixel */
429 StrRetToStrNW(nameW, ARRAY_SIZE(nameW), &sd.str, NULL);
430 SendMessageW(This->hWndList, LVM_INSERTCOLUMNW, This->columns, (LPARAM)&lvColumn);
433 if (details) IShellDetails_Release(details);
436 /* LVM_SORTITEMS callback used when initially inserting items */
437 static INT CALLBACK ShellView_CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
439 LPITEMIDLIST pidl1 = (LPITEMIDLIST)lParam1;
440 LPITEMIDLIST pidl2 = (LPITEMIDLIST)lParam2;
441 IShellFolder *folder = (IShellFolder *)lpData;
442 int ret;
444 TRACE("pidl1=%p, pidl2=%p, shellfolder=%p\n", pidl1, pidl2, folder);
446 ret = (SHORT)HRESULT_CODE(IShellFolder_CompareIDs(folder, 0, pidl1, pidl2));
447 TRACE("ret=%i\n", ret);
448 return ret;
451 /*************************************************************************
452 * ShellView_ListViewCompareItems
454 * Compare Function for the Listview (FileOpen Dialog)
456 * PARAMS
457 * lParam1 [I] the first ItemIdList to compare with
458 * lParam2 [I] the second ItemIdList to compare with
459 * lpData [I] The column ID for the header Ctrl to process
461 * RETURNS
462 * A negative value if the first item should precede the second,
463 * a positive value if the first item should follow the second,
464 * or zero if the two items are equivalent
466 * NOTES
467 * FIXME: function does what ShellView_CompareItems is supposed to do.
468 * unify it and figure out how to use the undocumented first parameter
469 * of IShellFolder_CompareIDs to do the job this function does and
470 * move this code to IShellFolder.
471 * make LISTVIEW_SORT_INFO obsolete
472 * the way this function works is only usable if we had only
473 * filesystemfolders (25/10/99 jsch)
475 static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
477 INT nDiff=0;
478 FILETIME fd1, fd2;
479 char strName1[MAX_PATH], strName2[MAX_PATH];
480 BOOL bIsFolder1, bIsFolder2,bIsBothFolder;
481 LPITEMIDLIST pItemIdList1 = lParam1;
482 LPITEMIDLIST pItemIdList2 = lParam2;
483 LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData;
486 bIsFolder1 = _ILIsFolder(pItemIdList1);
487 bIsFolder2 = _ILIsFolder(pItemIdList2);
488 bIsBothFolder = bIsFolder1 && bIsFolder2;
490 /* When sorting between a File and a Folder, the Folder gets sorted first */
491 if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder)
493 nDiff = bIsFolder1 ? -1 : 1;
495 else
497 /* Sort by Time: Folders or Files can be sorted */
499 if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)
501 _ILGetFileDateTime(pItemIdList1, &fd1);
502 _ILGetFileDateTime(pItemIdList2, &fd2);
503 nDiff = CompareFileTime(&fd2, &fd1);
505 /* Sort by Attribute: Folder or Files can be sorted */
506 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB)
508 _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH);
509 _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH);
510 nDiff = lstrcmpiA(strName1, strName2);
512 /* Sort by FileName: Folder or Files can be sorted */
513 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder)
515 /* Sort by Text */
516 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
517 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
518 nDiff = lstrcmpiA(strName1, strName2);
520 /* Sort by File Size, Only valid for Files */
521 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)
523 nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0));
525 /* Sort by File Type, Only valid for Files */
526 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)
528 /* Sort by Type */
529 _ILGetFileType(pItemIdList1, strName1, MAX_PATH);
530 _ILGetFileType(pItemIdList2, strName2, MAX_PATH);
531 nDiff = lstrcmpiA(strName1, strName2);
534 /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
536 if(nDiff == 0)
538 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
539 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
540 nDiff = lstrcmpiA(strName1, strName2);
543 if(!pSortInfo->bIsAscending)
545 nDiff = -nDiff;
548 return nDiff;
552 /**********************************************************
553 * LV_FindItemByPidl()
555 static int LV_FindItemByPidl(
556 IShellViewImpl * This,
557 LPCITEMIDLIST pidl)
559 LVITEMW lvItem;
560 lvItem.iSubItem = 0;
561 lvItem.mask = LVIF_PARAM;
562 for(lvItem.iItem = 0;
563 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
564 lvItem.iItem++)
566 LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam;
567 HRESULT hr = IShellFolder_CompareIDs(This->pSFParent, 0, pidl, currentpidl);
568 if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
570 return lvItem.iItem;
573 return -1;
576 static void shellview_add_item(IShellViewImpl *shellview, LPCITEMIDLIST pidl)
578 LVITEMW item;
579 UINT i;
581 TRACE("(%p)(pidl=%p)\n", shellview, pidl);
583 item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
584 item.iItem = 0;
585 item.iSubItem = 0;
586 item.lParam = (LPARAM)pidl;
587 item.pszText = LPSTR_TEXTCALLBACKW;
588 item.iImage = I_IMAGECALLBACK;
589 SendMessageW(shellview->hWndList, LVM_INSERTITEMW, 0, (LPARAM)&item);
591 for (i = 1; i < shellview->columns; i++)
593 item.mask = LVIF_TEXT;
594 item.iItem = 0;
595 item.iSubItem = 1;
596 item.pszText = LPSTR_TEXTCALLBACKW;
597 SendMessageW(shellview->hWndList, LVM_SETITEMW, 0, (LPARAM)&item);
601 /**********************************************************
602 * LV_RenameItem()
604 static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew )
606 int nItem;
607 LVITEMW lvItem;
609 TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew);
611 nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld));
612 if ( -1 != nItem )
614 lvItem.mask = LVIF_PARAM; /* only the pidl */
615 lvItem.iItem = nItem;
616 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
618 SHFree((LPITEMIDLIST)lvItem.lParam);
619 lvItem.mask = LVIF_PARAM;
620 lvItem.iItem = nItem;
621 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew)); /* set the item's data */
622 SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem);
623 SendMessageW(This->hWndList, LVM_UPDATE, nItem, 0);
624 return TRUE; /* FIXME: better handling */
626 return FALSE;
628 /**********************************************************
629 * ShellView_FillList()
631 * - gets the objectlist from the shellfolder
632 * - sorts the list
633 * - fills the list into the view
636 static HRESULT ShellView_FillList(IShellViewImpl *This)
638 IFolderView2 *folderview = &This->IFolderView2_iface;
639 LPENUMIDLIST pEnumIDList;
640 LPITEMIDLIST pidl;
641 DWORD fetched;
642 HRESULT hr;
644 TRACE("(%p)\n", This);
646 /* get the itemlist from the shfolder*/
647 hr = IShellFolder_EnumObjects(This->pSFParent, This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList);
648 if (hr != S_OK)
649 return hr;
651 IFolderView2_SetRedraw(folderview, FALSE);
653 /* copy the items into the array */
654 while ((S_OK == IEnumIDList_Next(pEnumIDList, 1, &pidl, &fetched)) && fetched)
656 if (IncludeObject(This, pidl) == S_OK)
657 shellview_add_item(This, pidl);
660 SendMessageW(This->hWndList, LVM_SORTITEMS, (WPARAM)This->pSFParent, (LPARAM)ShellView_CompareItems);
662 IFolderView2_SetRedraw(folderview, TRUE);
664 IEnumIDList_Release(pEnumIDList);
665 return S_OK;
668 /**********************************************************
669 * ShellView_OnCreate()
671 static LRESULT ShellView_OnCreate(IShellViewImpl *This)
673 IShellView3 *iface = &This->IShellView3_iface;
674 static const WCHAR accel_nameW[] = {'s','h','v','_','a','c','c','e','l',0};
675 IPersistFolder2 *ppf2;
676 IDropTarget* pdt;
677 HRESULT hr;
679 TRACE("(%p)\n", This);
681 if (ShellView_CreateList(This))
683 ShellView_InitList(This);
684 ShellView_FillList(This);
687 hr = IShellView3_QueryInterface(iface, &IID_IDropTarget, (void**)&pdt);
688 if (hr == S_OK)
690 RegisterDragDrop(This->hWnd, pdt);
691 IDropTarget_Release(pdt);
694 /* register for receiving notifications */
695 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2);
696 if (hr == S_OK)
698 LPITEMIDLIST raw_pidl;
699 SHChangeNotifyEntry ntreg;
701 hr = IPersistFolder2_GetCurFolder(ppf2, &raw_pidl);
702 if(SUCCEEDED(hr))
704 LPITEMIDLIST computer_pidl;
705 SHGetFolderLocation(NULL,CSIDL_DRIVES,NULL,0,&computer_pidl);
706 if(ILIsParent(computer_pidl,raw_pidl,FALSE))
708 /* Normalize the pidl to unixfs to workaround an issue with
709 * sending notifications on dos paths
711 WCHAR path[MAX_PATH];
712 SHGetPathFromIDListW(raw_pidl,path);
713 SHParseDisplayName(path,NULL,(LPITEMIDLIST*)&ntreg.pidl,0,NULL);
714 SHFree(raw_pidl);
716 else
717 ntreg.pidl = raw_pidl;
718 ntreg.fRecursive = TRUE;
719 This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNRF_InterruptLevel, SHCNE_ALLEVENTS,
720 SHV_CHANGE_NOTIFY, 1, &ntreg);
721 SHFree((LPITEMIDLIST)ntreg.pidl);
722 SHFree(computer_pidl);
724 IPersistFolder2_Release(ppf2);
727 This->hAccel = LoadAcceleratorsW(shell32_hInstance, accel_nameW);
729 return S_OK;
732 /**********************************************************
733 * #### Handling of the menus ####
736 /**********************************************************
737 * ShellView_BuildFileMenu()
739 static HMENU ShellView_BuildFileMenu(IShellViewImpl * This)
740 { WCHAR szText[MAX_PATH];
741 MENUITEMINFOW mii;
742 int nTools,i;
743 HMENU hSubMenu;
745 TRACE("(%p)\n",This);
747 hSubMenu = CreatePopupMenu();
748 if(hSubMenu)
749 { /*get the number of items in our global array*/
750 for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){}
752 /*add the menu items*/
753 for(i = 0; i < nTools; i++)
755 LoadStringW(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH);
757 ZeroMemory(&mii, sizeof(mii));
758 mii.cbSize = sizeof(mii);
759 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
761 if(BTNS_SEP != Tools[i].bStyle) /* no separator*/
763 mii.fType = MFT_STRING;
764 mii.fState = MFS_ENABLED;
765 mii.dwTypeData = szText;
766 mii.wID = Tools[i].idCommand;
768 else
770 mii.fType = MFT_SEPARATOR;
772 /* tack This item onto the end of the menu */
773 InsertMenuItemW(hSubMenu, (UINT)-1, TRUE, &mii);
776 TRACE("-- return (menu=%p)\n",hSubMenu);
777 return hSubMenu;
779 /**********************************************************
780 * ShellView_MergeFileMenu()
782 static void ShellView_MergeFileMenu(IShellViewImpl *This, HMENU hSubMenu)
784 TRACE("(%p)->(submenu=%p) stub\n",This,hSubMenu);
786 if (hSubMenu)
788 static const WCHAR dummyW[] = {'d','u','m','m','y','4','5',0};
789 MENUITEMINFOW mii;
791 /* insert This item at the beginning of the menu */
793 mii.cbSize = sizeof(mii);
794 mii.fMask = MIIM_ID | MIIM_TYPE;
795 mii.wID = 0;
796 mii.fType = MFT_SEPARATOR;
797 InsertMenuItemW(hSubMenu, 0, TRUE, &mii);
799 mii.cbSize = sizeof(mii);
800 mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
801 mii.dwTypeData = (LPWSTR)dummyW;
802 mii.fState = MFS_ENABLED;
803 mii.wID = IDM_MYFILEITEM;
804 mii.fType = MFT_STRING;
805 InsertMenuItemW(hSubMenu, 0, TRUE, &mii);
808 TRACE("--\n");
811 /**********************************************************
812 * ShellView_MergeViewMenu()
815 static void ShellView_MergeViewMenu(IShellViewImpl *This, HMENU hSubMenu)
817 TRACE("(%p)->(submenu=%p)\n",This,hSubMenu);
819 /* add a separator at the correct position in the menu */
820 if (hSubMenu)
822 static const WCHAR menuW[] = {'M','E','N','U','_','0','0','1',0};
823 static const WCHAR viewW[] = {'V','i','e','w',0};
824 MENUITEMINFOW mii;
826 memset(&mii, 0, sizeof(mii));
827 mii.cbSize = sizeof(mii);
828 mii.fMask = MIIM_ID | MIIM_TYPE;
829 mii.wID = 0;
830 mii.fType = MFT_SEPARATOR;
831 InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
833 mii.cbSize = sizeof(mii);
834 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;
835 mii.fType = MFT_STRING;
836 mii.dwTypeData = (LPWSTR)viewW;
837 mii.hSubMenu = LoadMenuW(shell32_hInstance, menuW);
838 InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
842 /**********************************************************
843 * ShellView_GetSelections()
845 * - fills the this->apidl list with the selected objects
847 * RETURNS
848 * number of selected items
850 static UINT ShellView_GetSelections(IShellViewImpl * This)
852 LVITEMW lvItem;
853 UINT i = 0;
855 SHFree(This->apidl);
857 This->cidl = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0);
858 This->apidl = SHAlloc(This->cidl * sizeof(LPITEMIDLIST));
860 TRACE("selected=%i\n", This->cidl);
862 if(This->apidl)
864 TRACE("-- Items selected =%u\n", This->cidl);
866 lvItem.mask = LVIF_STATE | LVIF_PARAM;
867 lvItem.stateMask = LVIS_SELECTED;
868 lvItem.iItem = 0;
869 lvItem.iSubItem = 0;
871 while(ListView_GetItemW(This->hWndList, &lvItem) && (i < This->cidl))
873 if(lvItem.state & LVIS_SELECTED)
875 This->apidl[i] = (LPITEMIDLIST)lvItem.lParam;
876 i++;
877 TRACE("-- selected Item found\n");
879 lvItem.iItem++;
882 return This->cidl;
886 /**********************************************************
887 * ShellView_OpenSelectedItems()
889 static HRESULT ShellView_OpenSelectedItems(IShellViewImpl * This)
891 static UINT CF_IDLIST = 0;
892 HRESULT hr;
893 IDataObject* selection;
894 FORMATETC fetc;
895 STGMEDIUM stgm;
896 LPIDA pIDList;
897 LPCITEMIDLIST parent_pidl;
898 WCHAR parent_path[MAX_PATH];
899 LPCWSTR parent_dir = NULL;
900 SFGAOF attribs;
901 int i;
903 if (0 == ShellView_GetSelections(This))
905 return S_OK;
907 hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl,
908 (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,
909 0, (LPVOID *)&selection);
910 if (FAILED(hr))
911 return hr;
913 if (0 == CF_IDLIST)
915 CF_IDLIST = RegisterClipboardFormatW(CFSTR_SHELLIDLISTW);
917 fetc.cfFormat = CF_IDLIST;
918 fetc.ptd = NULL;
919 fetc.dwAspect = DVASPECT_CONTENT;
920 fetc.lindex = -1;
921 fetc.tymed = TYMED_HGLOBAL;
923 hr = IDataObject_QueryGetData(selection, &fetc);
924 if (FAILED(hr))
925 return hr;
927 hr = IDataObject_GetData(selection, &fetc, &stgm);
928 if (FAILED(hr))
929 return hr;
931 pIDList = GlobalLock(stgm.u.hGlobal);
933 parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pIDList+pIDList->aoffset[0]);
934 hr = IShellFolder_GetAttributesOf(This->pSFParent, 1, &parent_pidl, &attribs);
935 if (SUCCEEDED(hr) && (attribs & SFGAO_FILESYSTEM) &&
936 SHGetPathFromIDListW(parent_pidl, parent_path))
938 parent_dir = parent_path;
941 for (i = pIDList->cidl; i > 0; --i)
943 LPCITEMIDLIST pidl;
945 pidl = (LPCITEMIDLIST)((LPBYTE)pIDList+pIDList->aoffset[i]);
947 attribs = SFGAO_FOLDER;
948 hr = IShellFolder_GetAttributesOf(This->pSFParent, 1, &pidl, &attribs);
950 if (SUCCEEDED(hr) && ! (attribs & SFGAO_FOLDER))
952 SHELLEXECUTEINFOW shexinfo;
954 shexinfo.cbSize = sizeof(SHELLEXECUTEINFOW);
955 shexinfo.fMask = SEE_MASK_INVOKEIDLIST; /* SEE_MASK_IDLIST is also possible. */
956 shexinfo.hwnd = NULL;
957 shexinfo.lpVerb = NULL;
958 shexinfo.lpFile = NULL;
959 shexinfo.lpParameters = NULL;
960 shexinfo.lpDirectory = parent_dir;
961 shexinfo.nShow = SW_NORMAL;
962 shexinfo.lpIDList = ILCombine(parent_pidl, pidl);
964 ShellExecuteExW(&shexinfo); /* Discard error/success info */
966 ILFree(shexinfo.lpIDList);
970 GlobalUnlock(stgm.u.hGlobal);
971 ReleaseStgMedium(&stgm);
973 IDataObject_Release(selection);
975 return S_OK;
978 /**********************************************************
979 * ShellView_DoContextMenu()
981 static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL bDefault)
982 { UINT uCommand;
983 DWORD wFlags;
984 HMENU hMenu;
985 BOOL fExplore = FALSE;
986 HWND hwndTree = 0;
987 LPCONTEXTMENU pContextMenu = NULL;
988 CMINVOKECOMMANDINFO cmi;
990 TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, bDefault);
992 /* look, what's selected and create a context menu object of it*/
993 if( ShellView_GetSelections(This) )
995 IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, (LPCITEMIDLIST*)This->apidl,
996 &IID_IContextMenu, NULL, (LPVOID *)&pContextMenu);
998 if(pContextMenu)
1000 TRACE("-- pContextMenu\n");
1001 hMenu = CreatePopupMenu();
1003 if( hMenu )
1005 /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
1006 if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree)
1008 TRACE("-- explore mode\n");
1009 fExplore = TRUE;
1012 /* build the flags depending on what we can do with the selected item */
1013 wFlags = CMF_NORMAL | (This->cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0);
1015 /* let the ContextMenu merge its items in */
1016 if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags )))
1018 if (This->FolderSettings.fFlags & FWF_DESKTOP)
1019 SetMenuDefaultItem(hMenu, FCIDM_SHVIEW_OPEN, MF_BYCOMMAND);
1021 if( bDefault )
1023 TRACE("-- get menu default command\n");
1024 uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS);
1026 else
1028 TRACE("-- track popup\n");
1029 uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
1032 if(uCommand > 0)
1034 TRACE("-- uCommand=%u\n", uCommand);
1035 if (uCommand==FCIDM_SHVIEW_OPEN && IsInCommDlg(This))
1037 TRACE("-- dlg: OnDefaultCommand\n");
1038 if (OnDefaultCommand(This) != S_OK)
1040 ShellView_OpenSelectedItems(This);
1043 else
1045 TRACE("-- explore -- invoke command\n");
1046 ZeroMemory(&cmi, sizeof(cmi));
1047 cmi.cbSize = sizeof(cmi);
1048 cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */
1049 cmi.lpVerb = MAKEINTRESOURCEA(uCommand);
1050 IContextMenu_InvokeCommand(pContextMenu, &cmi);
1053 DestroyMenu(hMenu);
1056 if (pContextMenu)
1057 IContextMenu_Release(pContextMenu);
1060 else /* background context menu */
1062 IContextMenu2 *pCM;
1064 hMenu = CreatePopupMenu();
1066 BackgroundMenu_Constructor(This->pSFParent, FALSE, &IID_IContextMenu2, (void**)&pCM);
1067 IContextMenu2_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
1069 uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
1070 DestroyMenu(hMenu);
1072 TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand);
1074 ZeroMemory(&cmi, sizeof(cmi));
1075 cmi.cbSize = sizeof(cmi);
1076 cmi.lpVerb = MAKEINTRESOURCEA(uCommand);
1077 cmi.hwnd = This->hWndParent;
1078 IContextMenu2_InvokeCommand(pCM, &cmi);
1080 IContextMenu2_Release(pCM);
1084 /**********************************************************
1085 * ##### message handling #####
1088 /**********************************************************
1089 * ShellView_OnSize()
1091 static LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight)
1093 TRACE("%p width=%u height=%u\n",This, wWidth,wHeight);
1095 /*resize the ListView to fit our window*/
1096 if(This->hWndList)
1098 MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE);
1101 return S_OK;
1103 /**********************************************************
1104 * ShellView_OnDeactivate()
1106 * NOTES
1107 * internal
1109 static void ShellView_OnDeactivate(IShellViewImpl * This)
1111 TRACE("%p\n",This);
1113 if(This->uState != SVUIA_DEACTIVATE)
1115 if(This->hMenu)
1117 IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0);
1118 IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu);
1119 DestroyMenu(This->hMenu);
1120 This->hMenu = 0;
1123 This->uState = SVUIA_DEACTIVATE;
1127 /**********************************************************
1128 * ShellView_OnActivate()
1130 static LRESULT ShellView_OnActivate(IShellViewImpl *This, UINT uState)
1132 OLEMENUGROUPWIDTHS omw = { {0, 0, 0, 0, 0, 0} };
1133 MENUITEMINFOW mii;
1135 TRACE("(%p) uState=%x\n",This,uState);
1137 /* don't do anything if the state isn't really changing */
1138 if (This->uState == uState) return S_OK;
1140 ShellView_OnDeactivate(This);
1142 /* only do This if we are active */
1143 if (uState != SVUIA_DEACTIVATE)
1145 /* merge the menus */
1146 This->hMenu = CreateMenu();
1148 if (This->hMenu)
1150 static const WCHAR dummyW[] = {'d','u','m','m','y',' ','3','1',0};
1152 IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw);
1153 TRACE("-- after fnInsertMenusSB\n");
1155 mii.cbSize = sizeof(mii);
1156 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
1157 mii.fType = MFT_STRING;
1158 mii.fState = MFS_ENABLED;
1159 mii.wID = 0;
1160 mii.hSubMenu = ShellView_BuildFileMenu(This);
1161 mii.hbmpChecked = NULL;
1162 mii.hbmpUnchecked = NULL;
1163 mii.dwItemData = 0;
1164 /* build the top level menu get the menu item's text */
1165 mii.dwTypeData = (LPWSTR)dummyW;
1166 mii.cch = 0;
1167 mii.hbmpItem = NULL;
1169 /* insert our menu into the menu bar */
1170 if (mii.hSubMenu)
1171 InsertMenuItemW(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii);
1173 /* get the view menu so we can merge with it */
1174 memset(&mii, 0, sizeof(mii));
1175 mii.cbSize = sizeof(mii);
1176 mii.fMask = MIIM_SUBMENU;
1178 if (GetMenuItemInfoW(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii))
1179 ShellView_MergeViewMenu(This, mii.hSubMenu);
1181 /* add the items that should only be added if we have the focus */
1182 if (SVUIA_ACTIVATE_FOCUS == uState)
1184 /* get the file menu so we can merge with it */
1185 memset(&mii, 0, sizeof(mii));
1186 mii.cbSize = sizeof(mii);
1187 mii.fMask = MIIM_SUBMENU;
1189 if (GetMenuItemInfoW(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii))
1190 ShellView_MergeFileMenu(This, mii.hSubMenu);
1193 TRACE("-- before fnSetMenuSB\n");
1194 IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd);
1197 This->uState = uState;
1198 TRACE("--\n");
1199 return S_OK;
1202 /**********************************************************
1203 * ShellView_OnSetFocus()
1206 static LRESULT ShellView_OnSetFocus(IShellViewImpl * This)
1208 TRACE("%p\n",This);
1210 /* Tell the browser one of our windows has received the focus. This
1211 should always be done before merging menus (OnActivate merges the
1212 menus) if one of our windows has the focus.*/
1214 IShellBrowser_OnViewWindowActive(This->pShellBrowser, (IShellView *)&This->IShellView3_iface);
1215 ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS);
1217 /* Set the focus to the listview */
1218 SetFocus(This->hWndList);
1220 /* Notify the ICommDlgBrowser interface */
1221 OnStateChange(This,CDBOSC_SETFOCUS);
1223 return 0;
1226 /**********************************************************
1227 * ShellView_OnKillFocus()
1229 static LRESULT ShellView_OnKillFocus(IShellViewImpl * This)
1231 TRACE("(%p) stub\n",This);
1233 ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS);
1234 /* Notify the ICommDlgBrowser */
1235 OnStateChange(This,CDBOSC_KILLFOCUS);
1237 return 0;
1240 /**********************************************************
1241 * ShellView_OnCommand()
1243 * NOTES
1244 * the CmdIDs are the ones from the context menu
1246 static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd)
1248 TRACE("(%p)->(0x%08x 0x%08x %p) stub\n",This, dwCmdID, dwCmd, hwndCmd);
1250 switch(dwCmdID)
1252 case FCIDM_SHVIEW_SMALLICON:
1253 This->FolderSettings.ViewMode = FVM_SMALLICON;
1254 SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK);
1255 CheckToolbar(This);
1256 break;
1258 case FCIDM_SHVIEW_BIGICON:
1259 This->FolderSettings.ViewMode = FVM_ICON;
1260 SetStyle (This, LVS_ICON, LVS_TYPEMASK);
1261 CheckToolbar(This);
1262 break;
1264 case FCIDM_SHVIEW_LISTVIEW:
1265 This->FolderSettings.ViewMode = FVM_LIST;
1266 SetStyle (This, LVS_LIST, LVS_TYPEMASK);
1267 CheckToolbar(This);
1268 break;
1270 case FCIDM_SHVIEW_REPORTVIEW:
1271 This->FolderSettings.ViewMode = FVM_DETAILS;
1272 SetStyle (This, LVS_REPORT, LVS_TYPEMASK);
1273 CheckToolbar(This);
1274 break;
1276 /* the menu IDs for sorting are 0x30... see shell32.rc */
1277 case 0x30:
1278 case 0x31:
1279 case 0x32:
1280 case 0x33:
1281 This->ListViewSortInfo.nHeaderID = dwCmdID - 0x30;
1282 This->ListViewSortInfo.bIsAscending = TRUE;
1283 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1284 SendMessageW(This->hWndList, LVM_SORTITEMS, (WPARAM) &This->ListViewSortInfo, (LPARAM)ShellView_ListViewCompareItems);
1285 break;
1287 default:
1288 TRACE("-- COMMAND 0x%04x unhandled\n", dwCmdID);
1290 return 0;
1293 /**********************************************************
1294 * ShellView_OnNotify()
1297 static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
1298 { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
1299 NMLVDISPINFOW *lpdi = (NMLVDISPINFOW *)lpnmh;
1300 LPITEMIDLIST pidl;
1302 TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code);
1304 switch(lpnmh->code)
1306 case NM_SETFOCUS:
1307 TRACE("-- NM_SETFOCUS %p\n",This);
1308 ShellView_OnSetFocus(This);
1309 break;
1311 case NM_KILLFOCUS:
1312 TRACE("-- NM_KILLFOCUS %p\n",This);
1313 ShellView_OnDeactivate(This);
1314 /* Notify the ICommDlgBrowser interface */
1315 OnStateChange(This,CDBOSC_KILLFOCUS);
1316 break;
1318 case NM_CUSTOMDRAW:
1319 TRACE("-- NM_CUSTOMDRAW %p\n",This);
1320 return CDRF_DODEFAULT;
1322 case NM_RELEASEDCAPTURE:
1323 TRACE("-- NM_RELEASEDCAPTURE %p\n",This);
1324 break;
1326 case NM_CLICK:
1327 TRACE("-- NM_CLICK %p\n",This);
1328 break;
1330 case NM_RCLICK:
1331 TRACE("-- NM_RCLICK %p\n",This);
1332 break;
1334 case NM_DBLCLK:
1335 TRACE("-- NM_DBLCLK %p\n",This);
1336 if (OnDefaultCommand(This) != S_OK) ShellView_OpenSelectedItems(This);
1337 break;
1339 case NM_RETURN:
1340 TRACE("-- NM_RETURN %p\n",This);
1341 if (OnDefaultCommand(This) != S_OK) ShellView_OpenSelectedItems(This);
1342 break;
1344 case HDN_ENDTRACKW:
1345 TRACE("-- HDN_ENDTRACKW %p\n",This);
1346 /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
1347 nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
1348 break;
1350 case LVN_DELETEITEM:
1351 TRACE("-- LVN_DELETEITEM %p\n",This);
1352 SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/
1353 break;
1355 case LVN_DELETEALLITEMS:
1356 TRACE("-- LVN_DELETEALLITEMS %p\n",This);
1357 return FALSE;
1359 case LVN_INSERTITEM:
1360 TRACE("-- LVN_INSERTITEM (STUB)%p\n",This);
1361 break;
1363 case LVN_ITEMACTIVATE:
1364 TRACE("-- LVN_ITEMACTIVATE %p\n",This);
1365 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1366 break;
1368 case LVN_COLUMNCLICK:
1369 This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem;
1370 if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID)
1372 This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending;
1374 else
1376 This->ListViewSortInfo.bIsAscending = TRUE;
1378 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1380 SendMessageW(lpnmlv->hdr.hwndFrom, LVM_SORTITEMS, (WPARAM) &This->ListViewSortInfo, (LPARAM)ShellView_ListViewCompareItems);
1381 break;
1383 case LVN_GETDISPINFOA:
1384 case LVN_GETDISPINFOW:
1385 TRACE("-- LVN_GETDISPINFO %p\n",This);
1386 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1388 if(lpdi->item.mask & LVIF_TEXT) /* text requested */
1390 static WCHAR emptyW[] = { 0 };
1391 SHELLDETAILS sd;
1392 HRESULT hr;
1394 if (This->pSF2Parent)
1396 hr = IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
1398 else
1400 IShellDetails *details;
1402 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IShellDetails, (void**)&details);
1403 if (hr == S_OK)
1405 hr = IShellDetails_GetDetailsOf(details, pidl, lpdi->item.iSubItem, &sd);
1406 IShellDetails_Release(details);
1408 else
1409 WARN("IShellFolder2/IShellDetails not supported\n");
1412 if (hr != S_OK)
1414 /* set to empty on failure */
1415 sd.str.uType = STRRET_WSTR;
1416 sd.str.u.pOleStr = emptyW;
1419 if (lpnmh->code == LVN_GETDISPINFOW)
1421 StrRetToStrNW( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1422 TRACE("-- text=%s\n", debugstr_w(lpdi->item.pszText));
1424 else
1426 /* LVN_GETDISPINFOA - shouldn't happen */
1427 NMLVDISPINFOA *lpdiA = (NMLVDISPINFOA *)lpnmh;
1428 StrRetToStrNA( lpdiA->item.pszText, lpdiA->item.cchTextMax, &sd.str, NULL);
1429 TRACE("-- text=%s\n", lpdiA->item.pszText);
1433 if(lpdi->item.mask & LVIF_IMAGE) /* image requested */
1435 lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
1437 break;
1439 case LVN_ITEMCHANGED:
1440 TRACE("-- LVN_ITEMCHANGED %p\n",This);
1441 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1442 break;
1444 case LVN_BEGINDRAG:
1445 case LVN_BEGINRDRAG:
1446 TRACE("-- LVN_BEGINDRAG\n");
1448 if (ShellView_GetSelections(This))
1450 IDataObject * pda;
1451 DWORD dwAttributes = SFGAO_CANLINK;
1452 DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
1454 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
1456 IDropSource *pds = &This->IDropSource_iface; /* own DropSource interface */
1458 if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, (LPCITEMIDLIST*)This->apidl, &dwAttributes)))
1460 if (dwAttributes & SFGAO_CANLINK)
1462 dwEffect |= DROPEFFECT_LINK;
1466 if (pds)
1468 DWORD dwEffect2;
1469 DoDragDrop(pda, pds, dwEffect, &dwEffect2);
1471 IDataObject_Release(pda);
1474 break;
1476 case LVN_BEGINLABELEDITW:
1478 DWORD dwAttr = SFGAO_CANRENAME;
1479 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1481 TRACE("-- LVN_BEGINLABELEDITW %p\n",This);
1483 IShellFolder_GetAttributesOf(This->pSFParent, 1, (LPCITEMIDLIST*)&pidl, &dwAttr);
1484 if (SFGAO_CANRENAME & dwAttr)
1486 return FALSE;
1488 return TRUE;
1491 case LVN_ENDLABELEDITW:
1493 TRACE("-- LVN_ENDLABELEDITA %p\n",This);
1494 if (lpdi->item.pszText)
1496 HRESULT hr;
1497 LVITEMW lvItem;
1499 lvItem.iItem = lpdi->item.iItem;
1500 lvItem.iSubItem = 0;
1501 lvItem.mask = LVIF_PARAM;
1502 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
1504 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1505 hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, lpdi->item.pszText, SHGDN_INFOLDER, &pidl);
1507 if(SUCCEEDED(hr) && pidl)
1509 lvItem.mask = LVIF_PARAM;
1510 lvItem.lParam = (LPARAM)pidl;
1511 SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem);
1512 return TRUE;
1515 return FALSE;
1518 case LVN_KEYDOWN:
1520 LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
1522 /* initiate a rename of the selected file or directory */
1523 switch (plvKeyDown->wVKey)
1525 case VK_F2:
1527 INT i = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0);
1529 if (i == 1)
1531 /* get selected item */
1532 i = SendMessageW(This->hWndList, LVM_GETNEXTITEM, -1, MAKELPARAM (LVNI_SELECTED, 0));
1534 SendMessageW(This->hWndList, LVM_ENSUREVISIBLE, i, 0);
1535 SendMessageW(This->hWndList, LVM_EDITLABELW, i, 0);
1538 break;
1539 case VK_DELETE:
1541 UINT i, count;
1542 int item_index;
1543 LVITEMW item;
1544 LPITEMIDLIST* pItems;
1545 ISFHelper *psfhlp;
1546 HRESULT hr;
1548 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (void**)&psfhlp);
1549 if (hr != S_OK) return 0;
1551 if(!(count = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0)))
1553 ISFHelper_Release(psfhlp);
1554 return 0;
1557 /* allocate memory for the pidl array */
1558 pItems = heap_alloc(sizeof(LPITEMIDLIST) * count);
1560 /* retrieve all selected items */
1561 i = 0;
1562 item_index = -1;
1564 while (count > i)
1566 /* get selected item */
1567 item_index = SendMessageW(This->hWndList, LVM_GETNEXTITEM, item_index,
1568 MAKELPARAM (LVNI_SELECTED, 0));
1569 item.iItem = item_index;
1570 item.mask = LVIF_PARAM;
1571 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM)&item);
1573 /* get item pidl */
1574 pItems[i] = (LPITEMIDLIST)item.lParam;
1576 i++;
1579 /* perform the item deletion */
1580 ISFHelper_DeleteItems(psfhlp, i, (LPCITEMIDLIST*)pItems);
1581 ISFHelper_Release(psfhlp);
1583 /* free pidl array memory */
1584 heap_free(pItems);
1586 break;
1588 case VK_F5:
1589 /* Initiate a refresh */
1590 IShellView3_Refresh(&This->IShellView3_iface);
1591 break;
1593 case VK_BACK:
1595 LPSHELLBROWSER lpSb;
1596 if((lpSb = (LPSHELLBROWSER)SendMessageW(This->hWndParent, CWM_GETISHELLBROWSER, 0, 0)))
1598 IShellBrowser_BrowseObject(lpSb, NULL, SBSP_PARENT);
1601 break;
1603 default:
1604 FIXME("LVN_KEYDOWN key=0x%08x\n", plvKeyDown->wVKey);
1607 break;
1609 default:
1610 TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code);
1611 break;
1613 return 0;
1616 /**********************************************************
1617 * ShellView_OnChange()
1620 static LRESULT ShellView_OnChange(IShellViewImpl * This, const LPCITEMIDLIST *pidls, LONG event)
1622 LPCITEMIDLIST pidl;
1623 BOOL ret = TRUE;
1625 TRACE("(%p)->(%p, %p, 0x%08x)\n", This, pidls[0], pidls[1], event);
1627 switch (event)
1629 case SHCNE_MKDIR:
1630 case SHCNE_CREATE:
1631 pidl = ILClone(ILFindLastID(pidls[0]));
1632 shellview_add_item(This, pidl);
1633 break;
1634 case SHCNE_RMDIR:
1635 case SHCNE_DELETE:
1637 INT i = LV_FindItemByPidl(This, ILFindLastID(pidls[0]));
1638 ret = SendMessageW(This->hWndList, LVM_DELETEITEM, i, 0);
1639 break;
1641 case SHCNE_RENAMEFOLDER:
1642 case SHCNE_RENAMEITEM:
1643 LV_RenameItem(This, pidls[0], pidls[1]);
1644 break;
1645 case SHCNE_UPDATEITEM:
1646 break;
1648 return ret;
1650 /**********************************************************
1651 * ShellView_WndProc
1654 static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1656 IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
1657 LPCREATESTRUCTW lpcs;
1659 TRACE("(hwnd=%p msg=%x wparm=%lx lparm=%lx)\n",hWnd, uMessage, wParam, lParam);
1661 switch (uMessage)
1663 case WM_NCCREATE:
1664 lpcs = (LPCREATESTRUCTW)lParam;
1665 pThis = lpcs->lpCreateParams;
1666 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (ULONG_PTR)pThis);
1667 pThis->hWnd = hWnd; /*set the window handle*/
1668 break;
1670 case WM_SIZE: return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam));
1671 case WM_SETFOCUS: return ShellView_OnSetFocus(pThis);
1672 case WM_KILLFOCUS: return ShellView_OnKillFocus(pThis);
1673 case WM_CREATE: return ShellView_OnCreate(pThis);
1674 case WM_ACTIVATE: return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS);
1675 case WM_NOTIFY: return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam);
1676 case WM_COMMAND: return ShellView_OnCommand(pThis,
1677 GET_WM_COMMAND_ID(wParam, lParam),
1678 GET_WM_COMMAND_CMD(wParam, lParam),
1679 GET_WM_COMMAND_HWND(wParam, lParam));
1680 case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (const LPCITEMIDLIST*)wParam, (LONG)lParam);
1682 case WM_CONTEXTMENU: ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE);
1683 return 0;
1685 case WM_SHOWWINDOW: UpdateWindow(pThis->hWndList);
1686 break;
1688 case WM_GETDLGCODE: return SendMessageW(pThis->hWndList, uMessage, 0, 0);
1689 case WM_SETFONT: return SendMessageW(pThis->hWndList, WM_SETFONT, wParam, lParam);
1690 case WM_GETFONT: return SendMessageW(pThis->hWndList, WM_GETFONT, wParam, lParam);
1692 case WM_DESTROY:
1693 RevokeDragDrop(pThis->hWnd);
1694 SHChangeNotifyDeregister(pThis->hNotify);
1695 break;
1697 case WM_ERASEBKGND:
1698 if ((pThis->FolderSettings.fFlags & FWF_DESKTOP) ||
1699 (pThis->FolderSettings.fFlags & FWF_TRANSPARENT))
1700 return 1;
1701 break;
1704 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
1706 /**********************************************************
1709 * The INTERFACE of the IShellView object
1712 **********************************************************
1713 * IShellView_QueryInterface
1715 static HRESULT WINAPI IShellView_fnQueryInterface(IShellView3 *iface, REFIID riid, void **ppvObj)
1717 IShellViewImpl *This = impl_from_IShellView3(iface);
1719 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObj);
1721 *ppvObj = NULL;
1723 if(IsEqualIID(riid, &IID_IUnknown) ||
1724 IsEqualIID(riid, &IID_IShellView) ||
1725 IsEqualIID(riid, &IID_IShellView2) ||
1726 IsEqualIID(riid, &IID_IShellView3) ||
1727 IsEqualIID(riid, &IID_CDefView))
1729 *ppvObj = &This->IShellView3_iface;
1731 else if(IsEqualIID(riid, &IID_IShellFolderView))
1733 *ppvObj = &This->IShellFolderView_iface;
1735 else if(IsEqualIID(riid, &IID_IFolderView) ||
1736 IsEqualIID(riid, &IID_IFolderView2))
1738 *ppvObj = &This->IFolderView2_iface;
1740 else if(IsEqualIID(riid, &IID_IOleCommandTarget))
1742 *ppvObj = &This->IOleCommandTarget_iface;
1744 else if(IsEqualIID(riid, &IID_IDropTarget))
1746 *ppvObj = &This->IDropTarget_iface;
1748 else if(IsEqualIID(riid, &IID_IDropSource))
1750 *ppvObj = &This->IDropSource_iface;
1752 else if(IsEqualIID(riid, &IID_IViewObject))
1754 *ppvObj = &This->IViewObject_iface;
1757 if(*ppvObj)
1759 IUnknown_AddRef( (IUnknown*)*ppvObj );
1760 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1761 return S_OK;
1763 TRACE("-- Interface: E_NOINTERFACE\n");
1764 return E_NOINTERFACE;
1767 /**********************************************************
1768 * IShellView_AddRef
1770 static ULONG WINAPI IShellView_fnAddRef(IShellView3 *iface)
1772 IShellViewImpl *This = impl_from_IShellView3(iface);
1773 ULONG refCount = InterlockedIncrement(&This->ref);
1775 TRACE("(%p)->(count=%u)\n", This, refCount - 1);
1777 return refCount;
1779 /**********************************************************
1780 * IShellView_Release
1782 static ULONG WINAPI IShellView_fnRelease(IShellView3 *iface)
1784 IShellViewImpl *This = impl_from_IShellView3(iface);
1785 ULONG refCount = InterlockedDecrement(&This->ref);
1787 TRACE("(%p)->(count=%i)\n", This, refCount + 1);
1789 if (!refCount)
1791 TRACE(" destroying IShellView(%p)\n",This);
1793 DestroyWindow(This->hWndList);
1795 if(This->pSFParent)
1796 IShellFolder_Release(This->pSFParent);
1798 if(This->pSF2Parent)
1799 IShellFolder2_Release(This->pSF2Parent);
1801 SHFree(This->apidl);
1803 if(This->pAdvSink)
1804 IAdviseSink_Release(This->pAdvSink);
1806 heap_free(This);
1808 return refCount;
1811 /**********************************************************
1812 * ShellView_GetWindow
1814 static HRESULT WINAPI IShellView_fnGetWindow(IShellView3 *iface, HWND *phWnd)
1816 IShellViewImpl *This = impl_from_IShellView3(iface);
1818 TRACE("(%p)\n", This);
1820 *phWnd = This->hWnd;
1821 return S_OK;
1824 static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView3 *iface, BOOL mode)
1826 IShellViewImpl *This = impl_from_IShellView3(iface);
1827 TRACE("(%p)->(%d)\n", This, mode);
1828 return E_NOTIMPL;
1831 /**********************************************************
1832 * IShellView_TranslateAccelerator
1834 * FIXME:
1835 * use the accel functions
1837 static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView3 *iface, MSG *lpmsg)
1839 #if 0
1840 IShellViewImpl *This = (IShellViewImpl *)iface;
1842 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%x wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1843 #endif
1845 if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST))
1847 TRACE("-- key=0x04%lx\n",lpmsg->wParam) ;
1849 return S_FALSE; /* not handled */
1852 static HRESULT WINAPI IShellView_fnEnableModeless(IShellView3 *iface, BOOL fEnable)
1854 IShellViewImpl *This = impl_from_IShellView3(iface);
1856 FIXME("(%p) stub\n", This);
1858 return E_NOTIMPL;
1861 static HRESULT WINAPI IShellView_fnUIActivate(IShellView3 *iface, UINT uState)
1863 IShellViewImpl *This = impl_from_IShellView3(iface);
1866 CHAR szName[MAX_PATH];
1868 LRESULT lResult;
1869 int nPartArray[1] = {-1};
1871 TRACE("(%p)->(state=%x) stub\n",This, uState);
1873 /*don't do anything if the state isn't really changing*/
1874 if(This->uState == uState)
1876 return S_OK;
1879 /*OnActivate handles the menu merging and internal state*/
1880 ShellView_OnActivate(This, uState);
1882 /*only do This if we are active*/
1883 if(uState != SVUIA_DEACTIVATE)
1887 GetFolderPath is not a method of IShellFolder
1888 IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1890 /* set the number of parts */
1891 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1892 (LPARAM)nPartArray, &lResult);
1894 /* set the text for the parts */
1896 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1897 0, (LPARAM)szName, &lResult);
1901 return S_OK;
1904 static HRESULT WINAPI IShellView_fnRefresh(IShellView3 *iface)
1906 IShellViewImpl *This = impl_from_IShellView3(iface);
1908 TRACE("(%p)\n", This);
1910 SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0);
1911 ShellView_FillList(This);
1913 return S_OK;
1916 static HRESULT WINAPI IShellView_fnCreateViewWindow(IShellView3 *iface, IShellView *prev_view,
1917 const FOLDERSETTINGS *settings, IShellBrowser *owner, RECT *rect, HWND *hWnd)
1919 IShellViewImpl *This = impl_from_IShellView3(iface);
1920 TRACE("(%p)->(%p %p %p %p %p)\n", This, prev_view, settings, owner, rect, hWnd);
1921 return IShellView3_CreateViewWindow3(iface, owner, prev_view, SV3CVW3_DEFAULT,
1922 settings->fFlags, settings->fFlags, settings->ViewMode, NULL, rect, hWnd);
1925 static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView3 *iface)
1927 IShellViewImpl *This = impl_from_IShellView3(iface);
1929 TRACE("(%p)\n", This);
1931 if (!This->hWnd)
1932 return S_OK;
1934 /* Make absolutely sure all our UI is cleaned up. */
1935 IShellView3_UIActivate(iface, SVUIA_DEACTIVATE);
1937 if (This->hMenu)
1938 DestroyMenu(This->hMenu);
1940 DestroyWindow(This->hWnd);
1941 if (This->pShellBrowser) IShellBrowser_Release(This->pShellBrowser);
1942 if (This->pCommDlgBrowser) ICommDlgBrowser_Release(This->pCommDlgBrowser);
1944 This->hMenu = NULL;
1945 This->hWnd = NULL;
1946 This->pShellBrowser = NULL;
1947 This->pCommDlgBrowser = NULL;
1949 return S_OK;
1952 static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView3 *iface, LPFOLDERSETTINGS lpfs)
1954 IShellViewImpl *This = impl_from_IShellView3(iface);
1956 TRACE("(%p)->(%p) vmode=%x flags=%x\n", This, lpfs,
1957 This->FolderSettings.ViewMode, This->FolderSettings.fFlags);
1959 if (!lpfs) return E_INVALIDARG;
1960 *lpfs = This->FolderSettings;
1961 return S_OK;
1964 static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView3 *iface, DWORD dwReserved,
1965 LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
1967 IShellViewImpl *This = impl_from_IShellView3(iface);
1968 FIXME("(%p) stub\n", This);
1969 return E_NOTIMPL;
1972 static HRESULT WINAPI IShellView_fnSaveViewState(IShellView3 *iface)
1974 IShellViewImpl *This = impl_from_IShellView3(iface);
1975 FIXME("(%p) stub\n", This);
1976 return S_OK;
1979 static HRESULT WINAPI IShellView_fnSelectItem(IShellView3 *iface, LPCITEMIDLIST pidl, UINT flags)
1981 IShellViewImpl *This = impl_from_IShellView3(iface);
1982 int i;
1984 TRACE("(%p)->(pidl=%p, 0x%08x)\n",This, pidl, flags);
1986 i = LV_FindItemByPidl(This, pidl);
1987 if (i == -1) return S_OK;
1989 return IFolderView2_SelectItem(&This->IFolderView2_iface, i, flags);
1992 static HRESULT WINAPI IShellView_fnGetItemObject(IShellView3 *iface, UINT uItem, REFIID riid,
1993 void **ppvOut)
1995 IShellViewImpl *This = impl_from_IShellView3(iface);
1996 HRESULT hr = E_NOINTERFACE;
1998 TRACE("(%p)->(0x%08x, %s, %p)\n",This, uItem, debugstr_guid(riid), ppvOut);
2000 *ppvOut = NULL;
2002 switch(uItem)
2004 case SVGIO_BACKGROUND:
2006 if (IsEqualIID(&IID_IContextMenu, riid))
2007 return BackgroundMenu_Constructor(This->pSFParent, FALSE, riid, ppvOut);
2008 else if (IsEqualIID(&IID_IDispatch, riid)) {
2009 *ppvOut = &This->IShellFolderViewDual3_iface;
2010 IShellFolderViewDual3_AddRef(&This->IShellFolderViewDual3_iface);
2011 return S_OK;
2013 else
2014 FIXME("unsupported interface requested %s\n", debugstr_guid(riid));
2016 break;
2018 case SVGIO_SELECTION:
2019 ShellView_GetSelections(This);
2020 hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, riid, 0, ppvOut);
2021 break;
2023 default:
2024 FIXME("unimplemented for uItem = 0x%08x\n", uItem);
2026 TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
2028 return hr;
2031 static HRESULT WINAPI IShellView2_fnGetView(IShellView3 *iface, SHELLVIEWID *view_guid, ULONG view_type)
2033 FIXME("(%p)->(%s, %#x) stub!\n", iface, debugstr_guid(view_guid), view_type);
2034 return E_NOTIMPL;
2037 static HRESULT WINAPI IShellView2_fnCreateViewWindow2(IShellView3 *iface, SV2CVW2_PARAMS *view_params)
2039 IShellViewImpl *This = impl_from_IShellView3(iface);
2040 TRACE("(%p)->(%p)\n", This, view_params);
2041 return IShellView3_CreateViewWindow3(iface, view_params->psbOwner, view_params->psvPrev,
2042 SV3CVW3_DEFAULT, view_params->pfs->fFlags, view_params->pfs->fFlags,
2043 view_params->pfs->ViewMode, view_params->pvid, view_params->prcView, &view_params->hwndView);
2046 static HRESULT WINAPI IShellView2_fnHandleRename(IShellView3 *iface, LPCITEMIDLIST new_pidl)
2048 FIXME("(%p)->(new_pidl %p) stub!\n", iface, new_pidl);
2049 return E_NOTIMPL;
2052 static HRESULT WINAPI IShellView2_fnSelectAndPositionItem(IShellView3 *iface, LPCITEMIDLIST item,
2053 UINT flags, POINT *point)
2055 IShellViewImpl *This = impl_from_IShellView3(iface);
2056 TRACE("(%p)->(item %p, flags %#x, point %p)\n", This, item, flags, point);
2057 return IFolderView2_SelectAndPositionItems(&This->IFolderView2_iface, 1, &item, point, flags);
2060 static HRESULT WINAPI IShellView3_fnCreateViewWindow3(IShellView3 *iface, IShellBrowser *owner,
2061 IShellView *prev_view, SV3CVW3_FLAGS view_flags, FOLDERFLAGS mask, FOLDERFLAGS flags,
2062 FOLDERVIEWMODE mode, const SHELLVIEWID *view_id, const RECT *rect, HWND *hwnd)
2064 IShellViewImpl *This = impl_from_IShellView3(iface);
2065 INITCOMMONCONTROLSEX icex;
2066 WNDCLASSW wc;
2067 HRESULT hr;
2068 HWND wnd;
2070 TRACE("(%p)->(%p %p 0x%08x 0x%08x 0x%08x %d %s %s %p)\n", This, owner, prev_view, view_flags,
2071 mask, flags, mode, debugstr_guid(view_id), wine_dbgstr_rect(rect), hwnd);
2073 icex.dwSize = sizeof(icex);
2074 icex.dwICC = ICC_LISTVIEW_CLASSES;
2075 InitCommonControlsEx(&icex);
2077 *hwnd = NULL;
2079 if (!owner || This->hWnd)
2080 return E_UNEXPECTED;
2082 if (view_flags != SV3CVW3_DEFAULT)
2083 FIXME("unsupported view flags 0x%08x\n", view_flags);
2085 /* Set up the member variables */
2086 This->pShellBrowser = owner;
2087 This->FolderSettings.ViewMode = mode;
2088 This->FolderSettings.fFlags = mask & flags;
2090 if (view_id)
2092 if (IsEqualGUID(view_id, &VID_LargeIcons))
2093 This->FolderSettings.ViewMode = FVM_ICON;
2094 else if (IsEqualGUID(view_id, &VID_SmallIcons))
2095 This->FolderSettings.ViewMode = FVM_SMALLICON;
2096 else if (IsEqualGUID(view_id, &VID_List))
2097 This->FolderSettings.ViewMode = FVM_LIST;
2098 else if (IsEqualGUID(view_id, &VID_Details))
2099 This->FolderSettings.ViewMode = FVM_DETAILS;
2100 else if (IsEqualGUID(view_id, &VID_Thumbnails))
2101 This->FolderSettings.ViewMode = FVM_THUMBNAIL;
2102 else if (IsEqualGUID(view_id, &VID_Tile))
2103 This->FolderSettings.ViewMode = FVM_TILE;
2104 else if (IsEqualGUID(view_id, &VID_ThumbStrip))
2105 This->FolderSettings.ViewMode = FVM_THUMBSTRIP;
2106 else
2107 FIXME("Ignoring unrecognized VID %s\n", debugstr_guid(view_id));
2110 /* Get our parent window */
2111 IShellBrowser_AddRef(This->pShellBrowser);
2112 IShellBrowser_GetWindow(This->pShellBrowser, &This->hWndParent);
2114 /* Try to get the ICommDlgBrowserInterface, adds a reference !!! */
2115 This->pCommDlgBrowser = NULL;
2116 hr = IShellBrowser_QueryInterface(This->pShellBrowser, &IID_ICommDlgBrowser, (void **)&This->pCommDlgBrowser);
2117 if (hr == S_OK)
2118 TRACE("-- CommDlgBrowser %p\n", This->pCommDlgBrowser);
2120 /* If our window class has not been registered, then do so */
2121 if (!GetClassInfoW(shell32_hInstance, SV_CLASS_NAME, &wc))
2123 wc.style = CS_HREDRAW | CS_VREDRAW;
2124 wc.lpfnWndProc = ShellView_WndProc;
2125 wc.cbClsExtra = 0;
2126 wc.cbWndExtra = 0;
2127 wc.hInstance = shell32_hInstance;
2128 wc.hIcon = 0;
2129 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
2130 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2131 wc.lpszMenuName = NULL;
2132 wc.lpszClassName = SV_CLASS_NAME;
2134 if (!RegisterClassW(&wc)) return E_FAIL;
2137 wnd = CreateWindowExW(0, SV_CLASS_NAME, NULL, WS_CHILD | WS_TABSTOP,
2138 rect->left, rect->top,
2139 rect->right - rect->left,
2140 rect->bottom - rect->top,
2141 This->hWndParent, 0, shell32_hInstance, This);
2143 CheckToolbar(This);
2145 if (!wnd)
2147 IShellBrowser_Release(This->pShellBrowser);
2148 return E_FAIL;
2151 SetWindowPos(wnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
2152 UpdateWindow(wnd);
2154 *hwnd = wnd;
2156 return S_OK;
2159 static const IShellView3Vtbl shellviewvtbl =
2161 IShellView_fnQueryInterface,
2162 IShellView_fnAddRef,
2163 IShellView_fnRelease,
2164 IShellView_fnGetWindow,
2165 IShellView_fnContextSensitiveHelp,
2166 IShellView_fnTranslateAccelerator,
2167 IShellView_fnEnableModeless,
2168 IShellView_fnUIActivate,
2169 IShellView_fnRefresh,
2170 IShellView_fnCreateViewWindow,
2171 IShellView_fnDestroyViewWindow,
2172 IShellView_fnGetCurrentInfo,
2173 IShellView_fnAddPropertySheetPages,
2174 IShellView_fnSaveViewState,
2175 IShellView_fnSelectItem,
2176 IShellView_fnGetItemObject,
2177 IShellView2_fnGetView,
2178 IShellView2_fnCreateViewWindow2,
2179 IShellView2_fnHandleRename,
2180 IShellView2_fnSelectAndPositionItem,
2181 IShellView3_fnCreateViewWindow3
2185 /**********************************************************
2186 * ISVOleCmdTarget_QueryInterface (IUnknown)
2188 static HRESULT WINAPI ISVOleCmdTarget_QueryInterface(IOleCommandTarget *iface, REFIID iid, void **ppvObj)
2190 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2191 return IShellView3_QueryInterface(&This->IShellView3_iface, iid, ppvObj);
2194 /**********************************************************
2195 * ISVOleCmdTarget_AddRef (IUnknown)
2197 static ULONG WINAPI ISVOleCmdTarget_AddRef(IOleCommandTarget *iface)
2199 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2200 return IShellView3_AddRef(&This->IShellView3_iface);
2203 /**********************************************************
2204 * ISVOleCmdTarget_Release (IUnknown)
2206 static ULONG WINAPI ISVOleCmdTarget_Release(IOleCommandTarget *iface)
2208 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2209 return IShellView3_Release(&This->IShellView3_iface);
2212 /**********************************************************
2213 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
2215 static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
2216 IOleCommandTarget *iface,
2217 const GUID *pguidCmdGroup,
2218 ULONG cCmds,
2219 OLECMD *prgCmds,
2220 OLECMDTEXT *pCmdText)
2222 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2223 UINT i;
2225 FIXME("(%p)->(%s %d %p %p)\n",
2226 This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
2228 if (!prgCmds)
2229 return E_INVALIDARG;
2230 for (i = 0; i < cCmds; i++)
2232 FIXME("\tprgCmds[%d].cmdID = %d\n", i, prgCmds[i].cmdID);
2233 prgCmds[i].cmdf = 0;
2235 return OLECMDERR_E_UNKNOWNGROUP;
2238 /**********************************************************
2239 * ISVOleCmdTarget_Exec (IOleCommandTarget)
2241 * nCmdID is the OLECMDID_* enumeration
2243 static HRESULT WINAPI ISVOleCmdTarget_Exec(
2244 IOleCommandTarget *iface,
2245 const GUID* pguidCmdGroup,
2246 DWORD nCmdID,
2247 DWORD nCmdexecopt,
2248 VARIANT* pvaIn,
2249 VARIANT* pvaOut)
2251 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2253 FIXME("(%p)->(%s %d 0x%08x %s %p)\n",
2254 This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, debugstr_variant(pvaIn), pvaOut);
2256 if (!pguidCmdGroup)
2257 return OLECMDERR_E_UNKNOWNGROUP;
2259 if (IsEqualIID(pguidCmdGroup, &CGID_Explorer) &&
2260 (nCmdID == OLECMDID_SHOWMESSAGE) &&
2261 (nCmdexecopt == 4) && pvaOut)
2262 return S_OK;
2263 if (IsEqualIID(pguidCmdGroup, &CGID_ShellDocView) &&
2264 (nCmdID == OLECMDID_SPELL) &&
2265 (nCmdexecopt == OLECMDEXECOPT_DODEFAULT))
2266 return S_FALSE;
2268 return OLECMDERR_E_UNKNOWNGROUP;
2271 static const IOleCommandTargetVtbl olecommandtargetvtbl =
2273 ISVOleCmdTarget_QueryInterface,
2274 ISVOleCmdTarget_AddRef,
2275 ISVOleCmdTarget_Release,
2276 ISVOleCmdTarget_QueryStatus,
2277 ISVOleCmdTarget_Exec
2280 /**********************************************************
2281 * ISVDropTarget implementation
2284 static HRESULT WINAPI ISVDropTarget_QueryInterface(IDropTarget *iface, REFIID riid, void **ppvObj)
2286 IShellViewImpl *This = impl_from_IDropTarget(iface);
2287 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
2290 static ULONG WINAPI ISVDropTarget_AddRef(IDropTarget *iface)
2292 IShellViewImpl *This = impl_from_IDropTarget(iface);
2293 return IShellView3_AddRef(&This->IShellView3_iface);
2296 static ULONG WINAPI ISVDropTarget_Release(IDropTarget *iface)
2298 IShellViewImpl *This = impl_from_IDropTarget(iface);
2299 return IShellView3_Release(&This->IShellView3_iface);
2302 /******************************************************************************
2303 * drag_notify_subitem [Internal]
2305 * Figure out the shellfolder object, which is currently under the mouse cursor
2306 * and notify it via the IDropTarget interface.
2309 #define SCROLLAREAWIDTH 20
2311 static HRESULT drag_notify_subitem(IShellViewImpl *This, DWORD grfKeyState, POINTL pt,
2312 DWORD *pdwEffect)
2314 LVHITTESTINFO htinfo;
2315 LVITEMW lvItem;
2316 LONG lResult;
2317 HRESULT hr;
2318 RECT clientRect;
2320 /* Map from global to client coordinates and query the index of the listview-item, which is
2321 * currently under the mouse cursor. */
2322 htinfo.pt.x = pt.x;
2323 htinfo.pt.y = pt.y;
2324 htinfo.flags = LVHT_ONITEM;
2325 ScreenToClient(This->hWndList, &htinfo.pt);
2326 lResult = SendMessageW(This->hWndList, LVM_HITTEST, 0, (LPARAM)&htinfo);
2328 /* Send WM_*SCROLL messages every 250 ms during drag-scrolling */
2329 GetClientRect(This->hWndList, &clientRect);
2330 if (htinfo.pt.x == This->ptLastMousePos.x && htinfo.pt.y == This->ptLastMousePos.y &&
2331 (htinfo.pt.x < SCROLLAREAWIDTH || htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH ||
2332 htinfo.pt.y < SCROLLAREAWIDTH || htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH ))
2334 This->cScrollDelay = (This->cScrollDelay + 1) % 5; /* DragOver is called every 50 ms */
2335 if (This->cScrollDelay == 0) { /* Mouse did hover another 250 ms over the scroll-area */
2336 if (htinfo.pt.x < SCROLLAREAWIDTH)
2337 SendMessageW(This->hWndList, WM_HSCROLL, SB_LINEUP, 0);
2338 if (htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH)
2339 SendMessageW(This->hWndList, WM_HSCROLL, SB_LINEDOWN, 0);
2340 if (htinfo.pt.y < SCROLLAREAWIDTH)
2341 SendMessageW(This->hWndList, WM_VSCROLL, SB_LINEUP, 0);
2342 if (htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH)
2343 SendMessageW(This->hWndList, WM_VSCROLL, SB_LINEDOWN, 0);
2345 } else {
2346 This->cScrollDelay = 0; /* Reset, if the cursor is not over the listview's scroll-area */
2348 This->ptLastMousePos = htinfo.pt;
2350 /* If we are still over the previous sub-item, notify it via DragOver and return. */
2351 if (This->pCurDropTarget && lResult == This->iDragOverItem)
2352 return IDropTarget_DragOver(This->pCurDropTarget, grfKeyState, pt, pdwEffect);
2354 /* We've left the previous sub-item, notify it via DragLeave and Release it. */
2355 if (This->pCurDropTarget) {
2356 IDropTarget_DragLeave(This->pCurDropTarget);
2357 IDropTarget_Release(This->pCurDropTarget);
2358 This->pCurDropTarget = NULL;
2361 This->iDragOverItem = lResult;
2362 if (lResult == -1) {
2363 /* We are not above one of the listview's subitems. Bind to the parent folder's
2364 * DropTarget interface. */
2365 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IDropTarget,
2366 (LPVOID*)&This->pCurDropTarget);
2367 } else {
2368 /* Query the relative PIDL of the shellfolder object represented by the currently
2369 * dragged over listview-item ... */
2370 lvItem.mask = LVIF_PARAM;
2371 lvItem.iItem = lResult;
2372 lvItem.iSubItem = 0;
2373 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
2375 /* ... and bind pCurDropTarget to the IDropTarget interface of an UIObject of this object */
2376 hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWndList, 1,
2377 (LPCITEMIDLIST*)&lvItem.lParam, &IID_IDropTarget, NULL, (LPVOID*)&This->pCurDropTarget);
2380 /* If anything failed, pCurDropTarget should be NULL now, which ought to be a save state. */
2381 if (FAILED(hr))
2382 return hr;
2384 /* Notify the item just entered via DragEnter. */
2385 return IDropTarget_DragEnter(This->pCurDropTarget, This->pCurDataObject, grfKeyState, pt, pdwEffect);
2388 static HRESULT WINAPI ISVDropTarget_DragEnter(IDropTarget *iface, IDataObject *pDataObject,
2389 DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2391 IShellViewImpl *This = impl_from_IDropTarget(iface);
2393 /* Get a hold on the data object for later calls to DragEnter on the sub-folders */
2394 This->pCurDataObject = pDataObject;
2395 IDataObject_AddRef(pDataObject);
2397 return drag_notify_subitem(This, grfKeyState, pt, pdwEffect);
2400 static HRESULT WINAPI ISVDropTarget_DragOver(IDropTarget *iface, DWORD grfKeyState, POINTL pt,
2401 DWORD *pdwEffect)
2403 IShellViewImpl *This = impl_from_IDropTarget(iface);
2404 return drag_notify_subitem(This, grfKeyState, pt, pdwEffect);
2407 static HRESULT WINAPI ISVDropTarget_DragLeave(IDropTarget *iface)
2409 IShellViewImpl *This = impl_from_IDropTarget(iface);
2411 if (This->pCurDropTarget)
2413 IDropTarget_DragLeave(This->pCurDropTarget);
2414 IDropTarget_Release(This->pCurDropTarget);
2415 This->pCurDropTarget = NULL;
2418 if (This->pCurDataObject)
2420 IDataObject_Release(This->pCurDataObject);
2421 This->pCurDataObject = NULL;
2424 This->iDragOverItem = 0;
2426 return S_OK;
2429 static HRESULT WINAPI ISVDropTarget_Drop(IDropTarget *iface, IDataObject* pDataObject,
2430 DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2432 IShellViewImpl *This = impl_from_IDropTarget(iface);
2434 if (!This->pCurDropTarget) return DRAGDROP_E_INVALIDHWND;
2436 IDropTarget_Drop(This->pCurDropTarget, pDataObject, grfKeyState, pt, pdwEffect);
2438 IDropTarget_Release(This->pCurDropTarget);
2439 IDataObject_Release(This->pCurDataObject);
2440 This->pCurDataObject = NULL;
2441 This->pCurDropTarget = NULL;
2442 This->iDragOverItem = 0;
2444 return S_OK;
2447 static const IDropTargetVtbl droptargetvtbl =
2449 ISVDropTarget_QueryInterface,
2450 ISVDropTarget_AddRef,
2451 ISVDropTarget_Release,
2452 ISVDropTarget_DragEnter,
2453 ISVDropTarget_DragOver,
2454 ISVDropTarget_DragLeave,
2455 ISVDropTarget_Drop
2458 /**********************************************************
2459 * ISVDropSource implementation
2462 static HRESULT WINAPI ISVDropSource_QueryInterface(IDropSource *iface, REFIID riid, void **ppvObj)
2464 IShellViewImpl *This = impl_from_IDropSource(iface);
2465 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
2468 static ULONG WINAPI ISVDropSource_AddRef(IDropSource *iface)
2470 IShellViewImpl *This = impl_from_IDropSource(iface);
2471 return IShellView3_AddRef(&This->IShellView3_iface);
2474 static ULONG WINAPI ISVDropSource_Release(IDropSource *iface)
2476 IShellViewImpl *This = impl_from_IDropSource(iface);
2477 return IShellView3_Release(&This->IShellView3_iface);
2480 static HRESULT WINAPI ISVDropSource_QueryContinueDrag(
2481 IDropSource *iface,
2482 BOOL fEscapePressed,
2483 DWORD grfKeyState)
2485 IShellViewImpl *This = impl_from_IDropSource(iface);
2486 TRACE("(%p)\n",This);
2488 if (fEscapePressed)
2489 return DRAGDROP_S_CANCEL;
2490 else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
2491 return DRAGDROP_S_DROP;
2492 else
2493 return S_OK;
2496 static HRESULT WINAPI ISVDropSource_GiveFeedback(
2497 IDropSource *iface,
2498 DWORD dwEffect)
2500 IShellViewImpl *This = impl_from_IDropSource(iface);
2501 TRACE("(%p)\n",This);
2503 return DRAGDROP_S_USEDEFAULTCURSORS;
2506 static const IDropSourceVtbl dropsourcevtbl =
2508 ISVDropSource_QueryInterface,
2509 ISVDropSource_AddRef,
2510 ISVDropSource_Release,
2511 ISVDropSource_QueryContinueDrag,
2512 ISVDropSource_GiveFeedback
2514 /**********************************************************
2515 * ISVViewObject implementation
2518 static HRESULT WINAPI ISVViewObject_QueryInterface(IViewObject *iface, REFIID riid, void **ppvObj)
2520 IShellViewImpl *This = impl_from_IViewObject(iface);
2521 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
2524 static ULONG WINAPI ISVViewObject_AddRef(IViewObject *iface)
2526 IShellViewImpl *This = impl_from_IViewObject(iface);
2527 return IShellView3_AddRef(&This->IShellView3_iface);
2530 static ULONG WINAPI ISVViewObject_Release(IViewObject *iface)
2532 IShellViewImpl *This = impl_from_IViewObject(iface);
2533 return IShellView3_Release(&This->IShellView3_iface);
2536 static HRESULT WINAPI ISVViewObject_Draw(
2537 IViewObject *iface,
2538 DWORD dwDrawAspect,
2539 LONG lindex,
2540 void* pvAspect,
2541 DVTARGETDEVICE* ptd,
2542 HDC hdcTargetDev,
2543 HDC hdcDraw,
2544 LPCRECTL lprcBounds,
2545 LPCRECTL lprcWBounds,
2546 BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue),
2547 ULONG_PTR dwContinue)
2550 IShellViewImpl *This = impl_from_IViewObject(iface);
2552 FIXME("Stub: This=%p\n",This);
2554 return E_NOTIMPL;
2556 static HRESULT WINAPI ISVViewObject_GetColorSet(
2557 IViewObject *iface,
2558 DWORD dwDrawAspect,
2559 LONG lindex,
2560 void *pvAspect,
2561 DVTARGETDEVICE* ptd,
2562 HDC hicTargetDevice,
2563 LOGPALETTE** ppColorSet)
2566 IShellViewImpl *This = impl_from_IViewObject(iface);
2568 FIXME("Stub: This=%p\n",This);
2570 return E_NOTIMPL;
2572 static HRESULT WINAPI ISVViewObject_Freeze(
2573 IViewObject *iface,
2574 DWORD dwDrawAspect,
2575 LONG lindex,
2576 void* pvAspect,
2577 DWORD* pdwFreeze)
2580 IShellViewImpl *This = impl_from_IViewObject(iface);
2582 FIXME("Stub: This=%p\n",This);
2584 return E_NOTIMPL;
2586 static HRESULT WINAPI ISVViewObject_Unfreeze(
2587 IViewObject *iface,
2588 DWORD dwFreeze)
2591 IShellViewImpl *This = impl_from_IViewObject(iface);
2593 FIXME("Stub: This=%p\n",This);
2595 return E_NOTIMPL;
2597 static HRESULT WINAPI ISVViewObject_SetAdvise(
2598 IViewObject *iface,
2599 DWORD aspects,
2600 DWORD advf,
2601 IAdviseSink* pAdvSink)
2604 IShellViewImpl *This = impl_from_IViewObject(iface);
2606 FIXME("partial stub: %p %08x %08x %p\n",
2607 This, aspects, advf, pAdvSink);
2609 /* FIXME: we set the AdviseSink, but never use it to send any advice */
2610 This->pAdvSink = pAdvSink;
2611 This->dwAspects = aspects;
2612 This->dwAdvf = advf;
2614 return S_OK;
2617 static HRESULT WINAPI ISVViewObject_GetAdvise(
2618 IViewObject *iface,
2619 DWORD* pAspects,
2620 DWORD* pAdvf,
2621 IAdviseSink** ppAdvSink)
2624 IShellViewImpl *This = impl_from_IViewObject(iface);
2626 TRACE("This=%p pAspects=%p pAdvf=%p ppAdvSink=%p\n",
2627 This, pAspects, pAdvf, ppAdvSink);
2629 if( ppAdvSink )
2631 IAdviseSink_AddRef( This->pAdvSink );
2632 *ppAdvSink = This->pAdvSink;
2634 if( pAspects )
2635 *pAspects = This->dwAspects;
2636 if( pAdvf )
2637 *pAdvf = This->dwAdvf;
2639 return S_OK;
2643 static const IViewObjectVtbl viewobjectvtbl =
2645 ISVViewObject_QueryInterface,
2646 ISVViewObject_AddRef,
2647 ISVViewObject_Release,
2648 ISVViewObject_Draw,
2649 ISVViewObject_GetColorSet,
2650 ISVViewObject_Freeze,
2651 ISVViewObject_Unfreeze,
2652 ISVViewObject_SetAdvise,
2653 ISVViewObject_GetAdvise
2656 /* IFolderView2 */
2657 static HRESULT WINAPI FolderView_QueryInterface(IFolderView2 *iface, REFIID riid, void **ppvObj)
2659 IShellViewImpl *This = impl_from_IFolderView2(iface);
2660 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
2663 static ULONG WINAPI FolderView_AddRef(IFolderView2 *iface)
2665 IShellViewImpl *This = impl_from_IFolderView2(iface);
2666 return IShellView3_AddRef(&This->IShellView3_iface);
2669 static ULONG WINAPI FolderView_Release(IFolderView2 *iface)
2671 IShellViewImpl *This = impl_from_IFolderView2(iface);
2672 return IShellView3_Release(&This->IShellView3_iface);
2675 static HRESULT WINAPI FolderView_GetCurrentViewMode(IFolderView2 *iface, UINT *mode)
2677 IShellViewImpl *This = impl_from_IFolderView2(iface);
2678 TRACE("(%p)->(%p), stub\n", This, mode);
2680 if(!mode)
2681 return E_INVALIDARG;
2683 *mode = This->FolderSettings.ViewMode;
2684 return S_OK;
2687 static HRESULT WINAPI FolderView_SetCurrentViewMode(IFolderView2 *iface, UINT mode)
2689 IShellViewImpl *This = impl_from_IFolderView2(iface);
2690 DWORD dwStyle;
2691 TRACE("(%p)->(%u), stub\n", This, mode);
2693 if((mode < FVM_FIRST || mode > FVM_LAST) &&
2694 (mode != FVM_AUTO))
2695 return E_INVALIDARG;
2697 /* Windows before Vista uses LVM_SETVIEW and possibly
2698 LVM_SETEXTENDEDLISTVIEWSTYLE to set the style of the listview,
2699 while later versions seem to accomplish this through other
2700 means. */
2701 dwStyle = ViewModeToListStyle(mode);
2702 SetStyle(This, dwStyle, LVS_TYPEMASK);
2704 /* This will not necessarily be the actual mode set above.
2705 This mimics the behavior of Windows XP. */
2706 This->FolderSettings.ViewMode = mode;
2708 return S_OK;
2711 static HRESULT WINAPI FolderView_GetFolder(IFolderView2 *iface, REFIID riid, void **ppv)
2713 IShellViewImpl *This = impl_from_IFolderView2(iface);
2715 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
2717 return IShellFolder_QueryInterface(This->pSFParent, riid, ppv);
2720 static HRESULT WINAPI FolderView_Item(IFolderView2 *iface, int index, PITEMID_CHILD *ppidl)
2722 IShellViewImpl *This = impl_from_IFolderView2(iface);
2723 LVITEMW item;
2725 TRACE("(%p)->(%d %p)\n", This, index, ppidl);
2727 item.mask = LVIF_PARAM;
2728 item.iItem = index;
2730 if (SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM)&item))
2732 *ppidl = ILClone((PITEMID_CHILD)item.lParam);
2733 return S_OK;
2735 else
2737 *ppidl = 0;
2738 return E_INVALIDARG;
2742 static HRESULT WINAPI FolderView_ItemCount(IFolderView2 *iface, UINT flags, int *items)
2744 IShellViewImpl *This = impl_from_IFolderView2(iface);
2746 TRACE("(%p)->(%u %p)\n", This, flags, items);
2748 if (flags != SVGIO_ALLVIEW)
2749 FIXME("some flags unsupported, %x\n", flags & ~SVGIO_ALLVIEW);
2751 *items = SendMessageW(This->hWndList, LVM_GETITEMCOUNT, 0, 0);
2753 return S_OK;
2756 static HRESULT WINAPI FolderView_Items(IFolderView2 *iface, UINT flags, REFIID riid, void **ppv)
2758 IShellViewImpl *This = impl_from_IFolderView2(iface);
2759 FIXME("(%p)->(%u %s %p), stub\n", This, flags, debugstr_guid(riid), ppv);
2760 return E_NOTIMPL;
2763 static HRESULT WINAPI FolderView_GetSelectionMarkedItem(IFolderView2 *iface, int *item)
2765 IShellViewImpl *This = impl_from_IFolderView2(iface);
2767 TRACE("(%p)->(%p)\n", This, item);
2769 *item = SendMessageW(This->hWndList, LVM_GETSELECTIONMARK, 0, 0);
2771 return S_OK;
2774 static HRESULT WINAPI FolderView_GetFocusedItem(IFolderView2 *iface, int *item)
2776 IShellViewImpl *This = impl_from_IFolderView2(iface);
2778 TRACE("(%p)->(%p)\n", This, item);
2780 *item = SendMessageW(This->hWndList, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
2782 return S_OK;
2785 static HRESULT WINAPI FolderView_GetItemPosition(IFolderView2 *iface, PCUITEMID_CHILD pidl, POINT *ppt)
2787 IShellViewImpl *This = impl_from_IFolderView2(iface);
2788 FIXME("(%p)->(%p %p), stub\n", This, pidl, ppt);
2789 return E_NOTIMPL;
2792 static HRESULT WINAPI FolderView_GetSpacing(IFolderView2 *iface, POINT *pt)
2794 IShellViewImpl *This = impl_from_IFolderView2(iface);
2796 TRACE("(%p)->(%p)\n", This, pt);
2798 if (!This->hWndList) return S_FALSE;
2800 if (pt)
2802 DWORD ret;
2803 ret = SendMessageW(This->hWndList, LVM_GETITEMSPACING, 0, 0);
2805 pt->x = LOWORD(ret);
2806 pt->y = HIWORD(ret);
2809 return S_OK;
2812 static HRESULT WINAPI FolderView_GetDefaultSpacing(IFolderView2 *iface, POINT *pt)
2814 IShellViewImpl *This = impl_from_IFolderView2(iface);
2815 FIXME("(%p)->(%p), stub\n", This, pt);
2816 return E_NOTIMPL;
2819 static HRESULT WINAPI FolderView_GetAutoArrange(IFolderView2 *iface)
2821 IShellViewImpl *This = impl_from_IFolderView2(iface);
2822 FIXME("(%p), stub\n", This);
2823 return E_NOTIMPL;
2826 static HRESULT WINAPI FolderView_SelectItem(IFolderView2 *iface, int item, DWORD flags)
2828 IShellViewImpl *This = impl_from_IFolderView2(iface);
2829 LVITEMW lvItem;
2831 TRACE("(%p)->(%d, %x)\n", This, item, flags);
2833 lvItem.state = 0;
2834 lvItem.stateMask = LVIS_SELECTED;
2836 if (flags & SVSI_ENSUREVISIBLE)
2837 SendMessageW(This->hWndList, LVM_ENSUREVISIBLE, item, 0);
2839 /* all items */
2840 if (flags & SVSI_DESELECTOTHERS)
2841 SendMessageW(This->hWndList, LVM_SETITEMSTATE, -1, (LPARAM)&lvItem);
2843 /* this item */
2844 if (flags & SVSI_SELECT)
2845 lvItem.state |= LVIS_SELECTED;
2847 if (flags & SVSI_FOCUSED)
2848 lvItem.stateMask |= LVIS_FOCUSED;
2850 SendMessageW(This->hWndList, LVM_SETITEMSTATE, item, (LPARAM)&lvItem);
2852 if (flags & SVSI_EDIT)
2853 SendMessageW(This->hWndList, LVM_EDITLABELW, item, 0);
2855 return S_OK;
2858 static HRESULT WINAPI FolderView_SelectAndPositionItems(IFolderView2 *iface, UINT cidl,
2859 PCUITEMID_CHILD_ARRAY apidl, POINT *apt, DWORD flags)
2861 IShellViewImpl *This = impl_from_IFolderView2(iface);
2862 FIXME("(%p)->(%u %p %p %x), stub\n", This, cidl, apidl, apt, flags);
2863 return E_NOTIMPL;
2866 static HRESULT WINAPI FolderView2_SetGroupBy(IFolderView2 *iface, REFPROPERTYKEY key, BOOL ascending)
2868 IShellViewImpl *This = impl_from_IFolderView2(iface);
2869 FIXME("(%p)->(%p %d), stub\n", This, key, ascending);
2870 return E_NOTIMPL;
2873 static HRESULT WINAPI FolderView2_GetGroupBy(IFolderView2 *iface, PROPERTYKEY *pkey, BOOL *ascending)
2875 IShellViewImpl *This = impl_from_IFolderView2(iface);
2876 FIXME("(%p)->(%p %p), stub\n", This, pkey, ascending);
2877 return E_NOTIMPL;
2880 static HRESULT WINAPI FolderView2_SetViewProperty(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2881 REFPROPERTYKEY propkey, REFPROPVARIANT propvar)
2883 IShellViewImpl *This = impl_from_IFolderView2(iface);
2884 FIXME("(%p)->(%p %p %p), stub\n", This, pidl, propkey, propvar);
2885 return E_NOTIMPL;
2888 static HRESULT WINAPI FolderView2_GetViewProperty(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2889 REFPROPERTYKEY propkey, PROPVARIANT *propvar)
2891 IShellViewImpl *This = impl_from_IFolderView2(iface);
2892 FIXME("(%p)->(%p %p %p), stub\n", This, pidl, propkey, propvar);
2893 return E_NOTIMPL;
2896 static HRESULT WINAPI FolderView2_SetTileViewProperties(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2897 LPCWSTR prop_list)
2899 IShellViewImpl *This = impl_from_IFolderView2(iface);
2900 FIXME("(%p)->(%p %s), stub\n", This, pidl, debugstr_w(prop_list));
2901 return E_NOTIMPL;
2904 static HRESULT WINAPI FolderView2_SetExtendedTileViewProperties(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2905 LPCWSTR prop_list)
2907 IShellViewImpl *This = impl_from_IFolderView2(iface);
2908 FIXME("(%p)->(%p %s), stub\n", This, pidl, debugstr_w(prop_list));
2909 return E_NOTIMPL;
2912 static HRESULT WINAPI FolderView2_SetText(IFolderView2 *iface, FVTEXTTYPE type, LPCWSTR text)
2914 IShellViewImpl *This = impl_from_IFolderView2(iface);
2915 FIXME("(%p)->(%d %s), stub\n", This, type, debugstr_w(text));
2916 return E_NOTIMPL;
2919 static HRESULT WINAPI FolderView2_SetCurrentFolderFlags(IFolderView2 *iface, DWORD mask, DWORD flags)
2921 IShellViewImpl *This = impl_from_IFolderView2(iface);
2922 FIXME("(%p)->(0x%08x 0x%08x), stub\n", This, mask, flags);
2923 return E_NOTIMPL;
2926 static HRESULT WINAPI FolderView2_GetCurrentFolderFlags(IFolderView2 *iface, DWORD *flags)
2928 IShellViewImpl *This = impl_from_IFolderView2(iface);
2929 FIXME("(%p)->(%p), stub\n", This, flags);
2930 return E_NOTIMPL;
2933 static HRESULT WINAPI FolderView2_GetSortColumnCount(IFolderView2 *iface, int *columns)
2935 IShellViewImpl *This = impl_from_IFolderView2(iface);
2936 FIXME("(%p)->(%p), stub\n", This, columns);
2937 return E_NOTIMPL;
2940 static HRESULT WINAPI FolderView2_SetSortColumns(IFolderView2 *iface, const SORTCOLUMN *columns,
2941 int count)
2943 IShellViewImpl *This = impl_from_IFolderView2(iface);
2944 FIXME("(%p)->(%p %d), stub\n", This, columns, count);
2945 return E_NOTIMPL;
2948 static HRESULT WINAPI FolderView2_GetSortColumns(IFolderView2 *iface, SORTCOLUMN *columns,
2949 int count)
2951 IShellViewImpl *This = impl_from_IFolderView2(iface);
2952 FIXME("(%p)->(%p %d), stub\n", This, columns, count);
2953 return E_NOTIMPL;
2956 static HRESULT WINAPI FolderView2_GetItem(IFolderView2 *iface, int item, REFIID riid, void **ppv)
2958 IShellViewImpl *This = impl_from_IFolderView2(iface);
2959 FIXME("(%p)->(%d %s %p), stub\n", This, item, debugstr_guid(riid), ppv);
2960 return E_NOTIMPL;
2963 static HRESULT WINAPI FolderView2_GetVisibleItem(IFolderView2 *iface, int start, BOOL previous,
2964 int *item)
2966 IShellViewImpl *This = impl_from_IFolderView2(iface);
2967 FIXME("(%p)->(%d %d %p), stub\n", This, start, previous, item);
2968 return E_NOTIMPL;
2971 static HRESULT WINAPI FolderView2_GetSelectedItem(IFolderView2 *iface, int start, int *item)
2973 IShellViewImpl *This = impl_from_IFolderView2(iface);
2974 FIXME("(%p)->(%d %p), stub\n", This, start, item);
2975 return E_NOTIMPL;
2978 static HRESULT WINAPI FolderView2_GetSelection(IFolderView2 *iface, BOOL none_implies_folder,
2979 IShellItemArray **array)
2981 IShellViewImpl *This = impl_from_IFolderView2(iface);
2982 FIXME("(%p)->(%d %p), stub\n", This, none_implies_folder, array);
2983 return E_NOTIMPL;
2986 static HRESULT WINAPI FolderView2_GetSelectionState(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2987 DWORD *flags)
2989 IShellViewImpl *This = impl_from_IFolderView2(iface);
2990 FIXME("(%p)->(%p %p), stub\n", This, pidl, flags);
2991 return E_NOTIMPL;
2994 static HRESULT WINAPI FolderView2_InvokeVerbOnSelection(IFolderView2 *iface, LPCSTR verb)
2996 IShellViewImpl *This = impl_from_IFolderView2(iface);
2997 FIXME("(%p)->(%s), stub\n", This, debugstr_a(verb));
2998 return E_NOTIMPL;
3001 static HRESULT WINAPI FolderView2_SetViewModeAndIconSize(IFolderView2 *iface, FOLDERVIEWMODE mode,
3002 int size)
3004 IShellViewImpl *This = impl_from_IFolderView2(iface);
3005 FIXME("(%p)->(%d %d), stub\n", This, mode, size);
3006 return E_NOTIMPL;
3009 static HRESULT WINAPI FolderView2_GetViewModeAndIconSize(IFolderView2 *iface, FOLDERVIEWMODE *mode,
3010 int *size)
3012 IShellViewImpl *This = impl_from_IFolderView2(iface);
3013 FIXME("(%p)->(%p %p), stub\n", This, mode, size);
3014 return E_NOTIMPL;
3017 static HRESULT WINAPI FolderView2_SetGroupSubsetCount(IFolderView2 *iface, UINT visible_rows)
3019 IShellViewImpl *This = impl_from_IFolderView2(iface);
3020 FIXME("(%p)->(%u), stub\n", This, visible_rows);
3021 return E_NOTIMPL;
3024 static HRESULT WINAPI FolderView2_GetGroupSubsetCount(IFolderView2 *iface, UINT *visible_rows)
3026 IShellViewImpl *This = impl_from_IFolderView2(iface);
3027 FIXME("(%p)->(%p), stub\n", This, visible_rows);
3028 return E_NOTIMPL;
3031 static HRESULT WINAPI FolderView2_SetRedraw(IFolderView2 *iface, BOOL redraw)
3033 IShellViewImpl *This = impl_from_IFolderView2(iface);
3034 TRACE("(%p)->(%d)\n", This, redraw);
3035 SendMessageW(This->hWndList, WM_SETREDRAW, redraw, 0);
3036 return S_OK;
3039 static HRESULT WINAPI FolderView2_IsMoveInSameFolder(IFolderView2 *iface)
3041 IShellViewImpl *This = impl_from_IFolderView2(iface);
3042 FIXME("(%p), stub\n", This);
3043 return E_NOTIMPL;
3046 static HRESULT WINAPI FolderView2_DoRename(IFolderView2 *iface)
3048 IShellViewImpl *This = impl_from_IFolderView2(iface);
3049 FIXME("(%p), stub\n", This);
3050 return E_NOTIMPL;
3053 static const IFolderView2Vtbl folderviewvtbl =
3055 FolderView_QueryInterface,
3056 FolderView_AddRef,
3057 FolderView_Release,
3058 FolderView_GetCurrentViewMode,
3059 FolderView_SetCurrentViewMode,
3060 FolderView_GetFolder,
3061 FolderView_Item,
3062 FolderView_ItemCount,
3063 FolderView_Items,
3064 FolderView_GetSelectionMarkedItem,
3065 FolderView_GetFocusedItem,
3066 FolderView_GetItemPosition,
3067 FolderView_GetSpacing,
3068 FolderView_GetDefaultSpacing,
3069 FolderView_GetAutoArrange,
3070 FolderView_SelectItem,
3071 FolderView_SelectAndPositionItems,
3072 FolderView2_SetGroupBy,
3073 FolderView2_GetGroupBy,
3074 FolderView2_SetViewProperty,
3075 FolderView2_GetViewProperty,
3076 FolderView2_SetTileViewProperties,
3077 FolderView2_SetExtendedTileViewProperties,
3078 FolderView2_SetText,
3079 FolderView2_SetCurrentFolderFlags,
3080 FolderView2_GetCurrentFolderFlags,
3081 FolderView2_GetSortColumnCount,
3082 FolderView2_SetSortColumns,
3083 FolderView2_GetSortColumns,
3084 FolderView2_GetItem,
3085 FolderView2_GetVisibleItem,
3086 FolderView2_GetSelectedItem,
3087 FolderView2_GetSelection,
3088 FolderView2_GetSelectionState,
3089 FolderView2_InvokeVerbOnSelection,
3090 FolderView2_SetViewModeAndIconSize,
3091 FolderView2_GetViewModeAndIconSize,
3092 FolderView2_SetGroupSubsetCount,
3093 FolderView2_GetGroupSubsetCount,
3094 FolderView2_SetRedraw,
3095 FolderView2_IsMoveInSameFolder,
3096 FolderView2_DoRename
3099 /* IShellFolderView */
3100 static HRESULT WINAPI IShellFolderView_fnQueryInterface(IShellFolderView *iface, REFIID riid, void **ppvObj)
3102 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3103 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
3106 static ULONG WINAPI IShellFolderView_fnAddRef(IShellFolderView *iface)
3108 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3109 return IShellView3_AddRef(&This->IShellView3_iface);
3112 static ULONG WINAPI IShellFolderView_fnRelease(IShellFolderView *iface)
3114 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3115 return IShellView3_Release(&This->IShellView3_iface);
3118 static HRESULT WINAPI IShellFolderView_fnRearrange(IShellFolderView *iface, LPARAM sort)
3120 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3121 FIXME("(%p)->(%ld) stub\n", This, sort);
3122 return E_NOTIMPL;
3125 static HRESULT WINAPI IShellFolderView_fnGetArrangeParam(IShellFolderView *iface, LPARAM *sort)
3127 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3128 FIXME("(%p)->(%p) stub\n", This, sort);
3129 return E_NOTIMPL;
3132 static HRESULT WINAPI IShellFolderView_fnArrangeGrid(IShellFolderView *iface)
3134 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3135 FIXME("(%p) stub\n", This);
3136 return E_NOTIMPL;
3139 static HRESULT WINAPI IShellFolderView_fnAutoArrange(IShellFolderView *iface)
3141 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3142 TRACE("(%p)\n", This);
3143 return IFolderView2_SetCurrentFolderFlags(&This->IFolderView2_iface, FWF_AUTOARRANGE, FWF_AUTOARRANGE);
3146 static HRESULT WINAPI IShellFolderView_fnGetAutoArrange(IShellFolderView *iface)
3148 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3149 TRACE("(%p)\n", This);
3150 return IFolderView2_GetAutoArrange(&This->IFolderView2_iface);
3153 static HRESULT WINAPI IShellFolderView_fnAddObject(
3154 IShellFolderView *iface,
3155 PITEMID_CHILD pidl,
3156 UINT *item)
3158 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3159 FIXME("(%p)->(%p %p) stub\n", This, pidl, item);
3160 return E_NOTIMPL;
3163 static HRESULT WINAPI IShellFolderView_fnGetObject(
3164 IShellFolderView *iface,
3165 PITEMID_CHILD *pidl,
3166 UINT item)
3168 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3169 TRACE("(%p)->(%p %d)\n", This, pidl, item);
3170 return IFolderView2_Item(&This->IFolderView2_iface, item, pidl);
3173 static HRESULT WINAPI IShellFolderView_fnRemoveObject(
3174 IShellFolderView *iface,
3175 PITEMID_CHILD pidl,
3176 UINT *item)
3178 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3180 TRACE("(%p)->(%p %p)\n", This, pidl, item);
3182 if (pidl)
3184 *item = LV_FindItemByPidl(This, ILFindLastID(pidl));
3185 SendMessageW(This->hWndList, LVM_DELETEITEM, *item, 0);
3187 else
3189 *item = 0;
3190 SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0);
3193 return S_OK;
3196 static HRESULT WINAPI IShellFolderView_fnGetObjectCount(
3197 IShellFolderView *iface,
3198 UINT *count)
3200 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3201 TRACE("(%p)->(%p)\n", This, count);
3202 return IFolderView2_ItemCount(&This->IFolderView2_iface, SVGIO_ALLVIEW, (INT*)count);
3205 static HRESULT WINAPI IShellFolderView_fnSetObjectCount(
3206 IShellFolderView *iface,
3207 UINT count,
3208 UINT flags)
3210 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3211 FIXME("(%p)->(%d %x) stub\n", This, count, flags);
3212 return E_NOTIMPL;
3215 static HRESULT WINAPI IShellFolderView_fnUpdateObject(
3216 IShellFolderView *iface,
3217 PITEMID_CHILD pidl_old,
3218 PITEMID_CHILD pidl_new,
3219 UINT *item)
3221 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3222 FIXME("(%p)->(%p %p %p) stub\n", This, pidl_old, pidl_new, item);
3223 return E_NOTIMPL;
3226 static HRESULT WINAPI IShellFolderView_fnRefreshObject(
3227 IShellFolderView *iface,
3228 PITEMID_CHILD pidl,
3229 UINT *item)
3231 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3232 FIXME("(%p)->(%p %p) stub\n", This, pidl, item);
3233 return E_NOTIMPL;
3236 static HRESULT WINAPI IShellFolderView_fnSetRedraw(
3237 IShellFolderView *iface,
3238 BOOL redraw)
3240 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3241 TRACE("(%p)->(%d)\n", This, redraw);
3242 return IFolderView2_SetRedraw(&This->IFolderView2_iface, redraw);
3245 static HRESULT WINAPI IShellFolderView_fnGetSelectedCount(
3246 IShellFolderView *iface,
3247 UINT *count)
3249 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3250 IShellItemArray *selection;
3251 HRESULT hr;
3253 TRACE("(%p)->(%p)\n", This, count);
3255 *count = 0;
3256 hr = IFolderView2_GetSelection(&This->IFolderView2_iface, FALSE, &selection);
3257 if (FAILED(hr))
3258 return hr;
3260 hr = IShellItemArray_GetCount(selection, count);
3261 IShellItemArray_Release(selection);
3262 return hr;
3265 static HRESULT WINAPI IShellFolderView_fnGetSelectedObjects(
3266 IShellFolderView *iface,
3267 PCITEMID_CHILD **pidl,
3268 UINT *items)
3270 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3272 TRACE("(%p)->(%p %p)\n", This, pidl, items);
3274 *items = ShellView_GetSelections( This );
3276 if (*items)
3278 *pidl = LocalAlloc(0, *items*sizeof(LPITEMIDLIST));
3279 if (!*pidl) return E_OUTOFMEMORY;
3281 /* it's documented that caller shouldn't free PIDLs, only array itself */
3282 memcpy((PITEMID_CHILD*)*pidl, This->apidl, *items*sizeof(LPITEMIDLIST));
3285 return S_OK;
3288 static HRESULT WINAPI IShellFolderView_fnIsDropOnSource(
3289 IShellFolderView *iface,
3290 IDropTarget *drop_target)
3292 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3293 FIXME("(%p)->(%p) stub\n", This, drop_target);
3294 return E_NOTIMPL;
3297 static HRESULT WINAPI IShellFolderView_fnGetDragPoint(
3298 IShellFolderView *iface,
3299 POINT *pt)
3301 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3302 FIXME("(%p)->(%p) stub\n", This, pt);
3303 return E_NOTIMPL;
3306 static HRESULT WINAPI IShellFolderView_fnGetDropPoint(
3307 IShellFolderView *iface,
3308 POINT *pt)
3310 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3311 FIXME("(%p)->(%p) stub\n", This, pt);
3312 return E_NOTIMPL;
3315 static HRESULT WINAPI IShellFolderView_fnMoveIcons(
3316 IShellFolderView *iface,
3317 IDataObject *obj)
3319 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3320 TRACE("(%p)->(%p)\n", This, obj);
3321 return E_NOTIMPL;
3324 static HRESULT WINAPI IShellFolderView_fnSetItemPos(
3325 IShellFolderView *iface,
3326 PCUITEMID_CHILD pidl,
3327 POINT *pt)
3329 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3330 FIXME("(%p)->(%p %p) stub\n", This, pidl, pt);
3331 return E_NOTIMPL;
3334 static HRESULT WINAPI IShellFolderView_fnIsBkDropTarget(
3335 IShellFolderView *iface,
3336 IDropTarget *drop_target)
3338 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3339 FIXME("(%p)->(%p) stub\n", This, drop_target);
3340 return E_NOTIMPL;
3343 static HRESULT WINAPI IShellFolderView_fnSetClipboard(
3344 IShellFolderView *iface,
3345 BOOL move)
3347 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3348 FIXME("(%p)->(%d) stub\n", This, move);
3349 return E_NOTIMPL;
3352 static HRESULT WINAPI IShellFolderView_fnSetPoints(
3353 IShellFolderView *iface,
3354 IDataObject *obj)
3356 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3357 FIXME("(%p)->(%p) stub\n", This, obj);
3358 return E_NOTIMPL;
3361 static HRESULT WINAPI IShellFolderView_fnGetItemSpacing(
3362 IShellFolderView *iface,
3363 ITEMSPACING *spacing)
3365 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3366 FIXME("(%p)->(%p) stub\n", This, spacing);
3367 return E_NOTIMPL;
3370 static HRESULT WINAPI IShellFolderView_fnSetCallback(
3371 IShellFolderView *iface,
3372 IShellFolderViewCB *new_cb,
3373 IShellFolderViewCB **old_cb)
3376 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3377 FIXME("(%p)->(%p %p) stub\n", This, new_cb, old_cb);
3378 return E_NOTIMPL;
3381 static HRESULT WINAPI IShellFolderView_fnSelect(
3382 IShellFolderView *iface,
3383 UINT flags)
3385 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3386 FIXME("(%p)->(%d) stub\n", This, flags);
3387 return E_NOTIMPL;
3390 static HRESULT WINAPI IShellFolderView_fnQuerySupport(
3391 IShellFolderView *iface,
3392 UINT *support)
3394 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3395 TRACE("(%p)->(%p)\n", This, support);
3396 return S_OK;
3399 static HRESULT WINAPI IShellFolderView_fnSetAutomationObject(
3400 IShellFolderView *iface,
3401 IDispatch *disp)
3403 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3404 FIXME("(%p)->(%p) stub\n", This, disp);
3405 return E_NOTIMPL;
3408 static const IShellFolderViewVtbl shellfolderviewvtbl =
3410 IShellFolderView_fnQueryInterface,
3411 IShellFolderView_fnAddRef,
3412 IShellFolderView_fnRelease,
3413 IShellFolderView_fnRearrange,
3414 IShellFolderView_fnGetArrangeParam,
3415 IShellFolderView_fnArrangeGrid,
3416 IShellFolderView_fnAutoArrange,
3417 IShellFolderView_fnGetAutoArrange,
3418 IShellFolderView_fnAddObject,
3419 IShellFolderView_fnGetObject,
3420 IShellFolderView_fnRemoveObject,
3421 IShellFolderView_fnGetObjectCount,
3422 IShellFolderView_fnSetObjectCount,
3423 IShellFolderView_fnUpdateObject,
3424 IShellFolderView_fnRefreshObject,
3425 IShellFolderView_fnSetRedraw,
3426 IShellFolderView_fnGetSelectedCount,
3427 IShellFolderView_fnGetSelectedObjects,
3428 IShellFolderView_fnIsDropOnSource,
3429 IShellFolderView_fnGetDragPoint,
3430 IShellFolderView_fnGetDropPoint,
3431 IShellFolderView_fnMoveIcons,
3432 IShellFolderView_fnSetItemPos,
3433 IShellFolderView_fnIsBkDropTarget,
3434 IShellFolderView_fnSetClipboard,
3435 IShellFolderView_fnSetPoints,
3436 IShellFolderView_fnGetItemSpacing,
3437 IShellFolderView_fnSetCallback,
3438 IShellFolderView_fnSelect,
3439 IShellFolderView_fnQuerySupport,
3440 IShellFolderView_fnSetAutomationObject
3443 static HRESULT WINAPI shellfolderviewdual_QueryInterface(IShellFolderViewDual3 *iface, REFIID riid, void **ppvObj)
3445 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3447 TRACE("(%p)->(IID:%s,%p)\n", This, debugstr_guid(riid), ppvObj);
3449 if (IsEqualIID(riid, &IID_IShellFolderViewDual3) ||
3450 IsEqualIID(riid, &IID_IShellFolderViewDual2) ||
3451 IsEqualIID(riid, &IID_IShellFolderViewDual) ||
3452 IsEqualIID(riid, &IID_IDispatch) ||
3453 IsEqualIID(riid, &IID_IUnknown))
3455 *ppvObj = iface;
3456 IShellFolderViewDual3_AddRef(iface);
3457 return S_OK;
3460 WARN("unsupported interface %s\n", debugstr_guid(riid));
3461 return E_NOINTERFACE;
3464 static ULONG WINAPI shellfolderviewdual_AddRef(IShellFolderViewDual3 *iface)
3466 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3467 return IShellView3_AddRef(&This->IShellView3_iface);
3470 static ULONG WINAPI shellfolderviewdual_Release(IShellFolderViewDual3 *iface)
3472 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3473 return IShellView3_Release(&This->IShellView3_iface);
3476 static HRESULT WINAPI shellfolderviewdual_GetTypeInfoCount(IShellFolderViewDual3 *iface, UINT *pctinfo)
3478 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3479 TRACE("%p %p\n", This, pctinfo);
3480 *pctinfo = 1;
3481 return S_OK;
3484 static HRESULT WINAPI shellfolderviewdual_GetTypeInfo(IShellFolderViewDual3 *iface,
3485 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
3487 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3488 HRESULT hr;
3490 TRACE("(%p,%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo);
3492 hr = get_typeinfo(IShellFolderViewDual3_tid, ppTInfo);
3493 if (SUCCEEDED(hr))
3494 ITypeInfo_AddRef(*ppTInfo);
3495 return hr;
3498 static HRESULT WINAPI shellfolderviewdual_GetIDsOfNames(
3499 IShellFolderViewDual3 *iface, REFIID riid, LPOLESTR *rgszNames, UINT
3500 cNames, LCID lcid, DISPID *rgDispId)
3502 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3503 ITypeInfo *ti;
3504 HRESULT hr;
3506 TRACE("(%p, %s, %p, %u, %d, %p)\n", This, debugstr_guid(riid), rgszNames,
3507 cNames, lcid, rgDispId);
3509 hr = get_typeinfo(IShellFolderViewDual3_tid, &ti);
3510 if (SUCCEEDED(hr))
3511 hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId);
3512 return hr;
3515 static HRESULT WINAPI shellfolderviewdual_Invoke(IShellFolderViewDual3 *iface,
3516 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
3517 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
3518 UINT *puArgErr)
3520 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3521 ITypeInfo *ti;
3522 HRESULT hr;
3524 TRACE("(%p, %d, %s, %d, %u, %p, %p, %p, %p)\n", This, dispIdMember,
3525 debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult,
3526 pExcepInfo, puArgErr);
3528 hr = get_typeinfo(IShellFolderViewDual3_tid, &ti);
3529 if (SUCCEEDED(hr))
3530 hr = ITypeInfo_Invoke(ti, &This->IShellFolderViewDual3_iface, dispIdMember, wFlags, pDispParams,
3531 pVarResult, pExcepInfo, puArgErr);
3532 return hr;
3536 static HRESULT WINAPI shellfolderviewdual_get_Application(IShellFolderViewDual3 *iface,
3537 IDispatch **disp)
3539 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3541 TRACE("%p %p\n", This, disp);
3543 if (!disp)
3544 return E_INVALIDARG;
3546 return IShellDispatch_Constructor(NULL, &IID_IDispatch, (void**)disp);
3549 static HRESULT WINAPI shellfolderviewdual_get_Parent(IShellFolderViewDual3 *iface, IDispatch **disp)
3551 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3552 FIXME("%p %p\n", This, disp);
3553 return E_NOTIMPL;
3556 static HRESULT WINAPI shellfolderviewdual_get_Folder(IShellFolderViewDual3 *iface, Folder **folder)
3558 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3559 FIXME("%p %p\n", This, folder);
3560 return E_NOTIMPL;
3563 static HRESULT WINAPI shellfolderviewdual_SelectedItems(IShellFolderViewDual3 *iface, FolderItems **items)
3565 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3566 FIXME("%p %p\n", This, items);
3567 return E_NOTIMPL;
3570 static HRESULT WINAPI shellfolderviewdual_get_FocusedItem(IShellFolderViewDual3 *iface,
3571 FolderItem **item)
3573 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3574 FIXME("%p %p\n", This, item);
3575 return E_NOTIMPL;
3578 static HRESULT WINAPI shellfolderviewdual_SelectItem(IShellFolderViewDual3 *iface,
3579 VARIANT *v, int flags)
3581 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3582 FIXME("%p %s %x\n", This, debugstr_variant(v), flags);
3583 return E_NOTIMPL;
3586 static HRESULT WINAPI shellfolderviewdual_PopupItemMenu(IShellFolderViewDual3 *iface,
3587 FolderItem *item, VARIANT vx, VARIANT vy, BSTR *command)
3589 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3590 FIXME("%p %p %s %s %p\n", This, item, debugstr_variant(&vx), debugstr_variant(&vy), command);
3591 return E_NOTIMPL;
3594 static HRESULT WINAPI shellfolderviewdual_get_Script(IShellFolderViewDual3 *iface, IDispatch **disp)
3596 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3597 FIXME("%p %p\n", This, disp);
3598 return E_NOTIMPL;
3601 static HRESULT WINAPI shellfolderviewdual_get_ViewOptions(IShellFolderViewDual3 *iface, LONG *options)
3603 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3604 FIXME("%p %p\n", This, options);
3605 return E_NOTIMPL;
3608 static HRESULT WINAPI shellfolderviewdual_get_CurrentViewMode(IShellFolderViewDual3 *iface, UINT *mode)
3610 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3611 FIXME("%p %p\n", This, mode);
3612 return E_NOTIMPL;
3615 static HRESULT WINAPI shellfolderviewdual_put_CurrentViewMode(IShellFolderViewDual3 *iface, UINT mode)
3617 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3618 FIXME("%p %u\n", This, mode);
3619 return E_NOTIMPL;
3622 static HRESULT WINAPI shellfolderviewdual_SelectItemRelative(IShellFolderViewDual3 *iface, int relative)
3624 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3625 FIXME("%p %d\n", This, relative);
3626 return E_NOTIMPL;
3629 static HRESULT WINAPI shellfolderviewdual_get_GroupBy(IShellFolderViewDual3 *iface, BSTR *groupby)
3631 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3632 FIXME("%p %p\n", This, groupby);
3633 return E_NOTIMPL;
3636 static HRESULT WINAPI shellfolderviewdual_put_GroupBy(IShellFolderViewDual3 *iface, BSTR groupby)
3638 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3639 FIXME("%p %s\n", This, debugstr_w(groupby));
3640 return E_NOTIMPL;
3643 static HRESULT WINAPI shellfolderviewdual_get_FolderFlags(IShellFolderViewDual3 *iface, DWORD *flags)
3645 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3646 FIXME("%p %p\n", This, flags);
3647 return E_NOTIMPL;
3650 static HRESULT WINAPI shellfolderviewdual_put_FolderFlags(IShellFolderViewDual3 *iface, DWORD flags)
3652 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3653 FIXME("%p 0x%08x\n", This, flags);
3654 return E_NOTIMPL;
3657 static HRESULT WINAPI shellfolderviewdual_get_SortColumns(IShellFolderViewDual3 *iface, BSTR *sortcolumns)
3659 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3660 FIXME("%p %p\n", This, sortcolumns);
3661 return E_NOTIMPL;
3664 static HRESULT WINAPI shellfolderviewdual_put_SortColumns(IShellFolderViewDual3 *iface, BSTR sortcolumns)
3666 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3667 FIXME("%p %s\n", This, debugstr_w(sortcolumns));
3668 return E_NOTIMPL;
3671 static HRESULT WINAPI shellfolderviewdual_put_IconSize(IShellFolderViewDual3 *iface, int icon_size)
3673 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3674 FIXME("%p %d\n", This, icon_size);
3675 return E_NOTIMPL;
3678 static HRESULT WINAPI shellfolderviewdual_get_IconSize(IShellFolderViewDual3 *iface, int *icon_size)
3680 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3681 FIXME("%p %p\n", This, icon_size);
3682 return E_NOTIMPL;
3685 static HRESULT WINAPI shellfolderviewdual_FilterView(IShellFolderViewDual3 *iface, BSTR filter_text)
3687 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3688 FIXME("%p %s\n", This, debugstr_w(filter_text));
3689 return E_NOTIMPL;
3692 static const IShellFolderViewDual3Vtbl shellfolderviewdualvtbl =
3694 shellfolderviewdual_QueryInterface,
3695 shellfolderviewdual_AddRef,
3696 shellfolderviewdual_Release,
3697 shellfolderviewdual_GetTypeInfoCount,
3698 shellfolderviewdual_GetTypeInfo,
3699 shellfolderviewdual_GetIDsOfNames,
3700 shellfolderviewdual_Invoke,
3701 shellfolderviewdual_get_Application,
3702 shellfolderviewdual_get_Parent,
3703 shellfolderviewdual_get_Folder,
3704 shellfolderviewdual_SelectedItems,
3705 shellfolderviewdual_get_FocusedItem,
3706 shellfolderviewdual_SelectItem,
3707 shellfolderviewdual_PopupItemMenu,
3708 shellfolderviewdual_get_Script,
3709 shellfolderviewdual_get_ViewOptions,
3710 shellfolderviewdual_get_CurrentViewMode,
3711 shellfolderviewdual_put_CurrentViewMode,
3712 shellfolderviewdual_SelectItemRelative,
3713 shellfolderviewdual_get_GroupBy,
3714 shellfolderviewdual_put_GroupBy,
3715 shellfolderviewdual_get_FolderFlags,
3716 shellfolderviewdual_put_FolderFlags,
3717 shellfolderviewdual_get_SortColumns,
3718 shellfolderviewdual_put_SortColumns,
3719 shellfolderviewdual_put_IconSize,
3720 shellfolderviewdual_get_IconSize,
3721 shellfolderviewdual_FilterView
3724 /**********************************************************
3725 * IShellView_Constructor
3727 IShellView *IShellView_Constructor(IShellFolder *folder)
3729 IShellViewImpl *sv;
3731 sv = heap_alloc_zero(sizeof(*sv));
3732 if (!sv)
3733 return NULL;
3735 sv->ref = 1;
3736 sv->IShellView3_iface.lpVtbl = &shellviewvtbl;
3737 sv->IOleCommandTarget_iface.lpVtbl = &olecommandtargetvtbl;
3738 sv->IDropTarget_iface.lpVtbl = &droptargetvtbl;
3739 sv->IDropSource_iface.lpVtbl = &dropsourcevtbl;
3740 sv->IViewObject_iface.lpVtbl = &viewobjectvtbl;
3741 sv->IFolderView2_iface.lpVtbl = &folderviewvtbl;
3742 sv->IShellFolderView_iface.lpVtbl = &shellfolderviewvtbl;
3743 sv->IShellFolderViewDual3_iface.lpVtbl = &shellfolderviewdualvtbl;
3745 sv->pSFParent = folder;
3746 if (folder) IShellFolder_AddRef(folder);
3747 IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (void**)&sv->pSF2Parent);
3749 sv->pCurDropTarget = NULL;
3750 sv->pCurDataObject = NULL;
3751 sv->iDragOverItem = 0;
3752 sv->cScrollDelay = 0;
3753 sv->ptLastMousePos.x = 0;
3754 sv->ptLastMousePos.y = 0;
3756 TRACE("(%p)->(%p)\n", sv, folder);
3757 return (IShellView*)&sv->IShellView3_iface;
3760 /*************************************************************************
3761 * SHCreateShellFolderView [SHELL32.256]
3763 * Create a new instance of the default Shell folder view object.
3765 * RETURNS
3766 * Success: S_OK
3767 * Failure: error value
3769 * NOTES
3770 * see IShellFolder::CreateViewObject
3772 HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *desc, IShellView **shellview)
3774 TRACE("(%p, %p)\n", desc, shellview);
3776 *shellview = NULL;
3778 if (!desc || desc->cbSize != sizeof(*desc))
3779 return E_INVALIDARG;
3781 TRACE("sf=%p outer=%p callback=%p\n", desc->pshf, desc->psvOuter, desc->psfvcb);
3783 if (!desc->pshf)
3784 return E_UNEXPECTED;
3786 *shellview = IShellView_Constructor(desc->pshf);
3787 if (!*shellview)
3788 return E_OUTOFMEMORY;
3790 if (desc->psfvcb)
3792 IShellFolderView *view;
3793 IShellView_QueryInterface(*shellview, &IID_IShellFolderView, (void **)&view);
3794 IShellFolderView_SetCallback(view, desc->psfvcb, NULL);
3795 IShellFolderView_Release(view);
3798 return S_OK;
3801 /*************************************************************************
3802 * SHCreateShellFolderViewEx [SHELL32.174]
3804 * Create a new instance of the default Shell folder view object.
3806 * RETURNS
3807 * Success: S_OK
3808 * Failure: error value
3810 * NOTES
3811 * see IShellFolder::CreateViewObject
3813 HRESULT WINAPI SHCreateShellFolderViewEx(CSFV *desc, IShellView **shellview)
3815 TRACE("(%p, %p)\n", desc, shellview);
3817 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n", desc->pshf, desc->pidl, desc->pfnCallback,
3818 desc->fvm, desc->psvOuter);
3820 if (!desc->pshf)
3821 return E_UNEXPECTED;
3823 *shellview = IShellView_Constructor(desc->pshf);
3824 if (!*shellview)
3825 return E_OUTOFMEMORY;
3827 return S_OK;