winepulse: Lock sessions in AudioClient's GetService.
[wine.git] / dlls / shell32 / shlview.c
blobd58435670c24da60e908dfc8149ef1cfb4afb353
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 <stdarg.h>
40 #include <stdlib.h>
41 #include <string.h>
43 #define CINTERFACE
44 #define COBJMACROS
45 #define NONAMELESSUNION
47 #include "windef.h"
48 #include "winerror.h"
49 #include "winbase.h"
50 #include "winnls.h"
51 #include "objbase.h"
52 #include "servprov.h"
53 #include "shlguid.h"
54 #include "wingdi.h"
55 #include "winuser.h"
56 #include "shlobj.h"
57 #include "shobjidl.h"
58 #include "shresdef.h"
59 #include "wine/debug.h"
61 #include "docobj.h"
62 #include "pidl.h"
63 #include "shell32_main.h"
64 #include "shellfolder.h"
66 WINE_DEFAULT_DEBUG_CHANNEL(shell);
68 /* Generic structure used by several messages */
69 typedef struct
71 DWORD dwReserved;
72 DWORD dwReserved2;
73 LPCITEMIDLIST pidl;
74 DWORD *lpdwUser;
75 } SFVCBINFO;
77 /* SFVCB_SELECTIONCHANGED structure */
78 typedef struct
80 UINT uOldState;
81 UINT uNewState;
82 LPCITEMIDLIST pidl;
83 DWORD *lpdwUser;
84 } SFVSELECTSTATE;
86 /* SFVCB_COPYHOOKCALLBACK structure */
87 typedef struct
89 HWND hwnd;
90 UINT wFunc;
91 UINT wFlags;
92 const char *pszSrcFile;
93 DWORD dwSrcAttribs;
94 const char *pszDestFile;
95 DWORD dwDestAttribs;
96 } SFVCOPYHOOKINFO;
98 /* SFVCB_GETDETAILSOF structure */
99 typedef struct
101 LPCITEMIDLIST pidl;
102 int fmt;
103 int cx;
104 STRRET lpText;
105 } SFVCOLUMNINFO;
107 typedef struct
108 { BOOL bIsAscending;
109 INT nHeaderID;
110 INT nLastHeaderID;
111 }LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO;
113 typedef struct
115 IShellView3 IShellView3_iface;
116 IOleCommandTarget IOleCommandTarget_iface;
117 IDropTarget IDropTarget_iface;
118 IDropSource IDropSource_iface;
119 IViewObject IViewObject_iface;
120 IFolderView2 IFolderView2_iface;
121 IShellFolderView IShellFolderView_iface;
122 IShellFolderViewDual3 IShellFolderViewDual3_iface;
123 LONG ref;
124 IShellFolder* pSFParent;
125 IShellFolder2* pSF2Parent;
126 IShellBrowser* pShellBrowser;
127 ICommDlgBrowser* pCommDlgBrowser;
128 HWND hWnd; /* SHELLDLL_DefView */
129 HWND hWndList; /* ListView control */
130 HWND hWndParent;
131 FOLDERSETTINGS FolderSettings;
132 HMENU hMenu;
133 UINT uState;
134 UINT cidl;
135 LPITEMIDLIST *apidl;
136 LISTVIEW_SORT_INFO ListViewSortInfo;
137 ULONG hNotify; /* change notification handle */
138 HANDLE hAccel;
139 DWORD dwAspects;
140 DWORD dwAdvf;
141 IAdviseSink *pAdvSink;
142 IDropTarget* pCurDropTarget; /* The sub-item, which is currently dragged over */
143 IDataObject* pCurDataObject; /* The dragged data-object */
144 LONG iDragOverItem; /* Dragged over item's index, iff pCurDropTarget != NULL */
145 UINT cScrollDelay; /* Send a WM_*SCROLL msg every 250 ms during drag-scroll */
146 POINT ptLastMousePos; /* Mouse position at last DragOver call */
147 UINT columns; /* Number of shell folder columns */
148 } IShellViewImpl;
150 static inline IShellViewImpl *impl_from_IShellView3(IShellView3 *iface)
152 return CONTAINING_RECORD(iface, IShellViewImpl, IShellView3_iface);
155 static inline IShellViewImpl *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
157 return CONTAINING_RECORD(iface, IShellViewImpl, IOleCommandTarget_iface);
160 static inline IShellViewImpl *impl_from_IDropTarget(IDropTarget *iface)
162 return CONTAINING_RECORD(iface, IShellViewImpl, IDropTarget_iface);
165 static inline IShellViewImpl *impl_from_IDropSource(IDropSource *iface)
167 return CONTAINING_RECORD(iface, IShellViewImpl, IDropSource_iface);
170 static inline IShellViewImpl *impl_from_IViewObject(IViewObject *iface)
172 return CONTAINING_RECORD(iface, IShellViewImpl, IViewObject_iface);
175 static inline IShellViewImpl *impl_from_IFolderView2(IFolderView2 *iface)
177 return CONTAINING_RECORD(iface, IShellViewImpl, IFolderView2_iface);
180 static inline IShellViewImpl *impl_from_IShellFolderView(IShellFolderView *iface)
182 return CONTAINING_RECORD(iface, IShellViewImpl, IShellFolderView_iface);
185 static inline IShellViewImpl *impl_from_IShellFolderViewDual3(IShellFolderViewDual3 *iface)
187 return CONTAINING_RECORD(iface, IShellViewImpl, IShellFolderViewDual3_iface);
190 /* ListView Header IDs */
191 #define LISTVIEW_COLUMN_NAME 0
192 #define LISTVIEW_COLUMN_SIZE 1
193 #define LISTVIEW_COLUMN_TYPE 2
194 #define LISTVIEW_COLUMN_TIME 3
195 #define LISTVIEW_COLUMN_ATTRIB 4
197 /*menu items */
198 #define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500)
199 #define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501)
200 #define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502)
202 #define ID_LISTVIEW 1
204 #define SHV_CHANGE_NOTIFY WM_USER + 0x1111
206 /*windowsx.h */
207 #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
208 #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
209 #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
212 Items merged into the toolbar and the filemenu
214 typedef struct
215 { int idCommand;
216 int iImage;
217 int idButtonString;
218 int idMenuString;
219 BYTE bState;
220 BYTE bStyle;
221 } MYTOOLINFO, *LPMYTOOLINFO;
223 static const MYTOOLINFO Tools[] =
225 { FCIDM_SHVIEW_BIGICON, 0, 0, IDS_VIEW_LARGE, TBSTATE_ENABLED, BTNS_BUTTON },
226 { FCIDM_SHVIEW_SMALLICON, 0, 0, IDS_VIEW_SMALL, TBSTATE_ENABLED, BTNS_BUTTON },
227 { FCIDM_SHVIEW_LISTVIEW, 0, 0, IDS_VIEW_LIST, TBSTATE_ENABLED, BTNS_BUTTON },
228 { FCIDM_SHVIEW_REPORTVIEW, 0, 0, IDS_VIEW_DETAILS, TBSTATE_ENABLED, BTNS_BUTTON },
229 { -1, 0, 0, 0, 0, 0}
232 typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
234 /**********************************************************
236 * ##### helperfunctions for communication with ICommDlgBrowser #####
238 static BOOL IsInCommDlg(IShellViewImpl * This)
240 return This->pCommDlgBrowser != NULL;
243 static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl)
245 HRESULT ret = S_OK;
247 if (IsInCommDlg(This))
249 TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
250 ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView *)&This->IShellView3_iface, pidl);
251 TRACE("-- returns 0x%08lx\n", ret);
254 return ret;
257 static HRESULT OnDefaultCommand(IShellViewImpl * This)
259 HRESULT ret = S_FALSE;
261 if (IsInCommDlg(This))
263 TRACE("ICommDlgBrowser::OnDefaultCommand\n");
264 ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView *)&This->IShellView3_iface);
265 TRACE("-- returns 0x%08lx\n", ret);
268 return ret;
271 static HRESULT OnStateChange(IShellViewImpl * This, UINT change)
273 HRESULT ret = S_FALSE;
275 if (IsInCommDlg(This))
277 TRACE("ICommDlgBrowser::OnStateChange change=%d\n", change);
278 ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView *)&This->IShellView3_iface, change);
279 TRACE("-- returns 0x%08lx\n", ret);
282 return ret;
285 /**********************************************************
286 * set the toolbar of the filedialog buttons
288 * - activates the buttons from the shellbrowser according to
289 * the view state
291 static void CheckToolbar(IShellViewImpl * This)
293 LRESULT result;
295 TRACE("\n");
297 if (IsInCommDlg(This))
299 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
300 FCIDM_TB_SMALLICON, This->FolderSettings.ViewMode == FVM_LIST, &result);
301 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
302 FCIDM_TB_REPORTVIEW, This->FolderSettings.ViewMode == FVM_DETAILS, &result);
303 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
304 FCIDM_TB_SMALLICON, TRUE, &result);
305 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
306 FCIDM_TB_REPORTVIEW, TRUE, &result);
310 /**********************************************************
312 * ##### helperfunctions for initializing the view #####
314 /**********************************************************
315 * change the style of the listview control
317 static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove)
319 DWORD tmpstyle;
321 TRACE("(%p)\n", This);
323 tmpstyle = GetWindowLongW(This->hWndList, GWL_STYLE);
324 SetWindowLongW(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove));
327 static DWORD ViewModeToListStyle(UINT ViewMode)
329 DWORD dwStyle;
331 TRACE("%d\n", ViewMode);
333 switch (ViewMode)
335 case FVM_ICON: dwStyle = LVS_ICON; break;
336 case FVM_DETAILS: dwStyle = LVS_REPORT; break;
337 case FVM_SMALLICON: dwStyle = LVS_SMALLICON; break;
338 case FVM_LIST: dwStyle = LVS_LIST; break;
339 default:
341 FIXME("ViewMode %d not implemented\n", ViewMode);
342 dwStyle = LVS_LIST;
343 break;
347 return dwStyle;
350 /**********************************************************
351 * ShellView_CreateList()
353 * - creates the list view window
355 static BOOL ShellView_CreateList (IShellViewImpl * This)
356 { DWORD dwStyle, dwExStyle;
358 TRACE("%p\n",This);
360 dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
361 LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_AUTOARRANGE | LVS_SHOWSELALWAYS;
362 dwExStyle = WS_EX_CLIENTEDGE;
364 dwStyle |= ViewModeToListStyle(This->FolderSettings.ViewMode);
366 if (This->FolderSettings.fFlags & FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE;
367 if (This->FolderSettings.fFlags & FWF_DESKTOP)
368 This->FolderSettings.fFlags |= FWF_NOCLIENTEDGE | FWF_NOSCROLL;
369 if (This->FolderSettings.fFlags & FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL;
370 if (This->FolderSettings.fFlags & FWF_NOCLIENTEDGE)
371 dwExStyle &= ~WS_EX_CLIENTEDGE;
373 This->hWndList=CreateWindowExW( dwExStyle,
374 WC_LISTVIEWW,
375 NULL,
376 dwStyle,
377 0,0,0,0,
378 This->hWnd,
379 (HMENU)ID_LISTVIEW,
380 shell32_hInstance,
381 NULL);
383 if(!This->hWndList)
384 return FALSE;
386 This->ListViewSortInfo.bIsAscending = TRUE;
387 This->ListViewSortInfo.nHeaderID = -1;
388 This->ListViewSortInfo.nLastHeaderID = -1;
390 if (This->FolderSettings.fFlags & FWF_DESKTOP) {
392 * FIXME: look at the registry value
393 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ListviewShadow
394 * and activate drop shadows if necessary
396 if (0)
397 SendMessageW(This->hWndList, LVM_SETTEXTBKCOLOR, 0, CLR_NONE);
398 else
399 SendMessageW(This->hWndList, LVM_SETTEXTBKCOLOR, 0, GetSysColor(COLOR_DESKTOP));
401 SendMessageW(This->hWndList, LVM_SETTEXTCOLOR, 0, RGB(255,255,255));
404 /* UpdateShellSettings(); */
405 return TRUE;
408 /**********************************************************
409 * ShellView_InitList()
411 * - adds all needed columns to the shellview
413 static void ShellView_InitList(IShellViewImpl *This)
415 IShellDetails *details = NULL;
416 HIMAGELIST big_icons, small_icons;
417 LVCOLUMNW lvColumn;
418 SHELLDETAILS sd;
419 WCHAR nameW[50];
420 HRESULT hr;
421 HFONT list_font, old_font;
422 HDC list_dc;
423 TEXTMETRICW tm;
425 TRACE("(%p)\n", This);
427 Shell_GetImageLists( &big_icons, &small_icons );
428 SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0);
429 SendMessageW(This->hWndList, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)small_icons);
430 SendMessageW(This->hWndList, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)big_icons);
432 lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
433 lvColumn.pszText = nameW;
435 if (!This->pSF2Parent)
437 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IShellDetails, (void**)&details);
438 if (hr != S_OK)
440 WARN("IShellFolder2/IShellDetails not supported\n");
441 return;
445 list_font = (HFONT)SendMessageW(This->hWndList, WM_GETFONT, 0, 0);
446 list_dc = GetDC(This->hWndList);
447 old_font = SelectObject(list_dc, list_font);
448 GetTextMetricsW(list_dc, &tm);
449 SelectObject(list_dc, old_font);
450 ReleaseDC(This->hWndList, list_dc);
452 for (This->columns = 0;; This->columns++)
454 if (This->pSF2Parent)
455 hr = IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, This->columns, &sd);
456 else
457 hr = IShellDetails_GetDetailsOf(details, NULL, This->columns, &sd);
458 if (FAILED(hr)) break;
460 lvColumn.fmt = sd.fmt;
461 lvColumn.cx = MulDiv(sd.cxChar, tm.tmAveCharWidth * 3, 2); /* chars->pixel */
462 StrRetToStrNW(nameW, ARRAY_SIZE(nameW), &sd.str, NULL);
463 SendMessageW(This->hWndList, LVM_INSERTCOLUMNW, This->columns, (LPARAM)&lvColumn);
466 if (details) IShellDetails_Release(details);
469 /* LVM_SORTITEMS callback used when initially inserting items */
470 static INT CALLBACK ShellView_CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
472 LPITEMIDLIST pidl1 = (LPITEMIDLIST)lParam1;
473 LPITEMIDLIST pidl2 = (LPITEMIDLIST)lParam2;
474 IShellFolder *folder = (IShellFolder *)lpData;
475 int ret;
477 TRACE("pidl1=%p, pidl2=%p, shellfolder=%p\n", pidl1, pidl2, folder);
479 ret = (SHORT)HRESULT_CODE(IShellFolder_CompareIDs(folder, 0, pidl1, pidl2));
480 TRACE("ret=%i\n", ret);
481 return ret;
484 /*************************************************************************
485 * ShellView_ListViewCompareItems
487 * Compare Function for the Listview (FileOpen Dialog)
489 * PARAMS
490 * lParam1 [I] the first ItemIdList to compare with
491 * lParam2 [I] the second ItemIdList to compare with
492 * lpData [I] The column ID for the header Ctrl to process
494 * RETURNS
495 * A negative value if the first item should precede the second,
496 * a positive value if the first item should follow the second,
497 * or zero if the two items are equivalent
499 * NOTES
500 * FIXME: function does what ShellView_CompareItems is supposed to do.
501 * unify it and figure out how to use the undocumented first parameter
502 * of IShellFolder_CompareIDs to do the job this function does and
503 * move this code to IShellFolder.
504 * make LISTVIEW_SORT_INFO obsolete
505 * the way this function works is only usable if we had only
506 * filesystemfolders (25/10/99 jsch)
508 static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
510 INT nDiff=0;
511 FILETIME fd1, fd2;
512 char strName1[MAX_PATH], strName2[MAX_PATH];
513 BOOL bIsFolder1, bIsFolder2,bIsBothFolder;
514 LPITEMIDLIST pItemIdList1 = lParam1;
515 LPITEMIDLIST pItemIdList2 = lParam2;
516 LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData;
519 bIsFolder1 = _ILIsFolder(pItemIdList1);
520 bIsFolder2 = _ILIsFolder(pItemIdList2);
521 bIsBothFolder = bIsFolder1 && bIsFolder2;
523 /* When sorting between a File and a Folder, the Folder gets sorted first */
524 if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder)
526 nDiff = bIsFolder1 ? -1 : 1;
528 else
530 /* Sort by Time: Folders or Files can be sorted */
532 if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)
534 _ILGetFileDateTime(pItemIdList1, &fd1);
535 _ILGetFileDateTime(pItemIdList2, &fd2);
536 nDiff = CompareFileTime(&fd2, &fd1);
538 /* Sort by Attribute: Folder or Files can be sorted */
539 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB)
541 _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH);
542 _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH);
543 nDiff = lstrcmpiA(strName1, strName2);
545 /* Sort by FileName: Folder or Files can be sorted */
546 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder)
548 /* Sort by Text */
549 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
550 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
551 nDiff = lstrcmpiA(strName1, strName2);
553 /* Sort by File Size, Only valid for Files */
554 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)
556 nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0));
558 /* Sort by File Type, Only valid for Files */
559 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)
561 /* Sort by Type */
562 _ILGetFileType(pItemIdList1, strName1, MAX_PATH);
563 _ILGetFileType(pItemIdList2, strName2, MAX_PATH);
564 nDiff = lstrcmpiA(strName1, strName2);
567 /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
569 if(nDiff == 0)
571 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
572 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
573 nDiff = lstrcmpiA(strName1, strName2);
576 if(!pSortInfo->bIsAscending)
578 nDiff = -nDiff;
581 return nDiff;
585 /**********************************************************
586 * LV_FindItemByPidl()
588 static int LV_FindItemByPidl(
589 IShellViewImpl * This,
590 LPCITEMIDLIST pidl)
592 LVITEMW lvItem;
593 lvItem.iSubItem = 0;
594 lvItem.mask = LVIF_PARAM;
595 for(lvItem.iItem = 0;
596 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
597 lvItem.iItem++)
599 LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam;
600 HRESULT hr = IShellFolder_CompareIDs(This->pSFParent, 0, pidl, currentpidl);
601 if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
603 return lvItem.iItem;
606 return -1;
609 static void shellview_add_item(IShellViewImpl *shellview, LPCITEMIDLIST pidl)
611 LVITEMW item;
612 UINT i;
614 TRACE("(%p)(pidl=%p)\n", shellview, pidl);
616 item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
617 item.iItem = 0;
618 item.iSubItem = 0;
619 item.lParam = (LPARAM)pidl;
620 item.pszText = LPSTR_TEXTCALLBACKW;
621 item.iImage = I_IMAGECALLBACK;
622 SendMessageW(shellview->hWndList, LVM_INSERTITEMW, 0, (LPARAM)&item);
624 for (i = 1; i < shellview->columns; i++)
626 item.mask = LVIF_TEXT;
627 item.iItem = 0;
628 item.iSubItem = 1;
629 item.pszText = LPSTR_TEXTCALLBACKW;
630 SendMessageW(shellview->hWndList, LVM_SETITEMW, 0, (LPARAM)&item);
634 /**********************************************************
635 * LV_RenameItem()
637 static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew )
639 int nItem;
640 LVITEMW lvItem;
642 TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew);
644 nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld));
645 if ( -1 != nItem )
647 lvItem.mask = LVIF_PARAM; /* only the pidl */
648 lvItem.iItem = nItem;
649 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
651 SHFree((LPITEMIDLIST)lvItem.lParam);
652 lvItem.mask = LVIF_PARAM;
653 lvItem.iItem = nItem;
654 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew)); /* set the item's data */
655 SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem);
656 SendMessageW(This->hWndList, LVM_UPDATE, nItem, 0);
657 return TRUE; /* FIXME: better handling */
659 return FALSE;
661 /**********************************************************
662 * ShellView_FillList()
664 * - gets the objectlist from the shellfolder
665 * - sorts the list
666 * - fills the list into the view
669 static HRESULT ShellView_FillList(IShellViewImpl *This)
671 IFolderView2 *folderview = &This->IFolderView2_iface;
672 LPENUMIDLIST pEnumIDList;
673 LPITEMIDLIST pidl;
674 DWORD fetched;
675 HRESULT hr;
677 TRACE("(%p)\n", This);
679 /* get the itemlist from the shfolder*/
680 hr = IShellFolder_EnumObjects(This->pSFParent, This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList);
681 if (hr != S_OK)
682 return hr;
684 IFolderView2_SetRedraw(folderview, FALSE);
686 /* copy the items into the array */
687 while ((S_OK == IEnumIDList_Next(pEnumIDList, 1, &pidl, &fetched)) && fetched)
689 if (IncludeObject(This, pidl) == S_OK)
690 shellview_add_item(This, pidl);
691 else
692 ILFree(pidl);
695 SendMessageW(This->hWndList, LVM_SORTITEMS, (WPARAM)This->pSFParent, (LPARAM)ShellView_CompareItems);
697 IFolderView2_SetRedraw(folderview, TRUE);
699 IEnumIDList_Release(pEnumIDList);
700 return S_OK;
703 /**********************************************************
704 * ShellView_OnCreate()
706 static LRESULT ShellView_OnCreate(IShellViewImpl *This)
708 IShellView3 *iface = &This->IShellView3_iface;
709 IPersistFolder2 *ppf2;
710 IDropTarget* pdt;
711 HRESULT hr;
713 TRACE("(%p)\n", This);
715 if (ShellView_CreateList(This))
717 ShellView_InitList(This);
718 ShellView_FillList(This);
721 hr = IShellView3_QueryInterface(iface, &IID_IDropTarget, (void**)&pdt);
722 if (hr == S_OK)
724 RegisterDragDrop(This->hWnd, pdt);
725 IDropTarget_Release(pdt);
728 /* register for receiving notifications */
729 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2);
730 if (hr == S_OK)
732 LPITEMIDLIST raw_pidl;
733 SHChangeNotifyEntry ntreg;
735 hr = IPersistFolder2_GetCurFolder(ppf2, &raw_pidl);
736 if(SUCCEEDED(hr))
738 LPITEMIDLIST computer_pidl;
739 SHGetFolderLocation(NULL,CSIDL_DRIVES,NULL,0,&computer_pidl);
740 if(ILIsParent(computer_pidl,raw_pidl,FALSE))
742 /* Normalize the pidl to unixfs to workaround an issue with
743 * sending notifications on dos paths
745 WCHAR path[MAX_PATH];
746 SHGetPathFromIDListW(raw_pidl,path);
747 SHParseDisplayName(path,NULL,(LPITEMIDLIST*)&ntreg.pidl,0,NULL);
748 SHFree(raw_pidl);
750 else
751 ntreg.pidl = raw_pidl;
752 ntreg.fRecursive = TRUE;
753 This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNRF_InterruptLevel, SHCNE_ALLEVENTS,
754 SHV_CHANGE_NOTIFY, 1, &ntreg);
755 SHFree((LPITEMIDLIST)ntreg.pidl);
756 SHFree(computer_pidl);
758 IPersistFolder2_Release(ppf2);
761 This->hAccel = LoadAcceleratorsW(shell32_hInstance, L"shv_accel");
763 return S_OK;
766 /**********************************************************
767 * #### Handling of the menus ####
770 /**********************************************************
771 * ShellView_BuildFileMenu()
773 static HMENU ShellView_BuildFileMenu(IShellViewImpl * This)
774 { WCHAR szText[MAX_PATH];
775 MENUITEMINFOW mii;
776 int nTools,i;
777 HMENU hSubMenu;
779 TRACE("(%p)\n",This);
781 hSubMenu = CreatePopupMenu();
782 if(hSubMenu)
783 { /*get the number of items in our global array*/
784 for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){}
786 /*add the menu items*/
787 for(i = 0; i < nTools; i++)
789 LoadStringW(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH);
791 ZeroMemory(&mii, sizeof(mii));
792 mii.cbSize = sizeof(mii);
793 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
795 if(BTNS_SEP != Tools[i].bStyle) /* no separator*/
797 mii.fType = MFT_STRING;
798 mii.fState = MFS_ENABLED;
799 mii.dwTypeData = szText;
800 mii.wID = Tools[i].idCommand;
802 else
804 mii.fType = MFT_SEPARATOR;
806 /* tack This item onto the end of the menu */
807 InsertMenuItemW(hSubMenu, (UINT)-1, TRUE, &mii);
810 TRACE("-- return (menu=%p)\n",hSubMenu);
811 return hSubMenu;
814 static void ShellView_MergeFileMenu(IShellViewImpl *This, HMENU hSubMenu)
816 if (hSubMenu)
818 MENUITEMINFOW mii;
820 /* insert This item at the beginning of the menu */
822 mii.cbSize = sizeof(mii);
823 mii.fMask = MIIM_ID | MIIM_TYPE;
824 mii.wID = 0;
825 mii.fType = MFT_SEPARATOR;
826 InsertMenuItemW(hSubMenu, 0, TRUE, &mii);
828 mii.cbSize = sizeof(mii);
829 mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
830 mii.dwTypeData = (LPWSTR)L"dummy45";
831 mii.fState = MFS_ENABLED;
832 mii.wID = IDM_MYFILEITEM;
833 mii.fType = MFT_STRING;
834 InsertMenuItemW(hSubMenu, 0, TRUE, &mii);
838 /**********************************************************
839 * ShellView_MergeViewMenu()
842 static void ShellView_MergeViewMenu(IShellViewImpl *This, HMENU hSubMenu)
844 TRACE("(%p)->(submenu=%p)\n",This,hSubMenu);
846 /* add a separator at the correct position in the menu */
847 if (hSubMenu)
849 MENUITEMINFOW mii;
851 memset(&mii, 0, sizeof(mii));
852 mii.cbSize = sizeof(mii);
853 mii.fMask = MIIM_ID | MIIM_TYPE;
854 mii.wID = 0;
855 mii.fType = MFT_SEPARATOR;
856 InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
858 mii.cbSize = sizeof(mii);
859 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;
860 mii.fType = MFT_STRING;
861 mii.dwTypeData = (LPWSTR)L"View";
862 mii.hSubMenu = LoadMenuW(shell32_hInstance, L"MENU_001");
863 InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
867 /**********************************************************
868 * ShellView_GetSelections()
870 * - fills the this->apidl list with the selected objects
872 * RETURNS
873 * number of selected items
875 static UINT ShellView_GetSelections(IShellViewImpl * This)
877 LVITEMW lvItem;
878 UINT i = 0;
880 SHFree(This->apidl);
882 This->cidl = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0);
883 This->apidl = SHAlloc(This->cidl * sizeof(LPITEMIDLIST));
885 TRACE("selected=%i\n", This->cidl);
887 if(This->apidl)
889 TRACE("-- Items selected =%u\n", This->cidl);
891 lvItem.mask = LVIF_STATE | LVIF_PARAM;
892 lvItem.stateMask = LVIS_SELECTED;
893 lvItem.iItem = 0;
894 lvItem.iSubItem = 0;
896 while(ListView_GetItemW(This->hWndList, &lvItem) && (i < This->cidl))
898 if(lvItem.state & LVIS_SELECTED)
900 This->apidl[i] = (LPITEMIDLIST)lvItem.lParam;
901 i++;
902 TRACE("-- selected Item found\n");
904 lvItem.iItem++;
907 return This->cidl;
911 /**********************************************************
912 * ShellView_OpenSelectedItems()
914 static HRESULT ShellView_OpenSelectedItems(IShellViewImpl * This)
916 static UINT CF_IDLIST = 0;
917 HRESULT hr;
918 IDataObject* selection;
919 FORMATETC fetc;
920 STGMEDIUM stgm;
921 LPIDA pIDList;
922 LPCITEMIDLIST parent_pidl;
923 WCHAR parent_path[MAX_PATH];
924 LPCWSTR parent_dir = NULL;
925 SFGAOF attribs;
926 int i;
928 if (0 == ShellView_GetSelections(This))
930 return S_OK;
932 hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl,
933 (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,
934 0, (LPVOID *)&selection);
935 if (FAILED(hr))
936 return hr;
938 if (0 == CF_IDLIST)
940 CF_IDLIST = RegisterClipboardFormatW(CFSTR_SHELLIDLISTW);
942 fetc.cfFormat = CF_IDLIST;
943 fetc.ptd = NULL;
944 fetc.dwAspect = DVASPECT_CONTENT;
945 fetc.lindex = -1;
946 fetc.tymed = TYMED_HGLOBAL;
948 hr = IDataObject_QueryGetData(selection, &fetc);
949 if (FAILED(hr))
950 return hr;
952 hr = IDataObject_GetData(selection, &fetc, &stgm);
953 if (FAILED(hr))
954 return hr;
956 pIDList = GlobalLock(stgm.u.hGlobal);
958 parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pIDList+pIDList->aoffset[0]);
959 hr = IShellFolder_GetAttributesOf(This->pSFParent, 1, &parent_pidl, &attribs);
960 if (SUCCEEDED(hr) && (attribs & SFGAO_FILESYSTEM) &&
961 SHGetPathFromIDListW(parent_pidl, parent_path))
963 parent_dir = parent_path;
966 for (i = pIDList->cidl; i > 0; --i)
968 LPCITEMIDLIST pidl;
970 pidl = (LPCITEMIDLIST)((LPBYTE)pIDList+pIDList->aoffset[i]);
972 attribs = SFGAO_FOLDER;
973 hr = IShellFolder_GetAttributesOf(This->pSFParent, 1, &pidl, &attribs);
975 if (SUCCEEDED(hr) && ! (attribs & SFGAO_FOLDER))
977 SHELLEXECUTEINFOW shexinfo;
979 shexinfo.cbSize = sizeof(SHELLEXECUTEINFOW);
980 shexinfo.fMask = SEE_MASK_INVOKEIDLIST; /* SEE_MASK_IDLIST is also possible. */
981 shexinfo.hwnd = NULL;
982 shexinfo.lpVerb = NULL;
983 shexinfo.lpFile = NULL;
984 shexinfo.lpParameters = NULL;
985 shexinfo.lpDirectory = parent_dir;
986 shexinfo.nShow = SW_NORMAL;
987 shexinfo.lpIDList = ILCombine(parent_pidl, pidl);
989 ShellExecuteExW(&shexinfo); /* Discard error/success info */
991 ILFree(shexinfo.lpIDList);
995 GlobalUnlock(stgm.u.hGlobal);
996 ReleaseStgMedium(&stgm);
998 IDataObject_Release(selection);
1000 return S_OK;
1003 /**********************************************************
1004 * ShellView_DoContextMenu()
1006 static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL bDefault)
1007 { UINT uCommand;
1008 DWORD wFlags;
1009 HMENU hMenu;
1010 BOOL fExplore = FALSE;
1011 HWND hwndTree = 0;
1012 LPCONTEXTMENU pContextMenu = NULL;
1013 CMINVOKECOMMANDINFO cmi;
1015 TRACE("%p, %d, %d, %d.\n", This, x, y, bDefault);
1017 /* look, what's selected and create a context menu object of it*/
1018 if( ShellView_GetSelections(This) )
1020 IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, (LPCITEMIDLIST*)This->apidl,
1021 &IID_IContextMenu, NULL, (LPVOID *)&pContextMenu);
1023 if(pContextMenu)
1025 TRACE("-- pContextMenu\n");
1026 hMenu = CreatePopupMenu();
1028 if( hMenu )
1030 /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
1031 if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree)
1033 TRACE("-- explore mode\n");
1034 fExplore = TRUE;
1037 /* build the flags depending on what we can do with the selected item */
1038 wFlags = CMF_NORMAL | (This->cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0);
1040 /* let the ContextMenu merge its items in */
1041 if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags )))
1043 if (This->FolderSettings.fFlags & FWF_DESKTOP)
1044 SetMenuDefaultItem(hMenu, FCIDM_SHVIEW_OPEN, MF_BYCOMMAND);
1046 if( bDefault )
1048 TRACE("-- get menu default command\n");
1049 uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS);
1051 else
1053 TRACE("-- track popup\n");
1054 uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
1057 if(uCommand > 0)
1059 TRACE("-- uCommand=%u\n", uCommand);
1060 if (uCommand==FCIDM_SHVIEW_OPEN && IsInCommDlg(This))
1062 TRACE("-- dlg: OnDefaultCommand\n");
1063 if (OnDefaultCommand(This) != S_OK)
1065 ShellView_OpenSelectedItems(This);
1068 else
1070 TRACE("-- explore -- invoke command\n");
1071 ZeroMemory(&cmi, sizeof(cmi));
1072 cmi.cbSize = sizeof(cmi);
1073 cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */
1074 cmi.lpVerb = MAKEINTRESOURCEA(uCommand);
1075 IContextMenu_InvokeCommand(pContextMenu, &cmi);
1078 DestroyMenu(hMenu);
1081 if (pContextMenu)
1082 IContextMenu_Release(pContextMenu);
1085 else /* background context menu */
1087 IContextMenu2 *pCM;
1089 hMenu = CreatePopupMenu();
1091 BackgroundMenu_Constructor(This->pSFParent, FALSE, &IID_IContextMenu2, (void**)&pCM);
1092 IContextMenu2_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
1094 uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
1095 DestroyMenu(hMenu);
1097 TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand);
1099 ZeroMemory(&cmi, sizeof(cmi));
1100 cmi.cbSize = sizeof(cmi);
1101 cmi.lpVerb = MAKEINTRESOURCEA(uCommand);
1102 cmi.hwnd = This->hWndParent;
1103 IContextMenu2_InvokeCommand(pCM, &cmi);
1105 IContextMenu2_Release(pCM);
1109 /**********************************************************
1110 * ##### message handling #####
1113 /**********************************************************
1114 * ShellView_OnSize()
1116 static LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight)
1118 TRACE("%p width=%u height=%u\n",This, wWidth,wHeight);
1120 /*resize the ListView to fit our window*/
1121 if(This->hWndList)
1123 MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE);
1126 return S_OK;
1128 /**********************************************************
1129 * ShellView_OnDeactivate()
1131 * NOTES
1132 * internal
1134 static void ShellView_OnDeactivate(IShellViewImpl * This)
1136 TRACE("%p\n",This);
1138 if(This->uState != SVUIA_DEACTIVATE)
1140 if(This->hMenu)
1142 IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0);
1143 IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu);
1144 DestroyMenu(This->hMenu);
1145 This->hMenu = 0;
1148 This->uState = SVUIA_DEACTIVATE;
1152 /**********************************************************
1153 * ShellView_OnActivate()
1155 static LRESULT ShellView_OnActivate(IShellViewImpl *This, UINT uState)
1157 OLEMENUGROUPWIDTHS omw = { {0, 0, 0, 0, 0, 0} };
1158 MENUITEMINFOW mii;
1160 TRACE("(%p) uState=%x\n",This,uState);
1162 /* don't do anything if the state isn't really changing */
1163 if (This->uState == uState) return S_OK;
1165 ShellView_OnDeactivate(This);
1167 /* only do This if we are active */
1168 if (uState != SVUIA_DEACTIVATE)
1170 /* merge the menus */
1171 This->hMenu = CreateMenu();
1173 if (This->hMenu)
1175 IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw);
1176 TRACE("-- after fnInsertMenusSB\n");
1178 mii.cbSize = sizeof(mii);
1179 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
1180 mii.fType = MFT_STRING;
1181 mii.fState = MFS_ENABLED;
1182 mii.wID = 0;
1183 mii.hSubMenu = ShellView_BuildFileMenu(This);
1184 mii.hbmpChecked = NULL;
1185 mii.hbmpUnchecked = NULL;
1186 mii.dwItemData = 0;
1187 /* build the top level menu get the menu item's text */
1188 mii.dwTypeData = (LPWSTR)L"dummy 31";
1189 mii.cch = 0;
1190 mii.hbmpItem = NULL;
1192 /* insert our menu into the menu bar */
1193 if (mii.hSubMenu)
1194 InsertMenuItemW(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii);
1196 /* get the view menu so we can merge with it */
1197 memset(&mii, 0, sizeof(mii));
1198 mii.cbSize = sizeof(mii);
1199 mii.fMask = MIIM_SUBMENU;
1201 if (GetMenuItemInfoW(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii))
1202 ShellView_MergeViewMenu(This, mii.hSubMenu);
1204 /* add the items that should only be added if we have the focus */
1205 if (SVUIA_ACTIVATE_FOCUS == uState)
1207 /* get the file menu so we can merge with it */
1208 memset(&mii, 0, sizeof(mii));
1209 mii.cbSize = sizeof(mii);
1210 mii.fMask = MIIM_SUBMENU;
1212 if (GetMenuItemInfoW(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii))
1213 ShellView_MergeFileMenu(This, mii.hSubMenu);
1216 TRACE("-- before fnSetMenuSB\n");
1217 IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd);
1220 This->uState = uState;
1221 TRACE("--\n");
1222 return S_OK;
1225 /**********************************************************
1226 * ShellView_OnSetFocus()
1229 static LRESULT ShellView_OnSetFocus(IShellViewImpl * This)
1231 TRACE("%p\n",This);
1233 /* Tell the browser one of our windows has received the focus. This
1234 should always be done before merging menus (OnActivate merges the
1235 menus) if one of our windows has the focus.*/
1237 IShellBrowser_OnViewWindowActive(This->pShellBrowser, (IShellView *)&This->IShellView3_iface);
1238 ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS);
1240 /* Set the focus to the listview */
1241 SetFocus(This->hWndList);
1243 /* Notify the ICommDlgBrowser interface */
1244 OnStateChange(This,CDBOSC_SETFOCUS);
1246 return 0;
1249 /**********************************************************
1250 * ShellView_OnKillFocus()
1252 static LRESULT ShellView_OnKillFocus(IShellViewImpl * This)
1254 TRACE("%p.\n", This);
1256 ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS);
1257 /* Notify the ICommDlgBrowser */
1258 OnStateChange(This,CDBOSC_KILLFOCUS);
1260 return 0;
1263 /**********************************************************
1264 * ShellView_OnCommand()
1266 * NOTES
1267 * the CmdIDs are the ones from the context menu
1269 static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd)
1271 TRACE("(%p)->(0x%08lx 0x%08lx %p) stub\n",This, dwCmdID, dwCmd, hwndCmd);
1273 switch(dwCmdID)
1275 case FCIDM_SHVIEW_SMALLICON:
1276 This->FolderSettings.ViewMode = FVM_SMALLICON;
1277 SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK);
1278 CheckToolbar(This);
1279 break;
1281 case FCIDM_SHVIEW_BIGICON:
1282 This->FolderSettings.ViewMode = FVM_ICON;
1283 SetStyle (This, LVS_ICON, LVS_TYPEMASK);
1284 CheckToolbar(This);
1285 break;
1287 case FCIDM_SHVIEW_LISTVIEW:
1288 This->FolderSettings.ViewMode = FVM_LIST;
1289 SetStyle (This, LVS_LIST, LVS_TYPEMASK);
1290 CheckToolbar(This);
1291 break;
1293 case FCIDM_SHVIEW_REPORTVIEW:
1294 This->FolderSettings.ViewMode = FVM_DETAILS;
1295 SetStyle (This, LVS_REPORT, LVS_TYPEMASK);
1296 CheckToolbar(This);
1297 break;
1299 /* the menu IDs for sorting are 0x30... see shell32.rc */
1300 case 0x30:
1301 case 0x31:
1302 case 0x32:
1303 case 0x33:
1304 This->ListViewSortInfo.nHeaderID = dwCmdID - 0x30;
1305 This->ListViewSortInfo.bIsAscending = TRUE;
1306 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1307 SendMessageW(This->hWndList, LVM_SORTITEMS, (WPARAM) &This->ListViewSortInfo, (LPARAM)ShellView_ListViewCompareItems);
1308 break;
1310 default:
1311 TRACE("-- COMMAND 0x%04lx unhandled\n", dwCmdID);
1313 return 0;
1316 /**********************************************************
1317 * ShellView_OnNotify()
1320 static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
1321 { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
1322 NMLVDISPINFOW *lpdi = (NMLVDISPINFOW *)lpnmh;
1323 LPITEMIDLIST pidl;
1325 TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code);
1327 switch(lpnmh->code)
1329 case NM_SETFOCUS:
1330 TRACE("-- NM_SETFOCUS %p\n",This);
1331 ShellView_OnSetFocus(This);
1332 break;
1334 case NM_KILLFOCUS:
1335 TRACE("-- NM_KILLFOCUS %p\n",This);
1336 ShellView_OnDeactivate(This);
1337 /* Notify the ICommDlgBrowser interface */
1338 OnStateChange(This,CDBOSC_KILLFOCUS);
1339 break;
1341 case NM_CUSTOMDRAW:
1342 TRACE("-- NM_CUSTOMDRAW %p\n",This);
1343 return CDRF_DODEFAULT;
1345 case NM_RELEASEDCAPTURE:
1346 TRACE("-- NM_RELEASEDCAPTURE %p\n",This);
1347 break;
1349 case NM_CLICK:
1350 TRACE("-- NM_CLICK %p\n",This);
1351 break;
1353 case NM_RCLICK:
1354 TRACE("-- NM_RCLICK %p\n",This);
1355 break;
1357 case NM_DBLCLK:
1358 TRACE("-- NM_DBLCLK %p\n",This);
1359 if (OnDefaultCommand(This) != S_OK) ShellView_OpenSelectedItems(This);
1360 break;
1362 case NM_RETURN:
1363 TRACE("-- NM_RETURN %p\n",This);
1364 if (OnDefaultCommand(This) != S_OK) ShellView_OpenSelectedItems(This);
1365 break;
1367 case HDN_ENDTRACKW:
1368 TRACE("-- HDN_ENDTRACKW %p\n",This);
1369 /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
1370 nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
1371 break;
1373 case LVN_DELETEITEM:
1374 TRACE("-- LVN_DELETEITEM %p\n",This);
1375 SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/
1376 break;
1378 case LVN_DELETEALLITEMS:
1379 TRACE("-- LVN_DELETEALLITEMS %p\n",This);
1380 return FALSE;
1382 case LVN_INSERTITEM:
1383 TRACE("-- LVN_INSERTITEM (STUB)%p\n",This);
1384 break;
1386 case LVN_ITEMACTIVATE:
1387 TRACE("-- LVN_ITEMACTIVATE %p\n",This);
1388 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1389 break;
1391 case LVN_COLUMNCLICK:
1392 This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem;
1393 if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID)
1395 This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending;
1397 else
1399 This->ListViewSortInfo.bIsAscending = TRUE;
1401 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1403 SendMessageW(lpnmlv->hdr.hwndFrom, LVM_SORTITEMS, (WPARAM) &This->ListViewSortInfo, (LPARAM)ShellView_ListViewCompareItems);
1404 break;
1406 case LVN_GETDISPINFOA:
1407 case LVN_GETDISPINFOW:
1408 TRACE("-- LVN_GETDISPINFO %p\n",This);
1409 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1411 if(lpdi->item.mask & LVIF_TEXT) /* text requested */
1413 static WCHAR emptyW[] = { 0 };
1414 SHELLDETAILS sd;
1415 HRESULT hr;
1417 if (This->pSF2Parent)
1419 hr = IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
1421 else
1423 IShellDetails *details;
1425 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IShellDetails, (void**)&details);
1426 if (hr == S_OK)
1428 hr = IShellDetails_GetDetailsOf(details, pidl, lpdi->item.iSubItem, &sd);
1429 IShellDetails_Release(details);
1431 else
1432 WARN("IShellFolder2/IShellDetails not supported\n");
1435 if (hr != S_OK)
1437 /* set to empty on failure */
1438 sd.str.uType = STRRET_WSTR;
1439 sd.str.u.pOleStr = emptyW;
1442 if (lpnmh->code == LVN_GETDISPINFOW)
1444 StrRetToStrNW( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1445 TRACE("-- text=%s\n", debugstr_w(lpdi->item.pszText));
1447 else
1449 /* LVN_GETDISPINFOA - shouldn't happen */
1450 NMLVDISPINFOA *lpdiA = (NMLVDISPINFOA *)lpnmh;
1451 StrRetToStrNA( lpdiA->item.pszText, lpdiA->item.cchTextMax, &sd.str, NULL);
1452 TRACE("-- text=%s\n", lpdiA->item.pszText);
1456 if(lpdi->item.mask & LVIF_IMAGE) /* image requested */
1458 lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
1460 break;
1462 case LVN_ITEMCHANGED:
1463 TRACE("-- LVN_ITEMCHANGED %p\n",This);
1464 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1465 break;
1467 case LVN_BEGINDRAG:
1468 case LVN_BEGINRDRAG:
1469 TRACE("-- LVN_BEGINDRAG\n");
1471 if (ShellView_GetSelections(This))
1473 IDataObject * pda;
1474 DWORD dwAttributes = SFGAO_CANLINK;
1475 DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
1477 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
1479 IDropSource *pds = &This->IDropSource_iface; /* own DropSource interface */
1481 if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, (LPCITEMIDLIST*)This->apidl, &dwAttributes)))
1483 if (dwAttributes & SFGAO_CANLINK)
1485 dwEffect |= DROPEFFECT_LINK;
1489 if (pds)
1491 DWORD dwEffect2;
1492 DoDragDrop(pda, pds, dwEffect, &dwEffect2);
1494 IDataObject_Release(pda);
1497 break;
1499 case LVN_BEGINLABELEDITW:
1501 DWORD dwAttr = SFGAO_CANRENAME;
1502 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1504 TRACE("-- LVN_BEGINLABELEDITW %p\n",This);
1506 IShellFolder_GetAttributesOf(This->pSFParent, 1, (LPCITEMIDLIST*)&pidl, &dwAttr);
1507 if (SFGAO_CANRENAME & dwAttr)
1509 return FALSE;
1511 return TRUE;
1514 case LVN_ENDLABELEDITW:
1516 TRACE("-- LVN_ENDLABELEDITA %p\n",This);
1517 if (lpdi->item.pszText)
1519 HRESULT hr;
1520 LVITEMW lvItem;
1522 lvItem.iItem = lpdi->item.iItem;
1523 lvItem.iSubItem = 0;
1524 lvItem.mask = LVIF_PARAM;
1525 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
1527 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1528 hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, lpdi->item.pszText, SHGDN_INFOLDER, &pidl);
1530 if(SUCCEEDED(hr) && pidl)
1532 lvItem.mask = LVIF_PARAM;
1533 lvItem.lParam = (LPARAM)pidl;
1534 SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem);
1535 return TRUE;
1538 return FALSE;
1541 case LVN_KEYDOWN:
1543 LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
1545 /* initiate a rename of the selected file or directory */
1546 switch (plvKeyDown->wVKey)
1548 case VK_F2:
1550 INT i = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0);
1552 if (i == 1)
1554 /* get selected item */
1555 i = SendMessageW(This->hWndList, LVM_GETNEXTITEM, -1, MAKELPARAM (LVNI_SELECTED, 0));
1557 SendMessageW(This->hWndList, LVM_ENSUREVISIBLE, i, 0);
1558 SendMessageW(This->hWndList, LVM_EDITLABELW, i, 0);
1561 break;
1562 case VK_DELETE:
1564 UINT i, count;
1565 int item_index;
1566 LVITEMW item;
1567 LPITEMIDLIST* pItems;
1568 ISFHelper *psfhlp;
1569 HRESULT hr;
1571 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (void**)&psfhlp);
1572 if (hr != S_OK) return 0;
1574 if(!(count = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0)))
1576 ISFHelper_Release(psfhlp);
1577 return 0;
1580 /* allocate memory for the pidl array */
1581 pItems = heap_alloc(sizeof(LPITEMIDLIST) * count);
1583 /* retrieve all selected items */
1584 i = 0;
1585 item_index = -1;
1587 while (count > i)
1589 /* get selected item */
1590 item_index = SendMessageW(This->hWndList, LVM_GETNEXTITEM, item_index,
1591 MAKELPARAM (LVNI_SELECTED, 0));
1592 item.iItem = item_index;
1593 item.mask = LVIF_PARAM;
1594 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM)&item);
1596 /* get item pidl */
1597 pItems[i] = (LPITEMIDLIST)item.lParam;
1599 i++;
1602 /* perform the item deletion */
1603 ISFHelper_DeleteItems(psfhlp, i, (LPCITEMIDLIST*)pItems);
1604 ISFHelper_Release(psfhlp);
1606 /* free pidl array memory */
1607 heap_free(pItems);
1609 break;
1611 case VK_F5:
1612 /* Initiate a refresh */
1613 IShellView3_Refresh(&This->IShellView3_iface);
1614 break;
1616 case VK_BACK:
1618 LPSHELLBROWSER lpSb;
1619 if((lpSb = (LPSHELLBROWSER)SendMessageW(This->hWndParent, CWM_GETISHELLBROWSER, 0, 0)))
1621 IShellBrowser_BrowseObject(lpSb, NULL, SBSP_PARENT);
1624 break;
1626 default:
1627 FIXME("LVN_KEYDOWN key=0x%08x\n", plvKeyDown->wVKey);
1630 break;
1632 default:
1633 TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code);
1634 break;
1636 return 0;
1639 /**********************************************************
1640 * ShellView_OnChange()
1643 static LRESULT ShellView_OnChange(IShellViewImpl * This, const LPCITEMIDLIST *pidls, LONG event)
1645 LPCITEMIDLIST pidl;
1646 BOOL ret = TRUE;
1648 TRACE("(%p)->(%p, %p, 0x%08lx)\n", This, pidls[0], pidls[1], event);
1650 switch (event)
1652 case SHCNE_MKDIR:
1653 case SHCNE_CREATE:
1654 pidl = ILClone(ILFindLastID(pidls[0]));
1655 shellview_add_item(This, pidl);
1656 break;
1657 case SHCNE_RMDIR:
1658 case SHCNE_DELETE:
1660 INT i = LV_FindItemByPidl(This, ILFindLastID(pidls[0]));
1661 ret = SendMessageW(This->hWndList, LVM_DELETEITEM, i, 0);
1662 break;
1664 case SHCNE_RENAMEFOLDER:
1665 case SHCNE_RENAMEITEM:
1666 LV_RenameItem(This, pidls[0], pidls[1]);
1667 break;
1668 case SHCNE_UPDATEITEM:
1669 break;
1671 return ret;
1673 /**********************************************************
1674 * ShellView_WndProc
1677 static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1679 IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
1680 LPCREATESTRUCTW lpcs;
1682 TRACE("(hwnd=%p msg=%x wparm=%Ix lparm=%Ix)\n",hWnd, uMessage, wParam, lParam);
1684 switch (uMessage)
1686 case WM_NCCREATE:
1687 lpcs = (LPCREATESTRUCTW)lParam;
1688 pThis = lpcs->lpCreateParams;
1689 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (ULONG_PTR)pThis);
1690 pThis->hWnd = hWnd; /*set the window handle*/
1691 break;
1693 case WM_SIZE: return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam));
1694 case WM_SETFOCUS: return ShellView_OnSetFocus(pThis);
1695 case WM_KILLFOCUS: return ShellView_OnKillFocus(pThis);
1696 case WM_CREATE: return ShellView_OnCreate(pThis);
1697 case WM_ACTIVATE: return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS);
1698 case WM_NOTIFY: return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam);
1699 case WM_COMMAND: return ShellView_OnCommand(pThis,
1700 GET_WM_COMMAND_ID(wParam, lParam),
1701 GET_WM_COMMAND_CMD(wParam, lParam),
1702 GET_WM_COMMAND_HWND(wParam, lParam));
1703 case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (const LPCITEMIDLIST*)wParam, (LONG)lParam);
1705 case WM_CONTEXTMENU: ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE);
1706 return 0;
1708 case WM_SHOWWINDOW: UpdateWindow(pThis->hWndList);
1709 break;
1711 case WM_GETDLGCODE: return SendMessageW(pThis->hWndList, uMessage, 0, 0);
1712 case WM_SETFONT: return SendMessageW(pThis->hWndList, WM_SETFONT, wParam, lParam);
1713 case WM_GETFONT: return SendMessageW(pThis->hWndList, WM_GETFONT, wParam, lParam);
1715 case WM_DESTROY:
1716 RevokeDragDrop(pThis->hWnd);
1717 SHChangeNotifyDeregister(pThis->hNotify);
1718 break;
1720 case WM_ERASEBKGND:
1721 if ((pThis->FolderSettings.fFlags & FWF_DESKTOP) ||
1722 (pThis->FolderSettings.fFlags & FWF_TRANSPARENT))
1723 return 1;
1724 break;
1727 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
1729 /**********************************************************
1732 * The INTERFACE of the IShellView object
1735 **********************************************************
1736 * IShellView_QueryInterface
1738 static HRESULT WINAPI IShellView_fnQueryInterface(IShellView3 *iface, REFIID riid, void **ppvObj)
1740 IShellViewImpl *This = impl_from_IShellView3(iface);
1742 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObj);
1744 *ppvObj = NULL;
1746 if(IsEqualIID(riid, &IID_IUnknown) ||
1747 IsEqualIID(riid, &IID_IShellView) ||
1748 IsEqualIID(riid, &IID_IShellView2) ||
1749 IsEqualIID(riid, &IID_IShellView3) ||
1750 IsEqualIID(riid, &IID_CDefView))
1752 *ppvObj = &This->IShellView3_iface;
1754 else if(IsEqualIID(riid, &IID_IShellFolderView))
1756 *ppvObj = &This->IShellFolderView_iface;
1758 else if(IsEqualIID(riid, &IID_IFolderView) ||
1759 IsEqualIID(riid, &IID_IFolderView2))
1761 *ppvObj = &This->IFolderView2_iface;
1763 else if(IsEqualIID(riid, &IID_IOleCommandTarget))
1765 *ppvObj = &This->IOleCommandTarget_iface;
1767 else if(IsEqualIID(riid, &IID_IDropTarget))
1769 *ppvObj = &This->IDropTarget_iface;
1771 else if(IsEqualIID(riid, &IID_IDropSource))
1773 *ppvObj = &This->IDropSource_iface;
1775 else if(IsEqualIID(riid, &IID_IViewObject))
1777 *ppvObj = &This->IViewObject_iface;
1780 if(*ppvObj)
1782 IUnknown_AddRef( (IUnknown*)*ppvObj );
1783 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1784 return S_OK;
1786 TRACE("-- Interface: E_NOINTERFACE\n");
1787 return E_NOINTERFACE;
1790 /**********************************************************
1791 * IShellView_AddRef
1793 static ULONG WINAPI IShellView_fnAddRef(IShellView3 *iface)
1795 IShellViewImpl *This = impl_from_IShellView3(iface);
1796 ULONG refCount = InterlockedIncrement(&This->ref);
1798 TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
1800 return refCount;
1802 /**********************************************************
1803 * IShellView_Release
1805 static ULONG WINAPI IShellView_fnRelease(IShellView3 *iface)
1807 IShellViewImpl *This = impl_from_IShellView3(iface);
1808 ULONG refCount = InterlockedDecrement(&This->ref);
1810 TRACE("(%p)->(count=%li)\n", This, refCount + 1);
1812 if (!refCount)
1814 TRACE(" destroying IShellView(%p)\n",This);
1816 DestroyWindow(This->hWndList);
1818 if(This->pSFParent)
1819 IShellFolder_Release(This->pSFParent);
1821 if(This->pSF2Parent)
1822 IShellFolder2_Release(This->pSF2Parent);
1824 SHFree(This->apidl);
1826 if(This->pAdvSink)
1827 IAdviseSink_Release(This->pAdvSink);
1829 heap_free(This);
1831 return refCount;
1834 /**********************************************************
1835 * ShellView_GetWindow
1837 static HRESULT WINAPI IShellView_fnGetWindow(IShellView3 *iface, HWND *phWnd)
1839 IShellViewImpl *This = impl_from_IShellView3(iface);
1841 TRACE("(%p)\n", This);
1843 *phWnd = This->hWnd;
1844 return S_OK;
1847 static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView3 *iface, BOOL mode)
1849 IShellViewImpl *This = impl_from_IShellView3(iface);
1850 TRACE("(%p)->(%d)\n", This, mode);
1851 return E_NOTIMPL;
1854 /**********************************************************
1855 * IShellView_TranslateAccelerator
1857 * FIXME:
1858 * use the accel functions
1860 static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView3 *iface, MSG *lpmsg)
1862 #if 0
1863 IShellViewImpl *This = (IShellViewImpl *)iface;
1865 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%x wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1866 #endif
1868 if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message<=WM_KEYLAST))
1870 TRACE("-- key=0x04%Ix\n",lpmsg->wParam) ;
1872 return S_FALSE; /* not handled */
1875 static HRESULT WINAPI IShellView_fnEnableModeless(IShellView3 *iface, BOOL fEnable)
1877 IShellViewImpl *This = impl_from_IShellView3(iface);
1879 FIXME("(%p) stub\n", This);
1881 return E_NOTIMPL;
1884 static HRESULT WINAPI IShellView_fnUIActivate(IShellView3 *iface, UINT uState)
1886 IShellViewImpl *This = impl_from_IShellView3(iface);
1889 CHAR szName[MAX_PATH];
1891 LRESULT lResult;
1892 int nPartArray[1] = {-1};
1894 TRACE("%p, %d.\n", This, uState);
1896 /*don't do anything if the state isn't really changing*/
1897 if(This->uState == uState)
1899 return S_OK;
1902 /*OnActivate handles the menu merging and internal state*/
1903 ShellView_OnActivate(This, uState);
1905 /*only do This if we are active*/
1906 if(uState != SVUIA_DEACTIVATE)
1910 GetFolderPath is not a method of IShellFolder
1911 IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1913 /* set the number of parts */
1914 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1915 (LPARAM)nPartArray, &lResult);
1917 /* set the text for the parts */
1919 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1920 0, (LPARAM)szName, &lResult);
1924 return S_OK;
1927 static HRESULT WINAPI IShellView_fnRefresh(IShellView3 *iface)
1929 IShellViewImpl *This = impl_from_IShellView3(iface);
1931 TRACE("(%p)\n", This);
1933 SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0);
1934 ShellView_FillList(This);
1936 return S_OK;
1939 static HRESULT WINAPI IShellView_fnCreateViewWindow(IShellView3 *iface, IShellView *prev_view,
1940 const FOLDERSETTINGS *settings, IShellBrowser *owner, RECT *rect, HWND *hWnd)
1942 IShellViewImpl *This = impl_from_IShellView3(iface);
1943 TRACE("(%p)->(%p %p %p %p %p)\n", This, prev_view, settings, owner, rect, hWnd);
1944 return IShellView3_CreateViewWindow3(iface, owner, prev_view, SV3CVW3_DEFAULT,
1945 settings->fFlags, settings->fFlags, settings->ViewMode, NULL, rect, hWnd);
1948 static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView3 *iface)
1950 IShellViewImpl *This = impl_from_IShellView3(iface);
1952 TRACE("(%p)\n", This);
1954 if (!This->hWnd)
1955 return S_OK;
1957 /* Make absolutely sure all our UI is cleaned up. */
1958 IShellView3_UIActivate(iface, SVUIA_DEACTIVATE);
1960 if (This->hMenu)
1961 DestroyMenu(This->hMenu);
1963 DestroyWindow(This->hWnd);
1964 if (This->pShellBrowser) IShellBrowser_Release(This->pShellBrowser);
1965 if (This->pCommDlgBrowser) ICommDlgBrowser_Release(This->pCommDlgBrowser);
1967 This->hMenu = NULL;
1968 This->hWnd = NULL;
1969 This->pShellBrowser = NULL;
1970 This->pCommDlgBrowser = NULL;
1972 return S_OK;
1975 static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView3 *iface, LPFOLDERSETTINGS lpfs)
1977 IShellViewImpl *This = impl_from_IShellView3(iface);
1979 TRACE("(%p)->(%p) vmode=%x flags=%x\n", This, lpfs,
1980 This->FolderSettings.ViewMode, This->FolderSettings.fFlags);
1982 if (!lpfs) return E_INVALIDARG;
1983 *lpfs = This->FolderSettings;
1984 return S_OK;
1987 static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView3 *iface, DWORD dwReserved,
1988 LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
1990 IShellViewImpl *This = impl_from_IShellView3(iface);
1991 FIXME("(%p) stub\n", This);
1992 return E_NOTIMPL;
1995 static HRESULT WINAPI IShellView_fnSaveViewState(IShellView3 *iface)
1997 IShellViewImpl *This = impl_from_IShellView3(iface);
1998 FIXME("(%p) stub\n", This);
1999 return S_OK;
2002 static HRESULT WINAPI IShellView_fnSelectItem(IShellView3 *iface, LPCITEMIDLIST pidl, UINT flags)
2004 IShellViewImpl *This = impl_from_IShellView3(iface);
2005 int i;
2007 TRACE("(%p)->(pidl=%p, 0x%08x)\n",This, pidl, flags);
2009 i = LV_FindItemByPidl(This, pidl);
2010 if (i == -1) return S_OK;
2012 return IFolderView2_SelectItem(&This->IFolderView2_iface, i, flags);
2015 static HRESULT WINAPI IShellView_fnGetItemObject(IShellView3 *iface, UINT uItem, REFIID riid,
2016 void **ppvOut)
2018 IShellViewImpl *This = impl_from_IShellView3(iface);
2019 HRESULT hr = E_NOINTERFACE;
2021 TRACE("(%p)->(0x%08x, %s, %p)\n",This, uItem, debugstr_guid(riid), ppvOut);
2023 *ppvOut = NULL;
2025 switch(uItem)
2027 case SVGIO_BACKGROUND:
2029 if (IsEqualIID(&IID_IContextMenu, riid))
2030 return BackgroundMenu_Constructor(This->pSFParent, FALSE, riid, ppvOut);
2031 else if (IsEqualIID(&IID_IDispatch, riid)) {
2032 *ppvOut = &This->IShellFolderViewDual3_iface;
2033 IShellFolderViewDual3_AddRef(&This->IShellFolderViewDual3_iface);
2034 return S_OK;
2036 else
2037 FIXME("unsupported interface requested %s\n", debugstr_guid(riid));
2039 break;
2041 case SVGIO_SELECTION:
2042 ShellView_GetSelections(This);
2043 hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, riid, 0, ppvOut);
2044 break;
2046 default:
2047 FIXME("unimplemented for uItem = 0x%08x\n", uItem);
2049 TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
2051 return hr;
2054 static HRESULT WINAPI IShellView2_fnGetView(IShellView3 *iface, SHELLVIEWID *view_guid, ULONG view_type)
2056 FIXME("(%p)->(%s, %#lx) stub!\n", iface, debugstr_guid(view_guid), view_type);
2057 return E_NOTIMPL;
2060 static HRESULT WINAPI IShellView2_fnCreateViewWindow2(IShellView3 *iface, SV2CVW2_PARAMS *view_params)
2062 IShellViewImpl *This = impl_from_IShellView3(iface);
2063 TRACE("(%p)->(%p)\n", This, view_params);
2064 return IShellView3_CreateViewWindow3(iface, view_params->psbOwner, view_params->psvPrev,
2065 SV3CVW3_DEFAULT, view_params->pfs->fFlags, view_params->pfs->fFlags,
2066 view_params->pfs->ViewMode, view_params->pvid, view_params->prcView, &view_params->hwndView);
2069 static HRESULT WINAPI IShellView2_fnHandleRename(IShellView3 *iface, LPCITEMIDLIST new_pidl)
2071 FIXME("(%p)->(new_pidl %p) stub!\n", iface, new_pidl);
2072 return E_NOTIMPL;
2075 static HRESULT WINAPI IShellView2_fnSelectAndPositionItem(IShellView3 *iface, LPCITEMIDLIST item,
2076 UINT flags, POINT *point)
2078 IShellViewImpl *This = impl_from_IShellView3(iface);
2079 TRACE("(%p)->(item %p, flags %#x, point %p)\n", This, item, flags, point);
2080 return IFolderView2_SelectAndPositionItems(&This->IFolderView2_iface, 1, &item, point, flags);
2083 static HRESULT WINAPI IShellView3_fnCreateViewWindow3(IShellView3 *iface, IShellBrowser *owner,
2084 IShellView *prev_view, SV3CVW3_FLAGS view_flags, FOLDERFLAGS mask, FOLDERFLAGS flags,
2085 FOLDERVIEWMODE mode, const SHELLVIEWID *view_id, const RECT *rect, HWND *hwnd)
2087 IShellViewImpl *This = impl_from_IShellView3(iface);
2088 INITCOMMONCONTROLSEX icex;
2089 WNDCLASSW wc;
2090 HRESULT hr;
2091 HWND wnd;
2093 TRACE("(%p)->(%p %p 0x%08lx 0x%08x 0x%08x %d %s %s %p)\n", This, owner, prev_view, view_flags,
2094 mask, flags, mode, debugstr_guid(view_id), wine_dbgstr_rect(rect), hwnd);
2096 icex.dwSize = sizeof(icex);
2097 icex.dwICC = ICC_LISTVIEW_CLASSES;
2098 InitCommonControlsEx(&icex);
2100 *hwnd = NULL;
2102 if (!owner || This->hWnd)
2103 return E_UNEXPECTED;
2105 if (view_flags != SV3CVW3_DEFAULT)
2106 FIXME("unsupported view flags 0x%08lx\n", view_flags);
2108 /* Set up the member variables */
2109 This->pShellBrowser = owner;
2110 This->FolderSettings.ViewMode = mode;
2111 This->FolderSettings.fFlags = mask & flags;
2113 if (view_id)
2115 if (IsEqualGUID(view_id, &VID_LargeIcons))
2116 This->FolderSettings.ViewMode = FVM_ICON;
2117 else if (IsEqualGUID(view_id, &VID_SmallIcons))
2118 This->FolderSettings.ViewMode = FVM_SMALLICON;
2119 else if (IsEqualGUID(view_id, &VID_List))
2120 This->FolderSettings.ViewMode = FVM_LIST;
2121 else if (IsEqualGUID(view_id, &VID_Details))
2122 This->FolderSettings.ViewMode = FVM_DETAILS;
2123 else if (IsEqualGUID(view_id, &VID_Thumbnails))
2124 This->FolderSettings.ViewMode = FVM_THUMBNAIL;
2125 else if (IsEqualGUID(view_id, &VID_Tile))
2126 This->FolderSettings.ViewMode = FVM_TILE;
2127 else if (IsEqualGUID(view_id, &VID_ThumbStrip))
2128 This->FolderSettings.ViewMode = FVM_THUMBSTRIP;
2129 else
2130 FIXME("Ignoring unrecognized VID %s\n", debugstr_guid(view_id));
2133 /* Get our parent window */
2134 IShellBrowser_AddRef(This->pShellBrowser);
2135 IShellBrowser_GetWindow(This->pShellBrowser, &This->hWndParent);
2137 /* Try to get the ICommDlgBrowserInterface, adds a reference !!! */
2138 This->pCommDlgBrowser = NULL;
2139 hr = IShellBrowser_QueryInterface(This->pShellBrowser, &IID_ICommDlgBrowser, (void **)&This->pCommDlgBrowser);
2140 if (hr == S_OK)
2141 TRACE("-- CommDlgBrowser %p\n", This->pCommDlgBrowser);
2143 /* If our window class has not been registered, then do so */
2144 if (!GetClassInfoW(shell32_hInstance, L"SHELLDLL_DefView", &wc))
2146 wc.style = CS_HREDRAW | CS_VREDRAW;
2147 wc.lpfnWndProc = ShellView_WndProc;
2148 wc.cbClsExtra = 0;
2149 wc.cbWndExtra = 0;
2150 wc.hInstance = shell32_hInstance;
2151 wc.hIcon = 0;
2152 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
2153 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2154 wc.lpszMenuName = NULL;
2155 wc.lpszClassName = L"SHELLDLL_DefView";
2157 if (!RegisterClassW(&wc)) return E_FAIL;
2160 wnd = CreateWindowExW(0, L"SHELLDLL_DefView", NULL, WS_CHILD | WS_TABSTOP,
2161 rect->left, rect->top,
2162 rect->right - rect->left,
2163 rect->bottom - rect->top,
2164 This->hWndParent, 0, shell32_hInstance, This);
2166 CheckToolbar(This);
2168 if (!wnd)
2170 IShellBrowser_Release(This->pShellBrowser);
2171 return E_FAIL;
2174 SetWindowPos(wnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
2175 UpdateWindow(wnd);
2177 *hwnd = wnd;
2179 return S_OK;
2182 static const IShellView3Vtbl shellviewvtbl =
2184 IShellView_fnQueryInterface,
2185 IShellView_fnAddRef,
2186 IShellView_fnRelease,
2187 IShellView_fnGetWindow,
2188 IShellView_fnContextSensitiveHelp,
2189 IShellView_fnTranslateAccelerator,
2190 IShellView_fnEnableModeless,
2191 IShellView_fnUIActivate,
2192 IShellView_fnRefresh,
2193 IShellView_fnCreateViewWindow,
2194 IShellView_fnDestroyViewWindow,
2195 IShellView_fnGetCurrentInfo,
2196 IShellView_fnAddPropertySheetPages,
2197 IShellView_fnSaveViewState,
2198 IShellView_fnSelectItem,
2199 IShellView_fnGetItemObject,
2200 IShellView2_fnGetView,
2201 IShellView2_fnCreateViewWindow2,
2202 IShellView2_fnHandleRename,
2203 IShellView2_fnSelectAndPositionItem,
2204 IShellView3_fnCreateViewWindow3
2208 /**********************************************************
2209 * ISVOleCmdTarget_QueryInterface (IUnknown)
2211 static HRESULT WINAPI ISVOleCmdTarget_QueryInterface(IOleCommandTarget *iface, REFIID iid, void **ppvObj)
2213 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2214 return IShellView3_QueryInterface(&This->IShellView3_iface, iid, ppvObj);
2217 /**********************************************************
2218 * ISVOleCmdTarget_AddRef (IUnknown)
2220 static ULONG WINAPI ISVOleCmdTarget_AddRef(IOleCommandTarget *iface)
2222 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2223 return IShellView3_AddRef(&This->IShellView3_iface);
2226 /**********************************************************
2227 * ISVOleCmdTarget_Release (IUnknown)
2229 static ULONG WINAPI ISVOleCmdTarget_Release(IOleCommandTarget *iface)
2231 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2232 return IShellView3_Release(&This->IShellView3_iface);
2235 /**********************************************************
2236 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
2238 static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
2239 IOleCommandTarget *iface,
2240 const GUID *pguidCmdGroup,
2241 ULONG cCmds,
2242 OLECMD *prgCmds,
2243 OLECMDTEXT *pCmdText)
2245 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2246 UINT i;
2248 FIXME("(%p)->(%s %ld %p %p)\n",
2249 This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
2251 if (!prgCmds)
2252 return E_INVALIDARG;
2253 for (i = 0; i < cCmds; i++)
2255 FIXME("\tprgCmds[%d].cmdID = %ld\n", i, prgCmds[i].cmdID);
2256 prgCmds[i].cmdf = 0;
2258 return OLECMDERR_E_UNKNOWNGROUP;
2261 /**********************************************************
2262 * ISVOleCmdTarget_Exec (IOleCommandTarget)
2264 * nCmdID is the OLECMDID_* enumeration
2266 static HRESULT WINAPI ISVOleCmdTarget_Exec(
2267 IOleCommandTarget *iface,
2268 const GUID* pguidCmdGroup,
2269 DWORD nCmdID,
2270 DWORD nCmdexecopt,
2271 VARIANT* pvaIn,
2272 VARIANT* pvaOut)
2274 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2276 FIXME("(%p)->(%s %ld 0x%08lx %s %p)\n",
2277 This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, debugstr_variant(pvaIn), pvaOut);
2279 if (!pguidCmdGroup)
2280 return OLECMDERR_E_UNKNOWNGROUP;
2282 if (IsEqualIID(pguidCmdGroup, &CGID_Explorer) &&
2283 (nCmdID == OLECMDID_SHOWMESSAGE) &&
2284 (nCmdexecopt == 4) && pvaOut)
2285 return S_OK;
2286 if (IsEqualIID(pguidCmdGroup, &CGID_ShellDocView) &&
2287 (nCmdID == OLECMDID_SPELL) &&
2288 (nCmdexecopt == OLECMDEXECOPT_DODEFAULT))
2289 return S_FALSE;
2291 return OLECMDERR_E_UNKNOWNGROUP;
2294 static const IOleCommandTargetVtbl olecommandtargetvtbl =
2296 ISVOleCmdTarget_QueryInterface,
2297 ISVOleCmdTarget_AddRef,
2298 ISVOleCmdTarget_Release,
2299 ISVOleCmdTarget_QueryStatus,
2300 ISVOleCmdTarget_Exec
2303 /**********************************************************
2304 * ISVDropTarget implementation
2307 static HRESULT WINAPI ISVDropTarget_QueryInterface(IDropTarget *iface, REFIID riid, void **ppvObj)
2309 IShellViewImpl *This = impl_from_IDropTarget(iface);
2310 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
2313 static ULONG WINAPI ISVDropTarget_AddRef(IDropTarget *iface)
2315 IShellViewImpl *This = impl_from_IDropTarget(iface);
2316 return IShellView3_AddRef(&This->IShellView3_iface);
2319 static ULONG WINAPI ISVDropTarget_Release(IDropTarget *iface)
2321 IShellViewImpl *This = impl_from_IDropTarget(iface);
2322 return IShellView3_Release(&This->IShellView3_iface);
2325 /******************************************************************************
2326 * drag_notify_subitem [Internal]
2328 * Figure out the shellfolder object, which is currently under the mouse cursor
2329 * and notify it via the IDropTarget interface.
2332 #define SCROLLAREAWIDTH 20
2334 static HRESULT drag_notify_subitem(IShellViewImpl *This, DWORD grfKeyState, POINTL pt,
2335 DWORD *pdwEffect)
2337 LVHITTESTINFO htinfo;
2338 LVITEMW lvItem;
2339 LONG lResult;
2340 HRESULT hr;
2341 RECT clientRect;
2343 /* Map from global to client coordinates and query the index of the listview-item, which is
2344 * currently under the mouse cursor. */
2345 htinfo.pt.x = pt.x;
2346 htinfo.pt.y = pt.y;
2347 htinfo.flags = LVHT_ONITEM;
2348 ScreenToClient(This->hWndList, &htinfo.pt);
2349 lResult = SendMessageW(This->hWndList, LVM_HITTEST, 0, (LPARAM)&htinfo);
2351 /* Send WM_*SCROLL messages every 250 ms during drag-scrolling */
2352 GetClientRect(This->hWndList, &clientRect);
2353 if (htinfo.pt.x == This->ptLastMousePos.x && htinfo.pt.y == This->ptLastMousePos.y &&
2354 (htinfo.pt.x < SCROLLAREAWIDTH || htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH ||
2355 htinfo.pt.y < SCROLLAREAWIDTH || htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH ))
2357 This->cScrollDelay = (This->cScrollDelay + 1) % 5; /* DragOver is called every 50 ms */
2358 if (This->cScrollDelay == 0) { /* Mouse did hover another 250 ms over the scroll-area */
2359 if (htinfo.pt.x < SCROLLAREAWIDTH)
2360 SendMessageW(This->hWndList, WM_HSCROLL, SB_LINEUP, 0);
2361 if (htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH)
2362 SendMessageW(This->hWndList, WM_HSCROLL, SB_LINEDOWN, 0);
2363 if (htinfo.pt.y < SCROLLAREAWIDTH)
2364 SendMessageW(This->hWndList, WM_VSCROLL, SB_LINEUP, 0);
2365 if (htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH)
2366 SendMessageW(This->hWndList, WM_VSCROLL, SB_LINEDOWN, 0);
2368 } else {
2369 This->cScrollDelay = 0; /* Reset, if the cursor is not over the listview's scroll-area */
2371 This->ptLastMousePos = htinfo.pt;
2373 /* If we are still over the previous sub-item, notify it via DragOver and return. */
2374 if (This->pCurDropTarget && lResult == This->iDragOverItem)
2375 return IDropTarget_DragOver(This->pCurDropTarget, grfKeyState, pt, pdwEffect);
2377 /* We've left the previous sub-item, notify it via DragLeave and Release it. */
2378 if (This->pCurDropTarget) {
2379 IDropTarget_DragLeave(This->pCurDropTarget);
2380 IDropTarget_Release(This->pCurDropTarget);
2381 This->pCurDropTarget = NULL;
2384 This->iDragOverItem = lResult;
2385 if (lResult == -1) {
2386 /* We are not above one of the listview's subitems. Bind to the parent folder's
2387 * DropTarget interface. */
2388 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IDropTarget,
2389 (LPVOID*)&This->pCurDropTarget);
2390 } else {
2391 /* Query the relative PIDL of the shellfolder object represented by the currently
2392 * dragged over listview-item ... */
2393 lvItem.mask = LVIF_PARAM;
2394 lvItem.iItem = lResult;
2395 lvItem.iSubItem = 0;
2396 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
2398 /* ... and bind pCurDropTarget to the IDropTarget interface of an UIObject of this object */
2399 hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWndList, 1,
2400 (LPCITEMIDLIST*)&lvItem.lParam, &IID_IDropTarget, NULL, (LPVOID*)&This->pCurDropTarget);
2403 /* If anything failed, pCurDropTarget should be NULL now, which ought to be a save state. */
2404 if (FAILED(hr))
2405 return hr;
2407 /* Notify the item just entered via DragEnter. */
2408 return IDropTarget_DragEnter(This->pCurDropTarget, This->pCurDataObject, grfKeyState, pt, pdwEffect);
2411 static HRESULT WINAPI ISVDropTarget_DragEnter(IDropTarget *iface, IDataObject *pDataObject,
2412 DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2414 IShellViewImpl *This = impl_from_IDropTarget(iface);
2416 /* Get a hold on the data object for later calls to DragEnter on the sub-folders */
2417 This->pCurDataObject = pDataObject;
2418 IDataObject_AddRef(pDataObject);
2420 return drag_notify_subitem(This, grfKeyState, pt, pdwEffect);
2423 static HRESULT WINAPI ISVDropTarget_DragOver(IDropTarget *iface, DWORD grfKeyState, POINTL pt,
2424 DWORD *pdwEffect)
2426 IShellViewImpl *This = impl_from_IDropTarget(iface);
2427 return drag_notify_subitem(This, grfKeyState, pt, pdwEffect);
2430 static HRESULT WINAPI ISVDropTarget_DragLeave(IDropTarget *iface)
2432 IShellViewImpl *This = impl_from_IDropTarget(iface);
2434 if (This->pCurDropTarget)
2436 IDropTarget_DragLeave(This->pCurDropTarget);
2437 IDropTarget_Release(This->pCurDropTarget);
2438 This->pCurDropTarget = NULL;
2441 if (This->pCurDataObject)
2443 IDataObject_Release(This->pCurDataObject);
2444 This->pCurDataObject = NULL;
2447 This->iDragOverItem = 0;
2449 return S_OK;
2452 static HRESULT WINAPI ISVDropTarget_Drop(IDropTarget *iface, IDataObject* pDataObject,
2453 DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2455 IShellViewImpl *This = impl_from_IDropTarget(iface);
2457 if (!This->pCurDropTarget) return DRAGDROP_E_INVALIDHWND;
2459 IDropTarget_Drop(This->pCurDropTarget, pDataObject, grfKeyState, pt, pdwEffect);
2461 IDropTarget_Release(This->pCurDropTarget);
2462 IDataObject_Release(This->pCurDataObject);
2463 This->pCurDataObject = NULL;
2464 This->pCurDropTarget = NULL;
2465 This->iDragOverItem = 0;
2467 return S_OK;
2470 static const IDropTargetVtbl droptargetvtbl =
2472 ISVDropTarget_QueryInterface,
2473 ISVDropTarget_AddRef,
2474 ISVDropTarget_Release,
2475 ISVDropTarget_DragEnter,
2476 ISVDropTarget_DragOver,
2477 ISVDropTarget_DragLeave,
2478 ISVDropTarget_Drop
2481 /**********************************************************
2482 * ISVDropSource implementation
2485 static HRESULT WINAPI ISVDropSource_QueryInterface(IDropSource *iface, REFIID riid, void **ppvObj)
2487 IShellViewImpl *This = impl_from_IDropSource(iface);
2488 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
2491 static ULONG WINAPI ISVDropSource_AddRef(IDropSource *iface)
2493 IShellViewImpl *This = impl_from_IDropSource(iface);
2494 return IShellView3_AddRef(&This->IShellView3_iface);
2497 static ULONG WINAPI ISVDropSource_Release(IDropSource *iface)
2499 IShellViewImpl *This = impl_from_IDropSource(iface);
2500 return IShellView3_Release(&This->IShellView3_iface);
2503 static HRESULT WINAPI ISVDropSource_QueryContinueDrag(
2504 IDropSource *iface,
2505 BOOL fEscapePressed,
2506 DWORD grfKeyState)
2508 IShellViewImpl *This = impl_from_IDropSource(iface);
2509 TRACE("(%p)\n",This);
2511 if (fEscapePressed)
2512 return DRAGDROP_S_CANCEL;
2513 else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
2514 return DRAGDROP_S_DROP;
2515 else
2516 return S_OK;
2519 static HRESULT WINAPI ISVDropSource_GiveFeedback(
2520 IDropSource *iface,
2521 DWORD dwEffect)
2523 IShellViewImpl *This = impl_from_IDropSource(iface);
2524 TRACE("(%p)\n",This);
2526 return DRAGDROP_S_USEDEFAULTCURSORS;
2529 static const IDropSourceVtbl dropsourcevtbl =
2531 ISVDropSource_QueryInterface,
2532 ISVDropSource_AddRef,
2533 ISVDropSource_Release,
2534 ISVDropSource_QueryContinueDrag,
2535 ISVDropSource_GiveFeedback
2537 /**********************************************************
2538 * ISVViewObject implementation
2541 static HRESULT WINAPI ISVViewObject_QueryInterface(IViewObject *iface, REFIID riid, void **ppvObj)
2543 IShellViewImpl *This = impl_from_IViewObject(iface);
2544 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
2547 static ULONG WINAPI ISVViewObject_AddRef(IViewObject *iface)
2549 IShellViewImpl *This = impl_from_IViewObject(iface);
2550 return IShellView3_AddRef(&This->IShellView3_iface);
2553 static ULONG WINAPI ISVViewObject_Release(IViewObject *iface)
2555 IShellViewImpl *This = impl_from_IViewObject(iface);
2556 return IShellView3_Release(&This->IShellView3_iface);
2559 static HRESULT WINAPI ISVViewObject_Draw(
2560 IViewObject *iface,
2561 DWORD dwDrawAspect,
2562 LONG lindex,
2563 void* pvAspect,
2564 DVTARGETDEVICE* ptd,
2565 HDC hdcTargetDev,
2566 HDC hdcDraw,
2567 LPCRECTL lprcBounds,
2568 LPCRECTL lprcWBounds,
2569 BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue),
2570 ULONG_PTR dwContinue)
2573 IShellViewImpl *This = impl_from_IViewObject(iface);
2575 FIXME("Stub: This=%p\n",This);
2577 return E_NOTIMPL;
2579 static HRESULT WINAPI ISVViewObject_GetColorSet(
2580 IViewObject *iface,
2581 DWORD dwDrawAspect,
2582 LONG lindex,
2583 void *pvAspect,
2584 DVTARGETDEVICE* ptd,
2585 HDC hicTargetDevice,
2586 LOGPALETTE** ppColorSet)
2589 IShellViewImpl *This = impl_from_IViewObject(iface);
2591 FIXME("Stub: This=%p\n",This);
2593 return E_NOTIMPL;
2595 static HRESULT WINAPI ISVViewObject_Freeze(
2596 IViewObject *iface,
2597 DWORD dwDrawAspect,
2598 LONG lindex,
2599 void* pvAspect,
2600 DWORD* pdwFreeze)
2603 IShellViewImpl *This = impl_from_IViewObject(iface);
2605 FIXME("Stub: This=%p\n",This);
2607 return E_NOTIMPL;
2609 static HRESULT WINAPI ISVViewObject_Unfreeze(
2610 IViewObject *iface,
2611 DWORD dwFreeze)
2614 IShellViewImpl *This = impl_from_IViewObject(iface);
2616 FIXME("Stub: This=%p\n",This);
2618 return E_NOTIMPL;
2620 static HRESULT WINAPI ISVViewObject_SetAdvise(
2621 IViewObject *iface,
2622 DWORD aspects,
2623 DWORD advf,
2624 IAdviseSink* pAdvSink)
2627 IShellViewImpl *This = impl_from_IViewObject(iface);
2629 FIXME("partial stub: %p %08lx %08lx %p\n",
2630 This, aspects, advf, pAdvSink);
2632 /* FIXME: we set the AdviseSink, but never use it to send any advice */
2633 This->pAdvSink = pAdvSink;
2634 This->dwAspects = aspects;
2635 This->dwAdvf = advf;
2637 return S_OK;
2640 static HRESULT WINAPI ISVViewObject_GetAdvise(
2641 IViewObject *iface,
2642 DWORD* pAspects,
2643 DWORD* pAdvf,
2644 IAdviseSink** ppAdvSink)
2647 IShellViewImpl *This = impl_from_IViewObject(iface);
2649 TRACE("This=%p pAspects=%p pAdvf=%p ppAdvSink=%p\n",
2650 This, pAspects, pAdvf, ppAdvSink);
2652 if( ppAdvSink )
2654 IAdviseSink_AddRef( This->pAdvSink );
2655 *ppAdvSink = This->pAdvSink;
2657 if( pAspects )
2658 *pAspects = This->dwAspects;
2659 if( pAdvf )
2660 *pAdvf = This->dwAdvf;
2662 return S_OK;
2666 static const IViewObjectVtbl viewobjectvtbl =
2668 ISVViewObject_QueryInterface,
2669 ISVViewObject_AddRef,
2670 ISVViewObject_Release,
2671 ISVViewObject_Draw,
2672 ISVViewObject_GetColorSet,
2673 ISVViewObject_Freeze,
2674 ISVViewObject_Unfreeze,
2675 ISVViewObject_SetAdvise,
2676 ISVViewObject_GetAdvise
2679 /* IFolderView2 */
2680 static HRESULT WINAPI FolderView_QueryInterface(IFolderView2 *iface, REFIID riid, void **ppvObj)
2682 IShellViewImpl *This = impl_from_IFolderView2(iface);
2683 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
2686 static ULONG WINAPI FolderView_AddRef(IFolderView2 *iface)
2688 IShellViewImpl *This = impl_from_IFolderView2(iface);
2689 return IShellView3_AddRef(&This->IShellView3_iface);
2692 static ULONG WINAPI FolderView_Release(IFolderView2 *iface)
2694 IShellViewImpl *This = impl_from_IFolderView2(iface);
2695 return IShellView3_Release(&This->IShellView3_iface);
2698 static HRESULT WINAPI FolderView_GetCurrentViewMode(IFolderView2 *iface, UINT *mode)
2700 IShellViewImpl *This = impl_from_IFolderView2(iface);
2701 TRACE("%p, %p.\n", This, mode);
2703 if(!mode)
2704 return E_INVALIDARG;
2706 *mode = This->FolderSettings.ViewMode;
2707 return S_OK;
2710 static HRESULT WINAPI FolderView_SetCurrentViewMode(IFolderView2 *iface, UINT mode)
2712 IShellViewImpl *shellview = impl_from_IFolderView2(iface);
2713 DWORD style;
2715 TRACE("folder view %p, mode %u.\n", iface, mode);
2717 if (mode == FVM_AUTO)
2718 mode = FVM_ICON;
2720 if (mode >= FVM_FIRST && mode <= FVM_LAST)
2722 style = ViewModeToListStyle(mode);
2723 SetStyle(shellview, style, LVS_TYPEMASK);
2724 shellview->FolderSettings.ViewMode = mode;
2727 return S_OK;
2730 static HRESULT WINAPI FolderView_GetFolder(IFolderView2 *iface, REFIID riid, void **ppv)
2732 IShellViewImpl *This = impl_from_IFolderView2(iface);
2734 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
2736 return IShellFolder_QueryInterface(This->pSFParent, riid, ppv);
2739 static HRESULT WINAPI FolderView_Item(IFolderView2 *iface, int index, PITEMID_CHILD *ppidl)
2741 IShellViewImpl *This = impl_from_IFolderView2(iface);
2742 LVITEMW item;
2744 TRACE("(%p)->(%d %p)\n", This, index, ppidl);
2746 item.mask = LVIF_PARAM;
2747 item.iItem = index;
2749 if (SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM)&item))
2751 *ppidl = ILClone((PITEMID_CHILD)item.lParam);
2752 return S_OK;
2754 else
2756 *ppidl = 0;
2757 return E_INVALIDARG;
2761 static HRESULT WINAPI FolderView_ItemCount(IFolderView2 *iface, UINT flags, int *items)
2763 IShellViewImpl *This = impl_from_IFolderView2(iface);
2765 TRACE("(%p)->(%u %p)\n", This, flags, items);
2767 if (flags != SVGIO_ALLVIEW)
2768 FIXME("some flags unsupported, %x\n", flags & ~SVGIO_ALLVIEW);
2770 *items = SendMessageW(This->hWndList, LVM_GETITEMCOUNT, 0, 0);
2772 return S_OK;
2775 static HRESULT WINAPI FolderView_Items(IFolderView2 *iface, UINT flags, REFIID riid, void **ppv)
2777 IShellViewImpl *This = impl_from_IFolderView2(iface);
2778 FIXME("(%p)->(%u %s %p), stub\n", This, flags, debugstr_guid(riid), ppv);
2779 return E_NOTIMPL;
2782 static HRESULT WINAPI FolderView_GetSelectionMarkedItem(IFolderView2 *iface, int *item)
2784 IShellViewImpl *This = impl_from_IFolderView2(iface);
2786 TRACE("(%p)->(%p)\n", This, item);
2788 *item = SendMessageW(This->hWndList, LVM_GETSELECTIONMARK, 0, 0);
2790 return S_OK;
2793 static HRESULT WINAPI FolderView_GetFocusedItem(IFolderView2 *iface, int *item)
2795 IShellViewImpl *This = impl_from_IFolderView2(iface);
2797 TRACE("(%p)->(%p)\n", This, item);
2799 *item = SendMessageW(This->hWndList, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
2801 return S_OK;
2804 static HRESULT WINAPI FolderView_GetItemPosition(IFolderView2 *iface, PCUITEMID_CHILD pidl, POINT *ppt)
2806 IShellViewImpl *This = impl_from_IFolderView2(iface);
2807 FIXME("(%p)->(%p %p), stub\n", This, pidl, ppt);
2808 return E_NOTIMPL;
2811 static HRESULT WINAPI FolderView_GetSpacing(IFolderView2 *iface, POINT *pt)
2813 IShellViewImpl *This = impl_from_IFolderView2(iface);
2815 TRACE("(%p)->(%p)\n", This, pt);
2817 if (!This->hWndList) return S_FALSE;
2819 if (pt)
2821 DWORD ret;
2822 ret = SendMessageW(This->hWndList, LVM_GETITEMSPACING, 0, 0);
2824 pt->x = LOWORD(ret);
2825 pt->y = HIWORD(ret);
2828 return S_OK;
2831 static HRESULT WINAPI FolderView_GetDefaultSpacing(IFolderView2 *iface, POINT *pt)
2833 IShellViewImpl *This = impl_from_IFolderView2(iface);
2834 FIXME("(%p)->(%p), stub\n", This, pt);
2835 return E_NOTIMPL;
2838 static HRESULT WINAPI FolderView_GetAutoArrange(IFolderView2 *iface)
2840 IShellViewImpl *This = impl_from_IFolderView2(iface);
2841 FIXME("(%p), stub\n", This);
2842 return E_NOTIMPL;
2845 static HRESULT WINAPI FolderView_SelectItem(IFolderView2 *iface, int item, DWORD flags)
2847 IShellViewImpl *This = impl_from_IFolderView2(iface);
2848 LVITEMW lvItem;
2850 TRACE("(%p)->(%d, %lx)\n", This, item, flags);
2852 lvItem.state = 0;
2853 lvItem.stateMask = LVIS_SELECTED;
2855 if (flags & SVSI_ENSUREVISIBLE)
2856 SendMessageW(This->hWndList, LVM_ENSUREVISIBLE, item, 0);
2858 /* all items */
2859 if (flags & SVSI_DESELECTOTHERS)
2860 SendMessageW(This->hWndList, LVM_SETITEMSTATE, -1, (LPARAM)&lvItem);
2862 /* this item */
2863 if (flags & SVSI_SELECT)
2864 lvItem.state |= LVIS_SELECTED;
2866 if (flags & SVSI_FOCUSED)
2868 lvItem.stateMask |= LVIS_FOCUSED;
2869 lvItem.state |= LVIS_FOCUSED;
2872 SendMessageW(This->hWndList, LVM_SETITEMSTATE, item, (LPARAM)&lvItem);
2874 if ((flags & SVSI_EDIT) == SVSI_EDIT)
2875 SendMessageW(This->hWndList, LVM_EDITLABELW, item, 0);
2877 return S_OK;
2880 static HRESULT WINAPI FolderView_SelectAndPositionItems(IFolderView2 *iface, UINT cidl,
2881 PCUITEMID_CHILD_ARRAY apidl, POINT *apt, DWORD flags)
2883 IShellViewImpl *This = impl_from_IFolderView2(iface);
2884 FIXME("(%p)->(%u %p %p %lx), stub\n", This, cidl, apidl, apt, flags);
2885 return E_NOTIMPL;
2888 static HRESULT WINAPI FolderView2_SetGroupBy(IFolderView2 *iface, REFPROPERTYKEY key, BOOL ascending)
2890 IShellViewImpl *This = impl_from_IFolderView2(iface);
2891 FIXME("(%p)->(%p %d), stub\n", This, key, ascending);
2892 return E_NOTIMPL;
2895 static HRESULT WINAPI FolderView2_GetGroupBy(IFolderView2 *iface, PROPERTYKEY *pkey, BOOL *ascending)
2897 IShellViewImpl *This = impl_from_IFolderView2(iface);
2898 FIXME("(%p)->(%p %p), stub\n", This, pkey, ascending);
2899 return E_NOTIMPL;
2902 static HRESULT WINAPI FolderView2_SetViewProperty(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2903 REFPROPERTYKEY propkey, REFPROPVARIANT propvar)
2905 IShellViewImpl *This = impl_from_IFolderView2(iface);
2906 FIXME("(%p)->(%p %p %p), stub\n", This, pidl, propkey, propvar);
2907 return E_NOTIMPL;
2910 static HRESULT WINAPI FolderView2_GetViewProperty(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2911 REFPROPERTYKEY propkey, PROPVARIANT *propvar)
2913 IShellViewImpl *This = impl_from_IFolderView2(iface);
2914 FIXME("(%p)->(%p %p %p), stub\n", This, pidl, propkey, propvar);
2915 return E_NOTIMPL;
2918 static HRESULT WINAPI FolderView2_SetTileViewProperties(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2919 LPCWSTR prop_list)
2921 IShellViewImpl *This = impl_from_IFolderView2(iface);
2922 FIXME("(%p)->(%p %s), stub\n", This, pidl, debugstr_w(prop_list));
2923 return E_NOTIMPL;
2926 static HRESULT WINAPI FolderView2_SetExtendedTileViewProperties(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2927 LPCWSTR prop_list)
2929 IShellViewImpl *This = impl_from_IFolderView2(iface);
2930 FIXME("(%p)->(%p %s), stub\n", This, pidl, debugstr_w(prop_list));
2931 return E_NOTIMPL;
2934 static HRESULT WINAPI FolderView2_SetText(IFolderView2 *iface, FVTEXTTYPE type, LPCWSTR text)
2936 IShellViewImpl *This = impl_from_IFolderView2(iface);
2937 FIXME("(%p)->(%d %s), stub\n", This, type, debugstr_w(text));
2938 return E_NOTIMPL;
2941 static HRESULT WINAPI FolderView2_SetCurrentFolderFlags(IFolderView2 *iface, DWORD mask, DWORD flags)
2943 IShellViewImpl *shellview = impl_from_IFolderView2(iface);
2945 TRACE("folder view %p, mask %#lx, flags %#lx.\n", iface, mask, flags);
2947 shellview->FolderSettings.fFlags = (shellview->FolderSettings.fFlags & ~mask) | (flags & mask);
2948 return S_OK;
2951 static HRESULT WINAPI FolderView2_GetCurrentFolderFlags(IFolderView2 *iface, DWORD *flags)
2953 IShellViewImpl *shellview = impl_from_IFolderView2(iface);
2955 TRACE("folder view %p, flags %p.\n", iface, flags);
2957 if (flags)
2958 *flags = shellview->FolderSettings.fFlags;
2959 return S_OK;
2962 static HRESULT WINAPI FolderView2_GetSortColumnCount(IFolderView2 *iface, int *columns)
2964 IShellViewImpl *This = impl_from_IFolderView2(iface);
2965 FIXME("(%p)->(%p), stub\n", This, columns);
2966 return E_NOTIMPL;
2969 static HRESULT WINAPI FolderView2_SetSortColumns(IFolderView2 *iface, const SORTCOLUMN *columns,
2970 int count)
2972 IShellViewImpl *This = impl_from_IFolderView2(iface);
2973 FIXME("(%p)->(%p %d), stub\n", This, columns, count);
2974 return E_NOTIMPL;
2977 static HRESULT WINAPI FolderView2_GetSortColumns(IFolderView2 *iface, SORTCOLUMN *columns,
2978 int count)
2980 IShellViewImpl *This = impl_from_IFolderView2(iface);
2981 FIXME("(%p)->(%p %d), stub\n", This, columns, count);
2982 return E_NOTIMPL;
2985 static HRESULT WINAPI FolderView2_GetItem(IFolderView2 *iface, int item, REFIID riid, void **ppv)
2987 IShellViewImpl *This = impl_from_IFolderView2(iface);
2988 FIXME("(%p)->(%d %s %p), stub\n", This, item, debugstr_guid(riid), ppv);
2989 return E_NOTIMPL;
2992 static HRESULT WINAPI FolderView2_GetVisibleItem(IFolderView2 *iface, int start, BOOL previous,
2993 int *item)
2995 IShellViewImpl *This = impl_from_IFolderView2(iface);
2996 FIXME("(%p)->(%d %d %p), stub\n", This, start, previous, item);
2997 return E_NOTIMPL;
3000 static HRESULT WINAPI FolderView2_GetSelectedItem(IFolderView2 *iface, int start, int *item)
3002 IShellViewImpl *This = impl_from_IFolderView2(iface);
3003 FIXME("(%p)->(%d %p), stub\n", This, start, item);
3004 return E_NOTIMPL;
3007 static HRESULT WINAPI FolderView2_GetSelection(IFolderView2 *iface, BOOL none_implies_folder,
3008 IShellItemArray **array)
3010 IShellViewImpl *This = impl_from_IFolderView2(iface);
3011 FIXME("(%p)->(%d %p), stub\n", This, none_implies_folder, array);
3012 return E_NOTIMPL;
3015 static HRESULT WINAPI FolderView2_GetSelectionState(IFolderView2 *iface, PCUITEMID_CHILD pidl,
3016 DWORD *flags)
3018 IShellViewImpl *This = impl_from_IFolderView2(iface);
3019 FIXME("(%p)->(%p %p), stub\n", This, pidl, flags);
3020 return E_NOTIMPL;
3023 static HRESULT WINAPI FolderView2_InvokeVerbOnSelection(IFolderView2 *iface, LPCSTR verb)
3025 IShellViewImpl *This = impl_from_IFolderView2(iface);
3026 FIXME("(%p)->(%s), stub\n", This, debugstr_a(verb));
3027 return E_NOTIMPL;
3030 static HRESULT WINAPI FolderView2_SetViewModeAndIconSize(IFolderView2 *iface, FOLDERVIEWMODE mode,
3031 int size)
3033 IShellViewImpl *This = impl_from_IFolderView2(iface);
3034 FIXME("(%p)->(%d %d), stub\n", This, mode, size);
3035 return E_NOTIMPL;
3038 static HRESULT WINAPI FolderView2_GetViewModeAndIconSize(IFolderView2 *iface, FOLDERVIEWMODE *mode,
3039 int *size)
3041 IShellViewImpl *This = impl_from_IFolderView2(iface);
3042 FIXME("(%p)->(%p %p), stub\n", This, mode, size);
3043 return E_NOTIMPL;
3046 static HRESULT WINAPI FolderView2_SetGroupSubsetCount(IFolderView2 *iface, UINT visible_rows)
3048 IShellViewImpl *This = impl_from_IFolderView2(iface);
3049 FIXME("(%p)->(%u), stub\n", This, visible_rows);
3050 return E_NOTIMPL;
3053 static HRESULT WINAPI FolderView2_GetGroupSubsetCount(IFolderView2 *iface, UINT *visible_rows)
3055 IShellViewImpl *This = impl_from_IFolderView2(iface);
3056 FIXME("(%p)->(%p), stub\n", This, visible_rows);
3057 return E_NOTIMPL;
3060 static HRESULT WINAPI FolderView2_SetRedraw(IFolderView2 *iface, BOOL redraw)
3062 IShellViewImpl *This = impl_from_IFolderView2(iface);
3063 TRACE("(%p)->(%d)\n", This, redraw);
3064 SendMessageW(This->hWndList, WM_SETREDRAW, redraw, 0);
3065 return S_OK;
3068 static HRESULT WINAPI FolderView2_IsMoveInSameFolder(IFolderView2 *iface)
3070 IShellViewImpl *This = impl_from_IFolderView2(iface);
3071 FIXME("(%p), stub\n", This);
3072 return E_NOTIMPL;
3075 static HRESULT WINAPI FolderView2_DoRename(IFolderView2 *iface)
3077 IShellViewImpl *This = impl_from_IFolderView2(iface);
3078 FIXME("(%p), stub\n", This);
3079 return E_NOTIMPL;
3082 static const IFolderView2Vtbl folderviewvtbl =
3084 FolderView_QueryInterface,
3085 FolderView_AddRef,
3086 FolderView_Release,
3087 FolderView_GetCurrentViewMode,
3088 FolderView_SetCurrentViewMode,
3089 FolderView_GetFolder,
3090 FolderView_Item,
3091 FolderView_ItemCount,
3092 FolderView_Items,
3093 FolderView_GetSelectionMarkedItem,
3094 FolderView_GetFocusedItem,
3095 FolderView_GetItemPosition,
3096 FolderView_GetSpacing,
3097 FolderView_GetDefaultSpacing,
3098 FolderView_GetAutoArrange,
3099 FolderView_SelectItem,
3100 FolderView_SelectAndPositionItems,
3101 FolderView2_SetGroupBy,
3102 FolderView2_GetGroupBy,
3103 FolderView2_SetViewProperty,
3104 FolderView2_GetViewProperty,
3105 FolderView2_SetTileViewProperties,
3106 FolderView2_SetExtendedTileViewProperties,
3107 FolderView2_SetText,
3108 FolderView2_SetCurrentFolderFlags,
3109 FolderView2_GetCurrentFolderFlags,
3110 FolderView2_GetSortColumnCount,
3111 FolderView2_SetSortColumns,
3112 FolderView2_GetSortColumns,
3113 FolderView2_GetItem,
3114 FolderView2_GetVisibleItem,
3115 FolderView2_GetSelectedItem,
3116 FolderView2_GetSelection,
3117 FolderView2_GetSelectionState,
3118 FolderView2_InvokeVerbOnSelection,
3119 FolderView2_SetViewModeAndIconSize,
3120 FolderView2_GetViewModeAndIconSize,
3121 FolderView2_SetGroupSubsetCount,
3122 FolderView2_GetGroupSubsetCount,
3123 FolderView2_SetRedraw,
3124 FolderView2_IsMoveInSameFolder,
3125 FolderView2_DoRename
3128 /* IShellFolderView */
3129 static HRESULT WINAPI IShellFolderView_fnQueryInterface(IShellFolderView *iface, REFIID riid, void **ppvObj)
3131 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3132 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
3135 static ULONG WINAPI IShellFolderView_fnAddRef(IShellFolderView *iface)
3137 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3138 return IShellView3_AddRef(&This->IShellView3_iface);
3141 static ULONG WINAPI IShellFolderView_fnRelease(IShellFolderView *iface)
3143 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3144 return IShellView3_Release(&This->IShellView3_iface);
3147 static HRESULT WINAPI IShellFolderView_fnRearrange(IShellFolderView *iface, LPARAM sort)
3149 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3150 FIXME("(%p)->(%Id) stub\n", This, sort);
3151 return E_NOTIMPL;
3154 static HRESULT WINAPI IShellFolderView_fnGetArrangeParam(IShellFolderView *iface, LPARAM *sort)
3156 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3157 FIXME("(%p)->(%p) stub\n", This, sort);
3158 return E_NOTIMPL;
3161 static HRESULT WINAPI IShellFolderView_fnArrangeGrid(IShellFolderView *iface)
3163 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3164 FIXME("(%p) stub\n", This);
3165 return E_NOTIMPL;
3168 static HRESULT WINAPI IShellFolderView_fnAutoArrange(IShellFolderView *iface)
3170 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3171 TRACE("(%p)\n", This);
3172 return IFolderView2_SetCurrentFolderFlags(&This->IFolderView2_iface, FWF_AUTOARRANGE, FWF_AUTOARRANGE);
3175 static HRESULT WINAPI IShellFolderView_fnGetAutoArrange(IShellFolderView *iface)
3177 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3178 TRACE("(%p)\n", This);
3179 return IFolderView2_GetAutoArrange(&This->IFolderView2_iface);
3182 static HRESULT WINAPI IShellFolderView_fnAddObject(
3183 IShellFolderView *iface,
3184 PITEMID_CHILD pidl,
3185 UINT *item)
3187 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3188 FIXME("(%p)->(%p %p) stub\n", This, pidl, item);
3189 return E_NOTIMPL;
3192 static HRESULT WINAPI IShellFolderView_fnGetObject(
3193 IShellFolderView *iface,
3194 PITEMID_CHILD *pidl,
3195 UINT item)
3197 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3198 TRACE("(%p)->(%p %d)\n", This, pidl, item);
3199 return IFolderView2_Item(&This->IFolderView2_iface, item, pidl);
3202 static HRESULT WINAPI IShellFolderView_fnRemoveObject(
3203 IShellFolderView *iface,
3204 PITEMID_CHILD pidl,
3205 UINT *item)
3207 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3209 TRACE("(%p)->(%p %p)\n", This, pidl, item);
3211 if (pidl)
3213 *item = LV_FindItemByPidl(This, ILFindLastID(pidl));
3214 SendMessageW(This->hWndList, LVM_DELETEITEM, *item, 0);
3216 else
3218 *item = 0;
3219 SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0);
3222 return S_OK;
3225 static HRESULT WINAPI IShellFolderView_fnGetObjectCount(
3226 IShellFolderView *iface,
3227 UINT *count)
3229 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3230 TRACE("(%p)->(%p)\n", This, count);
3231 return IFolderView2_ItemCount(&This->IFolderView2_iface, SVGIO_ALLVIEW, (INT*)count);
3234 static HRESULT WINAPI IShellFolderView_fnSetObjectCount(
3235 IShellFolderView *iface,
3236 UINT count,
3237 UINT flags)
3239 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3240 FIXME("(%p)->(%d %x) stub\n", This, count, flags);
3241 return E_NOTIMPL;
3244 static HRESULT WINAPI IShellFolderView_fnUpdateObject(
3245 IShellFolderView *iface,
3246 PITEMID_CHILD pidl_old,
3247 PITEMID_CHILD pidl_new,
3248 UINT *item)
3250 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3251 FIXME("(%p)->(%p %p %p) stub\n", This, pidl_old, pidl_new, item);
3252 return E_NOTIMPL;
3255 static HRESULT WINAPI IShellFolderView_fnRefreshObject(
3256 IShellFolderView *iface,
3257 PITEMID_CHILD pidl,
3258 UINT *item)
3260 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3261 FIXME("(%p)->(%p %p) stub\n", This, pidl, item);
3262 return E_NOTIMPL;
3265 static HRESULT WINAPI IShellFolderView_fnSetRedraw(
3266 IShellFolderView *iface,
3267 BOOL redraw)
3269 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3270 TRACE("(%p)->(%d)\n", This, redraw);
3271 return IFolderView2_SetRedraw(&This->IFolderView2_iface, redraw);
3274 static HRESULT WINAPI IShellFolderView_fnGetSelectedCount(
3275 IShellFolderView *iface,
3276 UINT *count)
3278 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3279 IShellItemArray *selection;
3280 HRESULT hr;
3282 TRACE("(%p)->(%p)\n", This, count);
3284 *count = 0;
3285 hr = IFolderView2_GetSelection(&This->IFolderView2_iface, FALSE, &selection);
3286 if (FAILED(hr))
3287 return hr;
3289 hr = IShellItemArray_GetCount(selection, (DWORD *)count);
3290 IShellItemArray_Release(selection);
3291 return hr;
3294 static HRESULT WINAPI IShellFolderView_fnGetSelectedObjects(
3295 IShellFolderView *iface,
3296 PCITEMID_CHILD **pidl,
3297 UINT *items)
3299 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3301 TRACE("(%p)->(%p %p)\n", This, pidl, items);
3303 *items = ShellView_GetSelections( This );
3305 if (*items)
3307 *pidl = LocalAlloc(0, *items*sizeof(LPITEMIDLIST));
3308 if (!*pidl) return E_OUTOFMEMORY;
3310 /* it's documented that caller shouldn't free PIDLs, only array itself */
3311 memcpy((PITEMID_CHILD*)*pidl, This->apidl, *items*sizeof(LPITEMIDLIST));
3314 return S_OK;
3317 static HRESULT WINAPI IShellFolderView_fnIsDropOnSource(
3318 IShellFolderView *iface,
3319 IDropTarget *drop_target)
3321 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3322 FIXME("(%p)->(%p) stub\n", This, drop_target);
3323 return E_NOTIMPL;
3326 static HRESULT WINAPI IShellFolderView_fnGetDragPoint(
3327 IShellFolderView *iface,
3328 POINT *pt)
3330 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3331 FIXME("(%p)->(%p) stub\n", This, pt);
3332 return E_NOTIMPL;
3335 static HRESULT WINAPI IShellFolderView_fnGetDropPoint(
3336 IShellFolderView *iface,
3337 POINT *pt)
3339 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3340 FIXME("(%p)->(%p) stub\n", This, pt);
3341 return E_NOTIMPL;
3344 static HRESULT WINAPI IShellFolderView_fnMoveIcons(
3345 IShellFolderView *iface,
3346 IDataObject *obj)
3348 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3349 TRACE("(%p)->(%p)\n", This, obj);
3350 return E_NOTIMPL;
3353 static HRESULT WINAPI IShellFolderView_fnSetItemPos(
3354 IShellFolderView *iface,
3355 PCUITEMID_CHILD pidl,
3356 POINT *pt)
3358 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3359 FIXME("(%p)->(%p %p) stub\n", This, pidl, pt);
3360 return E_NOTIMPL;
3363 static HRESULT WINAPI IShellFolderView_fnIsBkDropTarget(
3364 IShellFolderView *iface,
3365 IDropTarget *drop_target)
3367 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3368 FIXME("(%p)->(%p) stub\n", This, drop_target);
3369 return E_NOTIMPL;
3372 static HRESULT WINAPI IShellFolderView_fnSetClipboard(
3373 IShellFolderView *iface,
3374 BOOL move)
3376 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3377 FIXME("(%p)->(%d) stub\n", This, move);
3378 return E_NOTIMPL;
3381 static HRESULT WINAPI IShellFolderView_fnSetPoints(
3382 IShellFolderView *iface,
3383 IDataObject *obj)
3385 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3386 FIXME("(%p)->(%p) stub\n", This, obj);
3387 return E_NOTIMPL;
3390 static HRESULT WINAPI IShellFolderView_fnGetItemSpacing(
3391 IShellFolderView *iface,
3392 ITEMSPACING *spacing)
3394 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3395 FIXME("(%p)->(%p) stub\n", This, spacing);
3396 return E_NOTIMPL;
3399 static HRESULT WINAPI IShellFolderView_fnSetCallback(
3400 IShellFolderView *iface,
3401 IShellFolderViewCB *new_cb,
3402 IShellFolderViewCB **old_cb)
3405 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3406 FIXME("(%p)->(%p %p) stub\n", This, new_cb, old_cb);
3407 return E_NOTIMPL;
3410 static HRESULT WINAPI IShellFolderView_fnSelect(
3411 IShellFolderView *iface,
3412 UINT flags)
3414 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3415 FIXME("(%p)->(%d) stub\n", This, flags);
3416 return E_NOTIMPL;
3419 static HRESULT WINAPI IShellFolderView_fnQuerySupport(
3420 IShellFolderView *iface,
3421 UINT *support)
3423 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3424 TRACE("(%p)->(%p)\n", This, support);
3425 return S_OK;
3428 static HRESULT WINAPI IShellFolderView_fnSetAutomationObject(
3429 IShellFolderView *iface,
3430 IDispatch *disp)
3432 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3433 FIXME("(%p)->(%p) stub\n", This, disp);
3434 return E_NOTIMPL;
3437 static const IShellFolderViewVtbl shellfolderviewvtbl =
3439 IShellFolderView_fnQueryInterface,
3440 IShellFolderView_fnAddRef,
3441 IShellFolderView_fnRelease,
3442 IShellFolderView_fnRearrange,
3443 IShellFolderView_fnGetArrangeParam,
3444 IShellFolderView_fnArrangeGrid,
3445 IShellFolderView_fnAutoArrange,
3446 IShellFolderView_fnGetAutoArrange,
3447 IShellFolderView_fnAddObject,
3448 IShellFolderView_fnGetObject,
3449 IShellFolderView_fnRemoveObject,
3450 IShellFolderView_fnGetObjectCount,
3451 IShellFolderView_fnSetObjectCount,
3452 IShellFolderView_fnUpdateObject,
3453 IShellFolderView_fnRefreshObject,
3454 IShellFolderView_fnSetRedraw,
3455 IShellFolderView_fnGetSelectedCount,
3456 IShellFolderView_fnGetSelectedObjects,
3457 IShellFolderView_fnIsDropOnSource,
3458 IShellFolderView_fnGetDragPoint,
3459 IShellFolderView_fnGetDropPoint,
3460 IShellFolderView_fnMoveIcons,
3461 IShellFolderView_fnSetItemPos,
3462 IShellFolderView_fnIsBkDropTarget,
3463 IShellFolderView_fnSetClipboard,
3464 IShellFolderView_fnSetPoints,
3465 IShellFolderView_fnGetItemSpacing,
3466 IShellFolderView_fnSetCallback,
3467 IShellFolderView_fnSelect,
3468 IShellFolderView_fnQuerySupport,
3469 IShellFolderView_fnSetAutomationObject
3472 static HRESULT WINAPI shellfolderviewdual_QueryInterface(IShellFolderViewDual3 *iface, REFIID riid, void **ppvObj)
3474 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3476 TRACE("(%p)->(IID:%s,%p)\n", This, debugstr_guid(riid), ppvObj);
3478 if (IsEqualIID(riid, &IID_IShellFolderViewDual3) ||
3479 IsEqualIID(riid, &IID_IShellFolderViewDual2) ||
3480 IsEqualIID(riid, &IID_IShellFolderViewDual) ||
3481 IsEqualIID(riid, &IID_IDispatch) ||
3482 IsEqualIID(riid, &IID_IUnknown))
3484 *ppvObj = iface;
3485 IShellFolderViewDual3_AddRef(iface);
3486 return S_OK;
3489 WARN("unsupported interface %s\n", debugstr_guid(riid));
3490 return E_NOINTERFACE;
3493 static ULONG WINAPI shellfolderviewdual_AddRef(IShellFolderViewDual3 *iface)
3495 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3496 return IShellView3_AddRef(&This->IShellView3_iface);
3499 static ULONG WINAPI shellfolderviewdual_Release(IShellFolderViewDual3 *iface)
3501 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3502 return IShellView3_Release(&This->IShellView3_iface);
3505 static HRESULT WINAPI shellfolderviewdual_GetTypeInfoCount(IShellFolderViewDual3 *iface, UINT *pctinfo)
3507 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3508 TRACE("%p %p\n", This, pctinfo);
3509 *pctinfo = 1;
3510 return S_OK;
3513 static HRESULT WINAPI shellfolderviewdual_GetTypeInfo(IShellFolderViewDual3 *iface,
3514 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
3516 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3517 HRESULT hr;
3519 TRACE("(%p,%u,%ld,%p)\n", This, iTInfo, lcid, ppTInfo);
3521 hr = get_typeinfo(IShellFolderViewDual3_tid, ppTInfo);
3522 if (SUCCEEDED(hr))
3523 ITypeInfo_AddRef(*ppTInfo);
3524 return hr;
3527 static HRESULT WINAPI shellfolderviewdual_GetIDsOfNames(
3528 IShellFolderViewDual3 *iface, REFIID riid, LPOLESTR *rgszNames, UINT
3529 cNames, LCID lcid, DISPID *rgDispId)
3531 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3532 ITypeInfo *ti;
3533 HRESULT hr;
3535 TRACE("(%p, %s, %p, %u, %ld, %p)\n", This, debugstr_guid(riid), rgszNames,
3536 cNames, lcid, rgDispId);
3538 hr = get_typeinfo(IShellFolderViewDual3_tid, &ti);
3539 if (SUCCEEDED(hr))
3540 hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId);
3541 return hr;
3544 static HRESULT WINAPI shellfolderviewdual_Invoke(IShellFolderViewDual3 *iface,
3545 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
3546 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
3547 UINT *puArgErr)
3549 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3550 ITypeInfo *ti;
3551 HRESULT hr;
3553 TRACE("(%p, %ld, %s, %ld, %u, %p, %p, %p, %p)\n", This, dispIdMember,
3554 debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult,
3555 pExcepInfo, puArgErr);
3557 hr = get_typeinfo(IShellFolderViewDual3_tid, &ti);
3558 if (SUCCEEDED(hr))
3559 hr = ITypeInfo_Invoke(ti, &This->IShellFolderViewDual3_iface, dispIdMember, wFlags, pDispParams,
3560 pVarResult, pExcepInfo, puArgErr);
3561 return hr;
3565 static HRESULT WINAPI shellfolderviewdual_get_Application(IShellFolderViewDual3 *iface,
3566 IDispatch **disp)
3568 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3570 TRACE("%p %p\n", This, disp);
3572 if (!disp)
3573 return E_INVALIDARG;
3575 return IShellDispatch_Constructor(NULL, &IID_IDispatch, (void**)disp);
3578 static HRESULT WINAPI shellfolderviewdual_get_Parent(IShellFolderViewDual3 *iface, IDispatch **disp)
3580 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3581 FIXME("%p %p\n", This, disp);
3582 return E_NOTIMPL;
3585 static HRESULT WINAPI shellfolderviewdual_get_Folder(IShellFolderViewDual3 *iface, Folder **folder)
3587 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3588 FIXME("%p %p\n", This, folder);
3589 return E_NOTIMPL;
3592 static HRESULT WINAPI shellfolderviewdual_SelectedItems(IShellFolderViewDual3 *iface, FolderItems **items)
3594 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3595 FIXME("%p %p\n", This, items);
3596 return E_NOTIMPL;
3599 static HRESULT WINAPI shellfolderviewdual_get_FocusedItem(IShellFolderViewDual3 *iface,
3600 FolderItem **item)
3602 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3603 FIXME("%p %p\n", This, item);
3604 return E_NOTIMPL;
3607 static HRESULT WINAPI shellfolderviewdual_SelectItem(IShellFolderViewDual3 *iface,
3608 VARIANT *v, int flags)
3610 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3611 FIXME("%p %s %x\n", This, debugstr_variant(v), flags);
3612 return E_NOTIMPL;
3615 static HRESULT WINAPI shellfolderviewdual_PopupItemMenu(IShellFolderViewDual3 *iface,
3616 FolderItem *item, VARIANT vx, VARIANT vy, BSTR *command)
3618 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3619 FIXME("%p %p %s %s %p\n", This, item, debugstr_variant(&vx), debugstr_variant(&vy), command);
3620 return E_NOTIMPL;
3623 static HRESULT WINAPI shellfolderviewdual_get_Script(IShellFolderViewDual3 *iface, IDispatch **disp)
3625 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3626 FIXME("%p %p\n", This, disp);
3627 return E_NOTIMPL;
3630 static HRESULT WINAPI shellfolderviewdual_get_ViewOptions(IShellFolderViewDual3 *iface, LONG *options)
3632 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3633 FIXME("%p %p\n", This, options);
3634 return E_NOTIMPL;
3637 static HRESULT WINAPI shellfolderviewdual_get_CurrentViewMode(IShellFolderViewDual3 *iface, UINT *mode)
3639 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3640 FIXME("%p %p\n", This, mode);
3641 return E_NOTIMPL;
3644 static HRESULT WINAPI shellfolderviewdual_put_CurrentViewMode(IShellFolderViewDual3 *iface, UINT mode)
3646 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3647 FIXME("%p %u\n", This, mode);
3648 return E_NOTIMPL;
3651 static HRESULT WINAPI shellfolderviewdual_SelectItemRelative(IShellFolderViewDual3 *iface, int relative)
3653 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3654 FIXME("%p %d\n", This, relative);
3655 return E_NOTIMPL;
3658 static HRESULT WINAPI shellfolderviewdual_get_GroupBy(IShellFolderViewDual3 *iface, BSTR *groupby)
3660 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3661 FIXME("%p %p\n", This, groupby);
3662 return E_NOTIMPL;
3665 static HRESULT WINAPI shellfolderviewdual_put_GroupBy(IShellFolderViewDual3 *iface, BSTR groupby)
3667 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3668 FIXME("%p %s\n", This, debugstr_w(groupby));
3669 return E_NOTIMPL;
3672 static HRESULT WINAPI shellfolderviewdual_get_FolderFlags(IShellFolderViewDual3 *iface, DWORD *flags)
3674 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3675 FIXME("%p %p\n", This, flags);
3676 return E_NOTIMPL;
3679 static HRESULT WINAPI shellfolderviewdual_put_FolderFlags(IShellFolderViewDual3 *iface, DWORD flags)
3681 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3682 FIXME("%p 0x%08lx\n", This, flags);
3683 return E_NOTIMPL;
3686 static HRESULT WINAPI shellfolderviewdual_get_SortColumns(IShellFolderViewDual3 *iface, BSTR *sortcolumns)
3688 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3689 FIXME("%p %p\n", This, sortcolumns);
3690 return E_NOTIMPL;
3693 static HRESULT WINAPI shellfolderviewdual_put_SortColumns(IShellFolderViewDual3 *iface, BSTR sortcolumns)
3695 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3696 FIXME("%p %s\n", This, debugstr_w(sortcolumns));
3697 return E_NOTIMPL;
3700 static HRESULT WINAPI shellfolderviewdual_put_IconSize(IShellFolderViewDual3 *iface, int icon_size)
3702 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3703 FIXME("%p %d\n", This, icon_size);
3704 return E_NOTIMPL;
3707 static HRESULT WINAPI shellfolderviewdual_get_IconSize(IShellFolderViewDual3 *iface, int *icon_size)
3709 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3710 FIXME("%p %p\n", This, icon_size);
3711 return E_NOTIMPL;
3714 static HRESULT WINAPI shellfolderviewdual_FilterView(IShellFolderViewDual3 *iface, BSTR filter_text)
3716 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3717 FIXME("%p %s\n", This, debugstr_w(filter_text));
3718 return E_NOTIMPL;
3721 static const IShellFolderViewDual3Vtbl shellfolderviewdualvtbl =
3723 shellfolderviewdual_QueryInterface,
3724 shellfolderviewdual_AddRef,
3725 shellfolderviewdual_Release,
3726 shellfolderviewdual_GetTypeInfoCount,
3727 shellfolderviewdual_GetTypeInfo,
3728 shellfolderviewdual_GetIDsOfNames,
3729 shellfolderviewdual_Invoke,
3730 shellfolderviewdual_get_Application,
3731 shellfolderviewdual_get_Parent,
3732 shellfolderviewdual_get_Folder,
3733 shellfolderviewdual_SelectedItems,
3734 shellfolderviewdual_get_FocusedItem,
3735 shellfolderviewdual_SelectItem,
3736 shellfolderviewdual_PopupItemMenu,
3737 shellfolderviewdual_get_Script,
3738 shellfolderviewdual_get_ViewOptions,
3739 shellfolderviewdual_get_CurrentViewMode,
3740 shellfolderviewdual_put_CurrentViewMode,
3741 shellfolderviewdual_SelectItemRelative,
3742 shellfolderviewdual_get_GroupBy,
3743 shellfolderviewdual_put_GroupBy,
3744 shellfolderviewdual_get_FolderFlags,
3745 shellfolderviewdual_put_FolderFlags,
3746 shellfolderviewdual_get_SortColumns,
3747 shellfolderviewdual_put_SortColumns,
3748 shellfolderviewdual_put_IconSize,
3749 shellfolderviewdual_get_IconSize,
3750 shellfolderviewdual_FilterView
3753 /**********************************************************
3754 * IShellView_Constructor
3756 IShellView *IShellView_Constructor(IShellFolder *folder)
3758 IShellViewImpl *sv;
3760 sv = heap_alloc_zero(sizeof(*sv));
3761 if (!sv)
3762 return NULL;
3764 sv->ref = 1;
3765 sv->IShellView3_iface.lpVtbl = &shellviewvtbl;
3766 sv->IOleCommandTarget_iface.lpVtbl = &olecommandtargetvtbl;
3767 sv->IDropTarget_iface.lpVtbl = &droptargetvtbl;
3768 sv->IDropSource_iface.lpVtbl = &dropsourcevtbl;
3769 sv->IViewObject_iface.lpVtbl = &viewobjectvtbl;
3770 sv->IFolderView2_iface.lpVtbl = &folderviewvtbl;
3771 sv->IShellFolderView_iface.lpVtbl = &shellfolderviewvtbl;
3772 sv->IShellFolderViewDual3_iface.lpVtbl = &shellfolderviewdualvtbl;
3774 sv->pSFParent = folder;
3775 if (folder) IShellFolder_AddRef(folder);
3776 IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (void**)&sv->pSF2Parent);
3778 sv->pCurDropTarget = NULL;
3779 sv->pCurDataObject = NULL;
3780 sv->iDragOverItem = 0;
3781 sv->cScrollDelay = 0;
3782 sv->ptLastMousePos.x = 0;
3783 sv->ptLastMousePos.y = 0;
3784 sv->FolderSettings.ViewMode = FVM_TILE;
3785 sv->FolderSettings.fFlags = FWF_USESEARCHFOLDER;
3787 TRACE("(%p)->(%p)\n", sv, folder);
3788 return (IShellView*)&sv->IShellView3_iface;
3791 /*************************************************************************
3792 * SHCreateShellFolderView [SHELL32.256]
3794 * Create a new instance of the default Shell folder view object.
3796 * RETURNS
3797 * Success: S_OK
3798 * Failure: error value
3800 * NOTES
3801 * see IShellFolder::CreateViewObject
3803 HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *desc, IShellView **shellview)
3805 TRACE("(%p, %p)\n", desc, shellview);
3807 *shellview = NULL;
3809 if (!desc || desc->cbSize != sizeof(*desc))
3810 return E_INVALIDARG;
3812 TRACE("sf=%p outer=%p callback=%p\n", desc->pshf, desc->psvOuter, desc->psfvcb);
3814 if (!desc->pshf)
3815 return E_UNEXPECTED;
3817 *shellview = IShellView_Constructor(desc->pshf);
3818 if (!*shellview)
3819 return E_OUTOFMEMORY;
3821 if (desc->psfvcb)
3823 IShellFolderView *view;
3824 IShellView_QueryInterface(*shellview, &IID_IShellFolderView, (void **)&view);
3825 IShellFolderView_SetCallback(view, desc->psfvcb, NULL);
3826 IShellFolderView_Release(view);
3829 return S_OK;
3832 /*************************************************************************
3833 * SHCreateShellFolderViewEx [SHELL32.174]
3835 * Create a new instance of the default Shell folder view object.
3837 * RETURNS
3838 * Success: S_OK
3839 * Failure: error value
3841 * NOTES
3842 * see IShellFolder::CreateViewObject
3844 HRESULT WINAPI SHCreateShellFolderViewEx(CSFV *desc, IShellView **shellview)
3846 TRACE("(%p, %p)\n", desc, shellview);
3848 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n", desc->pshf, desc->pidl, desc->pfnCallback,
3849 desc->fvm, desc->psvOuter);
3851 if (!desc->pshf)
3852 return E_UNEXPECTED;
3854 *shellview = IShellView_Constructor(desc->pshf);
3855 if (!*shellview)
3856 return E_OUTOFMEMORY;
3858 return S_OK;