user32/tests: Fix monitor test failures on some systems.
[wine.git] / dlls / shell32 / shlview.c
blobff1332087d16121bf3775eb42dc949db8f91ec66
1 /*
2 * ShellView
4 * Copyright 1998,1999 <juergen.schmied@debitel.net>
6 * This is the view visualizing the data provided by the shellfolder.
7 * No direct access to data from pidls should be done from here.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * FIXME: The order by part of the background context menu should be
24 * built according to the columns shown.
26 * FIXME: Load/Save the view state from/into the stream provided by
27 * the ShellBrowser
29 * FIXME: CheckToolbar: handle the "new folder" and "folder up" button
31 * FIXME: ShellView_FillList: consider sort orders
33 * FIXME: implement the drag and drop in the old (msg-based) way
35 * FIXME: when the ShellView_WndProc gets a WM_NCDESTROY should we do a
36 * Release() ???
39 #include "config.h"
40 #include "wine/port.h"
42 #include <stdarg.h>
43 #include <stdlib.h>
44 #include <string.h>
46 #define CINTERFACE
47 #define COBJMACROS
48 #define NONAMELESSUNION
50 #include "windef.h"
51 #include "winerror.h"
52 #include "winbase.h"
53 #include "winnls.h"
54 #include "objbase.h"
55 #include "servprov.h"
56 #include "shlguid.h"
57 #include "wingdi.h"
58 #include "winuser.h"
59 #include "shlobj.h"
60 #include "shobjidl.h"
61 #include "undocshell.h"
62 #include "shresdef.h"
63 #include "wine/debug.h"
65 #include "docobj.h"
66 #include "pidl.h"
67 #include "shell32_main.h"
68 #include "shellfolder.h"
70 WINE_DEFAULT_DEBUG_CHANNEL(shell);
72 static const WCHAR SV_CLASS_NAME[] = {'S','H','E','L','L','D','L','L','_','D','e','f','V','i','e','w',0};
74 typedef struct
75 { BOOL bIsAscending;
76 INT nHeaderID;
77 INT nLastHeaderID;
78 }LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO;
80 typedef struct
82 IShellView3 IShellView3_iface;
83 IOleCommandTarget IOleCommandTarget_iface;
84 IDropTarget IDropTarget_iface;
85 IDropSource IDropSource_iface;
86 IViewObject IViewObject_iface;
87 IFolderView2 IFolderView2_iface;
88 IShellFolderView IShellFolderView_iface;
89 IShellFolderViewDual3 IShellFolderViewDual3_iface;
90 LONG ref;
91 IShellFolder* pSFParent;
92 IShellFolder2* pSF2Parent;
93 IShellBrowser* pShellBrowser;
94 ICommDlgBrowser* pCommDlgBrowser;
95 HWND hWnd; /* SHELLDLL_DefView */
96 HWND hWndList; /* ListView control */
97 HWND hWndParent;
98 FOLDERSETTINGS FolderSettings;
99 HMENU hMenu;
100 UINT uState;
101 UINT cidl;
102 LPITEMIDLIST *apidl;
103 LISTVIEW_SORT_INFO ListViewSortInfo;
104 ULONG hNotify; /* change notification handle */
105 HANDLE hAccel;
106 DWORD dwAspects;
107 DWORD dwAdvf;
108 IAdviseSink *pAdvSink;
109 IDropTarget* pCurDropTarget; /* The sub-item, which is currently dragged over */
110 IDataObject* pCurDataObject; /* The dragged data-object */
111 LONG iDragOverItem; /* Dragged over item's index, iff pCurDropTarget != NULL */
112 UINT cScrollDelay; /* Send a WM_*SCROLL msg every 250 ms during drag-scroll */
113 POINT ptLastMousePos; /* Mouse position at last DragOver call */
114 UINT columns; /* Number of shell folder columns */
115 } IShellViewImpl;
117 static inline IShellViewImpl *impl_from_IShellView3(IShellView3 *iface)
119 return CONTAINING_RECORD(iface, IShellViewImpl, IShellView3_iface);
122 static inline IShellViewImpl *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
124 return CONTAINING_RECORD(iface, IShellViewImpl, IOleCommandTarget_iface);
127 static inline IShellViewImpl *impl_from_IDropTarget(IDropTarget *iface)
129 return CONTAINING_RECORD(iface, IShellViewImpl, IDropTarget_iface);
132 static inline IShellViewImpl *impl_from_IDropSource(IDropSource *iface)
134 return CONTAINING_RECORD(iface, IShellViewImpl, IDropSource_iface);
137 static inline IShellViewImpl *impl_from_IViewObject(IViewObject *iface)
139 return CONTAINING_RECORD(iface, IShellViewImpl, IViewObject_iface);
142 static inline IShellViewImpl *impl_from_IFolderView2(IFolderView2 *iface)
144 return CONTAINING_RECORD(iface, IShellViewImpl, IFolderView2_iface);
147 static inline IShellViewImpl *impl_from_IShellFolderView(IShellFolderView *iface)
149 return CONTAINING_RECORD(iface, IShellViewImpl, IShellFolderView_iface);
152 static inline IShellViewImpl *impl_from_IShellFolderViewDual3(IShellFolderViewDual3 *iface)
154 return CONTAINING_RECORD(iface, IShellViewImpl, IShellFolderViewDual3_iface);
157 /* ListView Header IDs */
158 #define LISTVIEW_COLUMN_NAME 0
159 #define LISTVIEW_COLUMN_SIZE 1
160 #define LISTVIEW_COLUMN_TYPE 2
161 #define LISTVIEW_COLUMN_TIME 3
162 #define LISTVIEW_COLUMN_ATTRIB 4
164 /*menu items */
165 #define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500)
166 #define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501)
167 #define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502)
169 #define ID_LISTVIEW 1
171 #define SHV_CHANGE_NOTIFY WM_USER + 0x1111
173 /*windowsx.h */
174 #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
175 #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
176 #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
179 Items merged into the toolbar and the filemenu
181 typedef struct
182 { int idCommand;
183 int iImage;
184 int idButtonString;
185 int idMenuString;
186 BYTE bState;
187 BYTE bStyle;
188 } MYTOOLINFO, *LPMYTOOLINFO;
190 static const MYTOOLINFO Tools[] =
192 { FCIDM_SHVIEW_BIGICON, 0, 0, IDS_VIEW_LARGE, TBSTATE_ENABLED, BTNS_BUTTON },
193 { FCIDM_SHVIEW_SMALLICON, 0, 0, IDS_VIEW_SMALL, TBSTATE_ENABLED, BTNS_BUTTON },
194 { FCIDM_SHVIEW_LISTVIEW, 0, 0, IDS_VIEW_LIST, TBSTATE_ENABLED, BTNS_BUTTON },
195 { FCIDM_SHVIEW_REPORTVIEW, 0, 0, IDS_VIEW_DETAILS, TBSTATE_ENABLED, BTNS_BUTTON },
196 { -1, 0, 0, 0, 0, 0}
199 typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
201 /**********************************************************
203 * ##### helperfunctions for communication with ICommDlgBrowser #####
205 static BOOL IsInCommDlg(IShellViewImpl * This)
207 return This->pCommDlgBrowser != NULL;
210 static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl)
212 HRESULT ret = S_OK;
214 if (IsInCommDlg(This))
216 TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
217 ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView *)&This->IShellView3_iface, pidl);
218 TRACE("-- returns 0x%08x\n", ret);
221 return ret;
224 static HRESULT OnDefaultCommand(IShellViewImpl * This)
226 HRESULT ret = S_FALSE;
228 if (IsInCommDlg(This))
230 TRACE("ICommDlgBrowser::OnDefaultCommand\n");
231 ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView *)&This->IShellView3_iface);
232 TRACE("-- returns 0x%08x\n", ret);
235 return ret;
238 static HRESULT OnStateChange(IShellViewImpl * This, UINT change)
240 HRESULT ret = S_FALSE;
242 if (IsInCommDlg(This))
244 TRACE("ICommDlgBrowser::OnStateChange change=%d\n", change);
245 ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView *)&This->IShellView3_iface, change);
246 TRACE("-- returns 0x%08x\n", ret);
249 return ret;
252 /**********************************************************
253 * set the toolbar of the filedialog buttons
255 * - activates the buttons from the shellbrowser according to
256 * the view state
258 static void CheckToolbar(IShellViewImpl * This)
260 LRESULT result;
262 TRACE("\n");
264 if (IsInCommDlg(This))
266 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
267 FCIDM_TB_SMALLICON, This->FolderSettings.ViewMode == FVM_LIST, &result);
268 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
269 FCIDM_TB_REPORTVIEW, This->FolderSettings.ViewMode == FVM_DETAILS, &result);
270 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
271 FCIDM_TB_SMALLICON, TRUE, &result);
272 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
273 FCIDM_TB_REPORTVIEW, TRUE, &result);
277 /**********************************************************
279 * ##### helperfunctions for initializing the view #####
281 /**********************************************************
282 * change the style of the listview control
284 static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove)
286 DWORD tmpstyle;
288 TRACE("(%p)\n", This);
290 tmpstyle = GetWindowLongW(This->hWndList, GWL_STYLE);
291 SetWindowLongW(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove));
294 static DWORD ViewModeToListStyle(UINT ViewMode)
296 DWORD dwStyle;
298 TRACE("%d\n", ViewMode);
300 switch (ViewMode)
302 case FVM_ICON: dwStyle = LVS_ICON; break;
303 case FVM_DETAILS: dwStyle = LVS_REPORT; break;
304 case FVM_SMALLICON: dwStyle = LVS_SMALLICON; break;
305 case FVM_LIST: dwStyle = LVS_LIST; break;
306 default:
308 FIXME("ViewMode %d not implemented\n", ViewMode);
309 dwStyle = LVS_LIST;
310 break;
314 return dwStyle;
317 /**********************************************************
318 * ShellView_CreateList()
320 * - creates the list view window
322 static BOOL ShellView_CreateList (IShellViewImpl * This)
323 { DWORD dwStyle, dwExStyle;
325 TRACE("%p\n",This);
327 dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
328 LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_AUTOARRANGE;
329 dwExStyle = WS_EX_CLIENTEDGE;
331 dwStyle |= ViewModeToListStyle(This->FolderSettings.ViewMode);
333 if (This->FolderSettings.fFlags & FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE;
334 if (This->FolderSettings.fFlags & FWF_DESKTOP)
335 This->FolderSettings.fFlags |= FWF_NOCLIENTEDGE | FWF_NOSCROLL;
336 if (This->FolderSettings.fFlags & FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL;
337 if (This->FolderSettings.fFlags & FWF_NOCLIENTEDGE)
338 dwExStyle &= ~WS_EX_CLIENTEDGE;
340 This->hWndList=CreateWindowExW( dwExStyle,
341 WC_LISTVIEWW,
342 NULL,
343 dwStyle,
344 0,0,0,0,
345 This->hWnd,
346 (HMENU)ID_LISTVIEW,
347 shell32_hInstance,
348 NULL);
350 if(!This->hWndList)
351 return FALSE;
353 This->ListViewSortInfo.bIsAscending = TRUE;
354 This->ListViewSortInfo.nHeaderID = -1;
355 This->ListViewSortInfo.nLastHeaderID = -1;
357 if (This->FolderSettings.fFlags & FWF_DESKTOP) {
359 * FIXME: look at the registry value
360 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ListviewShadow
361 * and activate drop shadows if necessary
363 if (0)
364 SendMessageW(This->hWndList, LVM_SETTEXTBKCOLOR, 0, CLR_NONE);
365 else
366 SendMessageW(This->hWndList, LVM_SETTEXTBKCOLOR, 0, GetSysColor(COLOR_DESKTOP));
368 SendMessageW(This->hWndList, LVM_SETTEXTCOLOR, 0, RGB(255,255,255));
371 /* UpdateShellSettings(); */
372 return TRUE;
375 /**********************************************************
376 * ShellView_InitList()
378 * - adds all needed columns to the shellview
380 static void ShellView_InitList(IShellViewImpl *This)
382 IShellDetails *details = NULL;
383 HIMAGELIST big_icons, small_icons;
384 LVCOLUMNW lvColumn;
385 SHELLDETAILS sd;
386 WCHAR nameW[50];
387 HRESULT hr;
388 HFONT list_font, old_font;
389 HDC list_dc;
390 TEXTMETRICW tm;
392 TRACE("(%p)\n", This);
394 Shell_GetImageLists( &big_icons, &small_icons );
395 SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0);
396 SendMessageW(This->hWndList, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)small_icons);
397 SendMessageW(This->hWndList, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)big_icons);
399 lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
400 lvColumn.pszText = nameW;
402 if (!This->pSF2Parent)
404 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IShellDetails, (void**)&details);
405 if (hr != S_OK)
407 WARN("IShellFolder2/IShellDetails not supported\n");
408 return;
412 list_font = (HFONT)SendMessageW(This->hWndList, WM_GETFONT, 0, 0);
413 list_dc = GetDC(This->hWndList);
414 old_font = SelectObject(list_dc, list_font);
415 GetTextMetricsW(list_dc, &tm);
416 SelectObject(list_dc, old_font);
417 ReleaseDC(This->hWndList, list_dc);
419 for (This->columns = 0;; This->columns++)
421 if (This->pSF2Parent)
422 hr = IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, This->columns, &sd);
423 else
424 hr = IShellDetails_GetDetailsOf(details, NULL, This->columns, &sd);
425 if (FAILED(hr)) break;
427 lvColumn.fmt = sd.fmt;
428 lvColumn.cx = MulDiv(sd.cxChar, tm.tmAveCharWidth * 3, 2); /* chars->pixel */
429 StrRetToStrNW(nameW, ARRAY_SIZE(nameW), &sd.str, NULL);
430 SendMessageW(This->hWndList, LVM_INSERTCOLUMNW, This->columns, (LPARAM)&lvColumn);
433 if (details) IShellDetails_Release(details);
436 /* LVM_SORTITEMS callback used when initially inserting items */
437 static INT CALLBACK ShellView_CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
439 LPITEMIDLIST pidl1 = (LPITEMIDLIST)lParam1;
440 LPITEMIDLIST pidl2 = (LPITEMIDLIST)lParam2;
441 IShellFolder *folder = (IShellFolder *)lpData;
442 int ret;
444 TRACE("pidl1=%p, pidl2=%p, shellfolder=%p\n", pidl1, pidl2, folder);
446 ret = (SHORT)HRESULT_CODE(IShellFolder_CompareIDs(folder, 0, pidl1, pidl2));
447 TRACE("ret=%i\n", ret);
448 return ret;
451 /*************************************************************************
452 * ShellView_ListViewCompareItems
454 * Compare Function for the Listview (FileOpen Dialog)
456 * PARAMS
457 * lParam1 [I] the first ItemIdList to compare with
458 * lParam2 [I] the second ItemIdList to compare with
459 * lpData [I] The column ID for the header Ctrl to process
461 * RETURNS
462 * A negative value if the first item should precede the second,
463 * a positive value if the first item should follow the second,
464 * or zero if the two items are equivalent
466 * NOTES
467 * FIXME: function does what ShellView_CompareItems is supposed to do.
468 * unify it and figure out how to use the undocumented first parameter
469 * of IShellFolder_CompareIDs to do the job this function does and
470 * move this code to IShellFolder.
471 * make LISTVIEW_SORT_INFO obsolete
472 * the way this function works is only usable if we had only
473 * filesystemfolders (25/10/99 jsch)
475 static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
477 INT nDiff=0;
478 FILETIME fd1, fd2;
479 char strName1[MAX_PATH], strName2[MAX_PATH];
480 BOOL bIsFolder1, bIsFolder2,bIsBothFolder;
481 LPITEMIDLIST pItemIdList1 = lParam1;
482 LPITEMIDLIST pItemIdList2 = lParam2;
483 LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData;
486 bIsFolder1 = _ILIsFolder(pItemIdList1);
487 bIsFolder2 = _ILIsFolder(pItemIdList2);
488 bIsBothFolder = bIsFolder1 && bIsFolder2;
490 /* When sorting between a File and a Folder, the Folder gets sorted first */
491 if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder)
493 nDiff = bIsFolder1 ? -1 : 1;
495 else
497 /* Sort by Time: Folders or Files can be sorted */
499 if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)
501 _ILGetFileDateTime(pItemIdList1, &fd1);
502 _ILGetFileDateTime(pItemIdList2, &fd2);
503 nDiff = CompareFileTime(&fd2, &fd1);
505 /* Sort by Attribute: Folder or Files can be sorted */
506 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB)
508 _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH);
509 _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH);
510 nDiff = lstrcmpiA(strName1, strName2);
512 /* Sort by FileName: Folder or Files can be sorted */
513 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder)
515 /* Sort by Text */
516 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
517 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
518 nDiff = lstrcmpiA(strName1, strName2);
520 /* Sort by File Size, Only valid for Files */
521 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)
523 nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0));
525 /* Sort by File Type, Only valid for Files */
526 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)
528 /* Sort by Type */
529 _ILGetFileType(pItemIdList1, strName1, MAX_PATH);
530 _ILGetFileType(pItemIdList2, strName2, MAX_PATH);
531 nDiff = lstrcmpiA(strName1, strName2);
534 /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
536 if(nDiff == 0)
538 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
539 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
540 nDiff = lstrcmpiA(strName1, strName2);
543 if(!pSortInfo->bIsAscending)
545 nDiff = -nDiff;
548 return nDiff;
552 /**********************************************************
553 * LV_FindItemByPidl()
555 static int LV_FindItemByPidl(
556 IShellViewImpl * This,
557 LPCITEMIDLIST pidl)
559 LVITEMW lvItem;
560 lvItem.iSubItem = 0;
561 lvItem.mask = LVIF_PARAM;
562 for(lvItem.iItem = 0;
563 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
564 lvItem.iItem++)
566 LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam;
567 HRESULT hr = IShellFolder_CompareIDs(This->pSFParent, 0, pidl, currentpidl);
568 if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
570 return lvItem.iItem;
573 return -1;
576 static void shellview_add_item(IShellViewImpl *shellview, LPCITEMIDLIST pidl)
578 LVITEMW item;
579 UINT i;
581 TRACE("(%p)(pidl=%p)\n", shellview, pidl);
583 item.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
584 item.iItem = 0;
585 item.iSubItem = 0;
586 item.lParam = (LPARAM)pidl;
587 item.pszText = LPSTR_TEXTCALLBACKW;
588 item.iImage = I_IMAGECALLBACK;
589 SendMessageW(shellview->hWndList, LVM_INSERTITEMW, 0, (LPARAM)&item);
591 for (i = 1; i < shellview->columns; i++)
593 item.mask = LVIF_TEXT;
594 item.iItem = 0;
595 item.iSubItem = 1;
596 item.pszText = LPSTR_TEXTCALLBACKW;
597 SendMessageW(shellview->hWndList, LVM_SETITEMW, 0, (LPARAM)&item);
601 /**********************************************************
602 * LV_RenameItem()
604 static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew )
606 int nItem;
607 LVITEMW lvItem;
609 TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew);
611 nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld));
612 if ( -1 != nItem )
614 lvItem.mask = LVIF_PARAM; /* only the pidl */
615 lvItem.iItem = nItem;
616 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
618 SHFree((LPITEMIDLIST)lvItem.lParam);
619 lvItem.mask = LVIF_PARAM;
620 lvItem.iItem = nItem;
621 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew)); /* set the item's data */
622 SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem);
623 SendMessageW(This->hWndList, LVM_UPDATE, nItem, 0);
624 return TRUE; /* FIXME: better handling */
626 return FALSE;
628 /**********************************************************
629 * ShellView_FillList()
631 * - gets the objectlist from the shellfolder
632 * - sorts the list
633 * - fills the list into the view
636 static HRESULT ShellView_FillList(IShellViewImpl *This)
638 IFolderView2 *folderview = &This->IFolderView2_iface;
639 LPENUMIDLIST pEnumIDList;
640 LPITEMIDLIST pidl;
641 DWORD fetched;
642 HRESULT hr;
644 TRACE("(%p)\n", This);
646 /* get the itemlist from the shfolder*/
647 hr = IShellFolder_EnumObjects(This->pSFParent, This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList);
648 if (hr != S_OK)
649 return hr;
651 IFolderView2_SetRedraw(folderview, FALSE);
653 /* copy the items into the array */
654 while ((S_OK == IEnumIDList_Next(pEnumIDList, 1, &pidl, &fetched)) && fetched)
656 if (IncludeObject(This, pidl) == S_OK)
657 shellview_add_item(This, pidl);
658 else
659 ILFree(pidl);
662 SendMessageW(This->hWndList, LVM_SORTITEMS, (WPARAM)This->pSFParent, (LPARAM)ShellView_CompareItems);
664 IFolderView2_SetRedraw(folderview, TRUE);
666 IEnumIDList_Release(pEnumIDList);
667 return S_OK;
670 /**********************************************************
671 * ShellView_OnCreate()
673 static LRESULT ShellView_OnCreate(IShellViewImpl *This)
675 IShellView3 *iface = &This->IShellView3_iface;
676 static const WCHAR accel_nameW[] = {'s','h','v','_','a','c','c','e','l',0};
677 IPersistFolder2 *ppf2;
678 IDropTarget* pdt;
679 HRESULT hr;
681 TRACE("(%p)\n", This);
683 if (ShellView_CreateList(This))
685 ShellView_InitList(This);
686 ShellView_FillList(This);
689 hr = IShellView3_QueryInterface(iface, &IID_IDropTarget, (void**)&pdt);
690 if (hr == S_OK)
692 RegisterDragDrop(This->hWnd, pdt);
693 IDropTarget_Release(pdt);
696 /* register for receiving notifications */
697 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2);
698 if (hr == S_OK)
700 LPITEMIDLIST raw_pidl;
701 SHChangeNotifyEntry ntreg;
703 hr = IPersistFolder2_GetCurFolder(ppf2, &raw_pidl);
704 if(SUCCEEDED(hr))
706 LPITEMIDLIST computer_pidl;
707 SHGetFolderLocation(NULL,CSIDL_DRIVES,NULL,0,&computer_pidl);
708 if(ILIsParent(computer_pidl,raw_pidl,FALSE))
710 /* Normalize the pidl to unixfs to workaround an issue with
711 * sending notifications on dos paths
713 WCHAR path[MAX_PATH];
714 SHGetPathFromIDListW(raw_pidl,path);
715 SHParseDisplayName(path,NULL,(LPITEMIDLIST*)&ntreg.pidl,0,NULL);
716 SHFree(raw_pidl);
718 else
719 ntreg.pidl = raw_pidl;
720 ntreg.fRecursive = TRUE;
721 This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNRF_InterruptLevel, SHCNE_ALLEVENTS,
722 SHV_CHANGE_NOTIFY, 1, &ntreg);
723 SHFree((LPITEMIDLIST)ntreg.pidl);
724 SHFree(computer_pidl);
726 IPersistFolder2_Release(ppf2);
729 This->hAccel = LoadAcceleratorsW(shell32_hInstance, accel_nameW);
731 return S_OK;
734 /**********************************************************
735 * #### Handling of the menus ####
738 /**********************************************************
739 * ShellView_BuildFileMenu()
741 static HMENU ShellView_BuildFileMenu(IShellViewImpl * This)
742 { WCHAR szText[MAX_PATH];
743 MENUITEMINFOW mii;
744 int nTools,i;
745 HMENU hSubMenu;
747 TRACE("(%p)\n",This);
749 hSubMenu = CreatePopupMenu();
750 if(hSubMenu)
751 { /*get the number of items in our global array*/
752 for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){}
754 /*add the menu items*/
755 for(i = 0; i < nTools; i++)
757 LoadStringW(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH);
759 ZeroMemory(&mii, sizeof(mii));
760 mii.cbSize = sizeof(mii);
761 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
763 if(BTNS_SEP != Tools[i].bStyle) /* no separator*/
765 mii.fType = MFT_STRING;
766 mii.fState = MFS_ENABLED;
767 mii.dwTypeData = szText;
768 mii.wID = Tools[i].idCommand;
770 else
772 mii.fType = MFT_SEPARATOR;
774 /* tack This item onto the end of the menu */
775 InsertMenuItemW(hSubMenu, (UINT)-1, TRUE, &mii);
778 TRACE("-- return (menu=%p)\n",hSubMenu);
779 return hSubMenu;
782 static void ShellView_MergeFileMenu(IShellViewImpl *This, HMENU hSubMenu)
784 if (hSubMenu)
786 static const WCHAR dummyW[] = {'d','u','m','m','y','4','5',0};
787 MENUITEMINFOW mii;
789 /* insert This item at the beginning of the menu */
791 mii.cbSize = sizeof(mii);
792 mii.fMask = MIIM_ID | MIIM_TYPE;
793 mii.wID = 0;
794 mii.fType = MFT_SEPARATOR;
795 InsertMenuItemW(hSubMenu, 0, TRUE, &mii);
797 mii.cbSize = sizeof(mii);
798 mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
799 mii.dwTypeData = (LPWSTR)dummyW;
800 mii.fState = MFS_ENABLED;
801 mii.wID = IDM_MYFILEITEM;
802 mii.fType = MFT_STRING;
803 InsertMenuItemW(hSubMenu, 0, TRUE, &mii);
807 /**********************************************************
808 * ShellView_MergeViewMenu()
811 static void ShellView_MergeViewMenu(IShellViewImpl *This, HMENU hSubMenu)
813 TRACE("(%p)->(submenu=%p)\n",This,hSubMenu);
815 /* add a separator at the correct position in the menu */
816 if (hSubMenu)
818 static const WCHAR menuW[] = {'M','E','N','U','_','0','0','1',0};
819 static const WCHAR viewW[] = {'V','i','e','w',0};
820 MENUITEMINFOW mii;
822 memset(&mii, 0, sizeof(mii));
823 mii.cbSize = sizeof(mii);
824 mii.fMask = MIIM_ID | MIIM_TYPE;
825 mii.wID = 0;
826 mii.fType = MFT_SEPARATOR;
827 InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
829 mii.cbSize = sizeof(mii);
830 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;
831 mii.fType = MFT_STRING;
832 mii.dwTypeData = (LPWSTR)viewW;
833 mii.hSubMenu = LoadMenuW(shell32_hInstance, menuW);
834 InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
838 /**********************************************************
839 * ShellView_GetSelections()
841 * - fills the this->apidl list with the selected objects
843 * RETURNS
844 * number of selected items
846 static UINT ShellView_GetSelections(IShellViewImpl * This)
848 LVITEMW lvItem;
849 UINT i = 0;
851 SHFree(This->apidl);
853 This->cidl = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0);
854 This->apidl = SHAlloc(This->cidl * sizeof(LPITEMIDLIST));
856 TRACE("selected=%i\n", This->cidl);
858 if(This->apidl)
860 TRACE("-- Items selected =%u\n", This->cidl);
862 lvItem.mask = LVIF_STATE | LVIF_PARAM;
863 lvItem.stateMask = LVIS_SELECTED;
864 lvItem.iItem = 0;
865 lvItem.iSubItem = 0;
867 while(ListView_GetItemW(This->hWndList, &lvItem) && (i < This->cidl))
869 if(lvItem.state & LVIS_SELECTED)
871 This->apidl[i] = (LPITEMIDLIST)lvItem.lParam;
872 i++;
873 TRACE("-- selected Item found\n");
875 lvItem.iItem++;
878 return This->cidl;
882 /**********************************************************
883 * ShellView_OpenSelectedItems()
885 static HRESULT ShellView_OpenSelectedItems(IShellViewImpl * This)
887 static UINT CF_IDLIST = 0;
888 HRESULT hr;
889 IDataObject* selection;
890 FORMATETC fetc;
891 STGMEDIUM stgm;
892 LPIDA pIDList;
893 LPCITEMIDLIST parent_pidl;
894 WCHAR parent_path[MAX_PATH];
895 LPCWSTR parent_dir = NULL;
896 SFGAOF attribs;
897 int i;
899 if (0 == ShellView_GetSelections(This))
901 return S_OK;
903 hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl,
904 (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,
905 0, (LPVOID *)&selection);
906 if (FAILED(hr))
907 return hr;
909 if (0 == CF_IDLIST)
911 CF_IDLIST = RegisterClipboardFormatW(CFSTR_SHELLIDLISTW);
913 fetc.cfFormat = CF_IDLIST;
914 fetc.ptd = NULL;
915 fetc.dwAspect = DVASPECT_CONTENT;
916 fetc.lindex = -1;
917 fetc.tymed = TYMED_HGLOBAL;
919 hr = IDataObject_QueryGetData(selection, &fetc);
920 if (FAILED(hr))
921 return hr;
923 hr = IDataObject_GetData(selection, &fetc, &stgm);
924 if (FAILED(hr))
925 return hr;
927 pIDList = GlobalLock(stgm.u.hGlobal);
929 parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pIDList+pIDList->aoffset[0]);
930 hr = IShellFolder_GetAttributesOf(This->pSFParent, 1, &parent_pidl, &attribs);
931 if (SUCCEEDED(hr) && (attribs & SFGAO_FILESYSTEM) &&
932 SHGetPathFromIDListW(parent_pidl, parent_path))
934 parent_dir = parent_path;
937 for (i = pIDList->cidl; i > 0; --i)
939 LPCITEMIDLIST pidl;
941 pidl = (LPCITEMIDLIST)((LPBYTE)pIDList+pIDList->aoffset[i]);
943 attribs = SFGAO_FOLDER;
944 hr = IShellFolder_GetAttributesOf(This->pSFParent, 1, &pidl, &attribs);
946 if (SUCCEEDED(hr) && ! (attribs & SFGAO_FOLDER))
948 SHELLEXECUTEINFOW shexinfo;
950 shexinfo.cbSize = sizeof(SHELLEXECUTEINFOW);
951 shexinfo.fMask = SEE_MASK_INVOKEIDLIST; /* SEE_MASK_IDLIST is also possible. */
952 shexinfo.hwnd = NULL;
953 shexinfo.lpVerb = NULL;
954 shexinfo.lpFile = NULL;
955 shexinfo.lpParameters = NULL;
956 shexinfo.lpDirectory = parent_dir;
957 shexinfo.nShow = SW_NORMAL;
958 shexinfo.lpIDList = ILCombine(parent_pidl, pidl);
960 ShellExecuteExW(&shexinfo); /* Discard error/success info */
962 ILFree(shexinfo.lpIDList);
966 GlobalUnlock(stgm.u.hGlobal);
967 ReleaseStgMedium(&stgm);
969 IDataObject_Release(selection);
971 return S_OK;
974 /**********************************************************
975 * ShellView_DoContextMenu()
977 static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL bDefault)
978 { UINT uCommand;
979 DWORD wFlags;
980 HMENU hMenu;
981 BOOL fExplore = FALSE;
982 HWND hwndTree = 0;
983 LPCONTEXTMENU pContextMenu = NULL;
984 CMINVOKECOMMANDINFO cmi;
986 TRACE("%p, %d, %d, %d.\n", This, x, y, bDefault);
988 /* look, what's selected and create a context menu object of it*/
989 if( ShellView_GetSelections(This) )
991 IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, (LPCITEMIDLIST*)This->apidl,
992 &IID_IContextMenu, NULL, (LPVOID *)&pContextMenu);
994 if(pContextMenu)
996 TRACE("-- pContextMenu\n");
997 hMenu = CreatePopupMenu();
999 if( hMenu )
1001 /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
1002 if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree)
1004 TRACE("-- explore mode\n");
1005 fExplore = TRUE;
1008 /* build the flags depending on what we can do with the selected item */
1009 wFlags = CMF_NORMAL | (This->cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0);
1011 /* let the ContextMenu merge its items in */
1012 if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags )))
1014 if (This->FolderSettings.fFlags & FWF_DESKTOP)
1015 SetMenuDefaultItem(hMenu, FCIDM_SHVIEW_OPEN, MF_BYCOMMAND);
1017 if( bDefault )
1019 TRACE("-- get menu default command\n");
1020 uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS);
1022 else
1024 TRACE("-- track popup\n");
1025 uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
1028 if(uCommand > 0)
1030 TRACE("-- uCommand=%u\n", uCommand);
1031 if (uCommand==FCIDM_SHVIEW_OPEN && IsInCommDlg(This))
1033 TRACE("-- dlg: OnDefaultCommand\n");
1034 if (OnDefaultCommand(This) != S_OK)
1036 ShellView_OpenSelectedItems(This);
1039 else
1041 TRACE("-- explore -- invoke command\n");
1042 ZeroMemory(&cmi, sizeof(cmi));
1043 cmi.cbSize = sizeof(cmi);
1044 cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */
1045 cmi.lpVerb = MAKEINTRESOURCEA(uCommand);
1046 IContextMenu_InvokeCommand(pContextMenu, &cmi);
1049 DestroyMenu(hMenu);
1052 if (pContextMenu)
1053 IContextMenu_Release(pContextMenu);
1056 else /* background context menu */
1058 IContextMenu2 *pCM;
1060 hMenu = CreatePopupMenu();
1062 BackgroundMenu_Constructor(This->pSFParent, FALSE, &IID_IContextMenu2, (void**)&pCM);
1063 IContextMenu2_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
1065 uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
1066 DestroyMenu(hMenu);
1068 TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand);
1070 ZeroMemory(&cmi, sizeof(cmi));
1071 cmi.cbSize = sizeof(cmi);
1072 cmi.lpVerb = MAKEINTRESOURCEA(uCommand);
1073 cmi.hwnd = This->hWndParent;
1074 IContextMenu2_InvokeCommand(pCM, &cmi);
1076 IContextMenu2_Release(pCM);
1080 /**********************************************************
1081 * ##### message handling #####
1084 /**********************************************************
1085 * ShellView_OnSize()
1087 static LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight)
1089 TRACE("%p width=%u height=%u\n",This, wWidth,wHeight);
1091 /*resize the ListView to fit our window*/
1092 if(This->hWndList)
1094 MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE);
1097 return S_OK;
1099 /**********************************************************
1100 * ShellView_OnDeactivate()
1102 * NOTES
1103 * internal
1105 static void ShellView_OnDeactivate(IShellViewImpl * This)
1107 TRACE("%p\n",This);
1109 if(This->uState != SVUIA_DEACTIVATE)
1111 if(This->hMenu)
1113 IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0);
1114 IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu);
1115 DestroyMenu(This->hMenu);
1116 This->hMenu = 0;
1119 This->uState = SVUIA_DEACTIVATE;
1123 /**********************************************************
1124 * ShellView_OnActivate()
1126 static LRESULT ShellView_OnActivate(IShellViewImpl *This, UINT uState)
1128 OLEMENUGROUPWIDTHS omw = { {0, 0, 0, 0, 0, 0} };
1129 MENUITEMINFOW mii;
1131 TRACE("(%p) uState=%x\n",This,uState);
1133 /* don't do anything if the state isn't really changing */
1134 if (This->uState == uState) return S_OK;
1136 ShellView_OnDeactivate(This);
1138 /* only do This if we are active */
1139 if (uState != SVUIA_DEACTIVATE)
1141 /* merge the menus */
1142 This->hMenu = CreateMenu();
1144 if (This->hMenu)
1146 static const WCHAR dummyW[] = {'d','u','m','m','y',' ','3','1',0};
1148 IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw);
1149 TRACE("-- after fnInsertMenusSB\n");
1151 mii.cbSize = sizeof(mii);
1152 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
1153 mii.fType = MFT_STRING;
1154 mii.fState = MFS_ENABLED;
1155 mii.wID = 0;
1156 mii.hSubMenu = ShellView_BuildFileMenu(This);
1157 mii.hbmpChecked = NULL;
1158 mii.hbmpUnchecked = NULL;
1159 mii.dwItemData = 0;
1160 /* build the top level menu get the menu item's text */
1161 mii.dwTypeData = (LPWSTR)dummyW;
1162 mii.cch = 0;
1163 mii.hbmpItem = NULL;
1165 /* insert our menu into the menu bar */
1166 if (mii.hSubMenu)
1167 InsertMenuItemW(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii);
1169 /* get the view menu so we can merge with it */
1170 memset(&mii, 0, sizeof(mii));
1171 mii.cbSize = sizeof(mii);
1172 mii.fMask = MIIM_SUBMENU;
1174 if (GetMenuItemInfoW(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii))
1175 ShellView_MergeViewMenu(This, mii.hSubMenu);
1177 /* add the items that should only be added if we have the focus */
1178 if (SVUIA_ACTIVATE_FOCUS == uState)
1180 /* get the file menu so we can merge with it */
1181 memset(&mii, 0, sizeof(mii));
1182 mii.cbSize = sizeof(mii);
1183 mii.fMask = MIIM_SUBMENU;
1185 if (GetMenuItemInfoW(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii))
1186 ShellView_MergeFileMenu(This, mii.hSubMenu);
1189 TRACE("-- before fnSetMenuSB\n");
1190 IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd);
1193 This->uState = uState;
1194 TRACE("--\n");
1195 return S_OK;
1198 /**********************************************************
1199 * ShellView_OnSetFocus()
1202 static LRESULT ShellView_OnSetFocus(IShellViewImpl * This)
1204 TRACE("%p\n",This);
1206 /* Tell the browser one of our windows has received the focus. This
1207 should always be done before merging menus (OnActivate merges the
1208 menus) if one of our windows has the focus.*/
1210 IShellBrowser_OnViewWindowActive(This->pShellBrowser, (IShellView *)&This->IShellView3_iface);
1211 ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS);
1213 /* Set the focus to the listview */
1214 SetFocus(This->hWndList);
1216 /* Notify the ICommDlgBrowser interface */
1217 OnStateChange(This,CDBOSC_SETFOCUS);
1219 return 0;
1222 /**********************************************************
1223 * ShellView_OnKillFocus()
1225 static LRESULT ShellView_OnKillFocus(IShellViewImpl * This)
1227 TRACE("%p.\n", This);
1229 ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS);
1230 /* Notify the ICommDlgBrowser */
1231 OnStateChange(This,CDBOSC_KILLFOCUS);
1233 return 0;
1236 /**********************************************************
1237 * ShellView_OnCommand()
1239 * NOTES
1240 * the CmdIDs are the ones from the context menu
1242 static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd)
1244 TRACE("(%p)->(0x%08x 0x%08x %p) stub\n",This, dwCmdID, dwCmd, hwndCmd);
1246 switch(dwCmdID)
1248 case FCIDM_SHVIEW_SMALLICON:
1249 This->FolderSettings.ViewMode = FVM_SMALLICON;
1250 SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK);
1251 CheckToolbar(This);
1252 break;
1254 case FCIDM_SHVIEW_BIGICON:
1255 This->FolderSettings.ViewMode = FVM_ICON;
1256 SetStyle (This, LVS_ICON, LVS_TYPEMASK);
1257 CheckToolbar(This);
1258 break;
1260 case FCIDM_SHVIEW_LISTVIEW:
1261 This->FolderSettings.ViewMode = FVM_LIST;
1262 SetStyle (This, LVS_LIST, LVS_TYPEMASK);
1263 CheckToolbar(This);
1264 break;
1266 case FCIDM_SHVIEW_REPORTVIEW:
1267 This->FolderSettings.ViewMode = FVM_DETAILS;
1268 SetStyle (This, LVS_REPORT, LVS_TYPEMASK);
1269 CheckToolbar(This);
1270 break;
1272 /* the menu IDs for sorting are 0x30... see shell32.rc */
1273 case 0x30:
1274 case 0x31:
1275 case 0x32:
1276 case 0x33:
1277 This->ListViewSortInfo.nHeaderID = dwCmdID - 0x30;
1278 This->ListViewSortInfo.bIsAscending = TRUE;
1279 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1280 SendMessageW(This->hWndList, LVM_SORTITEMS, (WPARAM) &This->ListViewSortInfo, (LPARAM)ShellView_ListViewCompareItems);
1281 break;
1283 default:
1284 TRACE("-- COMMAND 0x%04x unhandled\n", dwCmdID);
1286 return 0;
1289 /**********************************************************
1290 * ShellView_OnNotify()
1293 static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
1294 { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
1295 NMLVDISPINFOW *lpdi = (NMLVDISPINFOW *)lpnmh;
1296 LPITEMIDLIST pidl;
1298 TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code);
1300 switch(lpnmh->code)
1302 case NM_SETFOCUS:
1303 TRACE("-- NM_SETFOCUS %p\n",This);
1304 ShellView_OnSetFocus(This);
1305 break;
1307 case NM_KILLFOCUS:
1308 TRACE("-- NM_KILLFOCUS %p\n",This);
1309 ShellView_OnDeactivate(This);
1310 /* Notify the ICommDlgBrowser interface */
1311 OnStateChange(This,CDBOSC_KILLFOCUS);
1312 break;
1314 case NM_CUSTOMDRAW:
1315 TRACE("-- NM_CUSTOMDRAW %p\n",This);
1316 return CDRF_DODEFAULT;
1318 case NM_RELEASEDCAPTURE:
1319 TRACE("-- NM_RELEASEDCAPTURE %p\n",This);
1320 break;
1322 case NM_CLICK:
1323 TRACE("-- NM_CLICK %p\n",This);
1324 break;
1326 case NM_RCLICK:
1327 TRACE("-- NM_RCLICK %p\n",This);
1328 break;
1330 case NM_DBLCLK:
1331 TRACE("-- NM_DBLCLK %p\n",This);
1332 if (OnDefaultCommand(This) != S_OK) ShellView_OpenSelectedItems(This);
1333 break;
1335 case NM_RETURN:
1336 TRACE("-- NM_RETURN %p\n",This);
1337 if (OnDefaultCommand(This) != S_OK) ShellView_OpenSelectedItems(This);
1338 break;
1340 case HDN_ENDTRACKW:
1341 TRACE("-- HDN_ENDTRACKW %p\n",This);
1342 /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
1343 nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
1344 break;
1346 case LVN_DELETEITEM:
1347 TRACE("-- LVN_DELETEITEM %p\n",This);
1348 SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/
1349 break;
1351 case LVN_DELETEALLITEMS:
1352 TRACE("-- LVN_DELETEALLITEMS %p\n",This);
1353 return FALSE;
1355 case LVN_INSERTITEM:
1356 TRACE("-- LVN_INSERTITEM (STUB)%p\n",This);
1357 break;
1359 case LVN_ITEMACTIVATE:
1360 TRACE("-- LVN_ITEMACTIVATE %p\n",This);
1361 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1362 break;
1364 case LVN_COLUMNCLICK:
1365 This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem;
1366 if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID)
1368 This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending;
1370 else
1372 This->ListViewSortInfo.bIsAscending = TRUE;
1374 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1376 SendMessageW(lpnmlv->hdr.hwndFrom, LVM_SORTITEMS, (WPARAM) &This->ListViewSortInfo, (LPARAM)ShellView_ListViewCompareItems);
1377 break;
1379 case LVN_GETDISPINFOA:
1380 case LVN_GETDISPINFOW:
1381 TRACE("-- LVN_GETDISPINFO %p\n",This);
1382 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1384 if(lpdi->item.mask & LVIF_TEXT) /* text requested */
1386 static WCHAR emptyW[] = { 0 };
1387 SHELLDETAILS sd;
1388 HRESULT hr;
1390 if (This->pSF2Parent)
1392 hr = IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
1394 else
1396 IShellDetails *details;
1398 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IShellDetails, (void**)&details);
1399 if (hr == S_OK)
1401 hr = IShellDetails_GetDetailsOf(details, pidl, lpdi->item.iSubItem, &sd);
1402 IShellDetails_Release(details);
1404 else
1405 WARN("IShellFolder2/IShellDetails not supported\n");
1408 if (hr != S_OK)
1410 /* set to empty on failure */
1411 sd.str.uType = STRRET_WSTR;
1412 sd.str.u.pOleStr = emptyW;
1415 if (lpnmh->code == LVN_GETDISPINFOW)
1417 StrRetToStrNW( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1418 TRACE("-- text=%s\n", debugstr_w(lpdi->item.pszText));
1420 else
1422 /* LVN_GETDISPINFOA - shouldn't happen */
1423 NMLVDISPINFOA *lpdiA = (NMLVDISPINFOA *)lpnmh;
1424 StrRetToStrNA( lpdiA->item.pszText, lpdiA->item.cchTextMax, &sd.str, NULL);
1425 TRACE("-- text=%s\n", lpdiA->item.pszText);
1429 if(lpdi->item.mask & LVIF_IMAGE) /* image requested */
1431 lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
1433 break;
1435 case LVN_ITEMCHANGED:
1436 TRACE("-- LVN_ITEMCHANGED %p\n",This);
1437 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1438 break;
1440 case LVN_BEGINDRAG:
1441 case LVN_BEGINRDRAG:
1442 TRACE("-- LVN_BEGINDRAG\n");
1444 if (ShellView_GetSelections(This))
1446 IDataObject * pda;
1447 DWORD dwAttributes = SFGAO_CANLINK;
1448 DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
1450 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
1452 IDropSource *pds = &This->IDropSource_iface; /* own DropSource interface */
1454 if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, (LPCITEMIDLIST*)This->apidl, &dwAttributes)))
1456 if (dwAttributes & SFGAO_CANLINK)
1458 dwEffect |= DROPEFFECT_LINK;
1462 if (pds)
1464 DWORD dwEffect2;
1465 DoDragDrop(pda, pds, dwEffect, &dwEffect2);
1467 IDataObject_Release(pda);
1470 break;
1472 case LVN_BEGINLABELEDITW:
1474 DWORD dwAttr = SFGAO_CANRENAME;
1475 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1477 TRACE("-- LVN_BEGINLABELEDITW %p\n",This);
1479 IShellFolder_GetAttributesOf(This->pSFParent, 1, (LPCITEMIDLIST*)&pidl, &dwAttr);
1480 if (SFGAO_CANRENAME & dwAttr)
1482 return FALSE;
1484 return TRUE;
1487 case LVN_ENDLABELEDITW:
1489 TRACE("-- LVN_ENDLABELEDITA %p\n",This);
1490 if (lpdi->item.pszText)
1492 HRESULT hr;
1493 LVITEMW lvItem;
1495 lvItem.iItem = lpdi->item.iItem;
1496 lvItem.iSubItem = 0;
1497 lvItem.mask = LVIF_PARAM;
1498 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
1500 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1501 hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, lpdi->item.pszText, SHGDN_INFOLDER, &pidl);
1503 if(SUCCEEDED(hr) && pidl)
1505 lvItem.mask = LVIF_PARAM;
1506 lvItem.lParam = (LPARAM)pidl;
1507 SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem);
1508 return TRUE;
1511 return FALSE;
1514 case LVN_KEYDOWN:
1516 LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
1518 /* initiate a rename of the selected file or directory */
1519 switch (plvKeyDown->wVKey)
1521 case VK_F2:
1523 INT i = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0);
1525 if (i == 1)
1527 /* get selected item */
1528 i = SendMessageW(This->hWndList, LVM_GETNEXTITEM, -1, MAKELPARAM (LVNI_SELECTED, 0));
1530 SendMessageW(This->hWndList, LVM_ENSUREVISIBLE, i, 0);
1531 SendMessageW(This->hWndList, LVM_EDITLABELW, i, 0);
1534 break;
1535 case VK_DELETE:
1537 UINT i, count;
1538 int item_index;
1539 LVITEMW item;
1540 LPITEMIDLIST* pItems;
1541 ISFHelper *psfhlp;
1542 HRESULT hr;
1544 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (void**)&psfhlp);
1545 if (hr != S_OK) return 0;
1547 if(!(count = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0)))
1549 ISFHelper_Release(psfhlp);
1550 return 0;
1553 /* allocate memory for the pidl array */
1554 pItems = heap_alloc(sizeof(LPITEMIDLIST) * count);
1556 /* retrieve all selected items */
1557 i = 0;
1558 item_index = -1;
1560 while (count > i)
1562 /* get selected item */
1563 item_index = SendMessageW(This->hWndList, LVM_GETNEXTITEM, item_index,
1564 MAKELPARAM (LVNI_SELECTED, 0));
1565 item.iItem = item_index;
1566 item.mask = LVIF_PARAM;
1567 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM)&item);
1569 /* get item pidl */
1570 pItems[i] = (LPITEMIDLIST)item.lParam;
1572 i++;
1575 /* perform the item deletion */
1576 ISFHelper_DeleteItems(psfhlp, i, (LPCITEMIDLIST*)pItems);
1577 ISFHelper_Release(psfhlp);
1579 /* free pidl array memory */
1580 heap_free(pItems);
1582 break;
1584 case VK_F5:
1585 /* Initiate a refresh */
1586 IShellView3_Refresh(&This->IShellView3_iface);
1587 break;
1589 case VK_BACK:
1591 LPSHELLBROWSER lpSb;
1592 if((lpSb = (LPSHELLBROWSER)SendMessageW(This->hWndParent, CWM_GETISHELLBROWSER, 0, 0)))
1594 IShellBrowser_BrowseObject(lpSb, NULL, SBSP_PARENT);
1597 break;
1599 default:
1600 FIXME("LVN_KEYDOWN key=0x%08x\n", plvKeyDown->wVKey);
1603 break;
1605 default:
1606 TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code);
1607 break;
1609 return 0;
1612 /**********************************************************
1613 * ShellView_OnChange()
1616 static LRESULT ShellView_OnChange(IShellViewImpl * This, const LPCITEMIDLIST *pidls, LONG event)
1618 LPCITEMIDLIST pidl;
1619 BOOL ret = TRUE;
1621 TRACE("(%p)->(%p, %p, 0x%08x)\n", This, pidls[0], pidls[1], event);
1623 switch (event)
1625 case SHCNE_MKDIR:
1626 case SHCNE_CREATE:
1627 pidl = ILClone(ILFindLastID(pidls[0]));
1628 shellview_add_item(This, pidl);
1629 break;
1630 case SHCNE_RMDIR:
1631 case SHCNE_DELETE:
1633 INT i = LV_FindItemByPidl(This, ILFindLastID(pidls[0]));
1634 ret = SendMessageW(This->hWndList, LVM_DELETEITEM, i, 0);
1635 break;
1637 case SHCNE_RENAMEFOLDER:
1638 case SHCNE_RENAMEITEM:
1639 LV_RenameItem(This, pidls[0], pidls[1]);
1640 break;
1641 case SHCNE_UPDATEITEM:
1642 break;
1644 return ret;
1646 /**********************************************************
1647 * ShellView_WndProc
1650 static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1652 IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
1653 LPCREATESTRUCTW lpcs;
1655 TRACE("(hwnd=%p msg=%x wparm=%lx lparm=%lx)\n",hWnd, uMessage, wParam, lParam);
1657 switch (uMessage)
1659 case WM_NCCREATE:
1660 lpcs = (LPCREATESTRUCTW)lParam;
1661 pThis = lpcs->lpCreateParams;
1662 SetWindowLongPtrW(hWnd, GWLP_USERDATA, (ULONG_PTR)pThis);
1663 pThis->hWnd = hWnd; /*set the window handle*/
1664 break;
1666 case WM_SIZE: return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam));
1667 case WM_SETFOCUS: return ShellView_OnSetFocus(pThis);
1668 case WM_KILLFOCUS: return ShellView_OnKillFocus(pThis);
1669 case WM_CREATE: return ShellView_OnCreate(pThis);
1670 case WM_ACTIVATE: return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS);
1671 case WM_NOTIFY: return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam);
1672 case WM_COMMAND: return ShellView_OnCommand(pThis,
1673 GET_WM_COMMAND_ID(wParam, lParam),
1674 GET_WM_COMMAND_CMD(wParam, lParam),
1675 GET_WM_COMMAND_HWND(wParam, lParam));
1676 case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (const LPCITEMIDLIST*)wParam, (LONG)lParam);
1678 case WM_CONTEXTMENU: ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE);
1679 return 0;
1681 case WM_SHOWWINDOW: UpdateWindow(pThis->hWndList);
1682 break;
1684 case WM_GETDLGCODE: return SendMessageW(pThis->hWndList, uMessage, 0, 0);
1685 case WM_SETFONT: return SendMessageW(pThis->hWndList, WM_SETFONT, wParam, lParam);
1686 case WM_GETFONT: return SendMessageW(pThis->hWndList, WM_GETFONT, wParam, lParam);
1688 case WM_DESTROY:
1689 RevokeDragDrop(pThis->hWnd);
1690 SHChangeNotifyDeregister(pThis->hNotify);
1691 break;
1693 case WM_ERASEBKGND:
1694 if ((pThis->FolderSettings.fFlags & FWF_DESKTOP) ||
1695 (pThis->FolderSettings.fFlags & FWF_TRANSPARENT))
1696 return 1;
1697 break;
1700 return DefWindowProcW(hWnd, uMessage, wParam, lParam);
1702 /**********************************************************
1705 * The INTERFACE of the IShellView object
1708 **********************************************************
1709 * IShellView_QueryInterface
1711 static HRESULT WINAPI IShellView_fnQueryInterface(IShellView3 *iface, REFIID riid, void **ppvObj)
1713 IShellViewImpl *This = impl_from_IShellView3(iface);
1715 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObj);
1717 *ppvObj = NULL;
1719 if(IsEqualIID(riid, &IID_IUnknown) ||
1720 IsEqualIID(riid, &IID_IShellView) ||
1721 IsEqualIID(riid, &IID_IShellView2) ||
1722 IsEqualIID(riid, &IID_IShellView3) ||
1723 IsEqualIID(riid, &IID_CDefView))
1725 *ppvObj = &This->IShellView3_iface;
1727 else if(IsEqualIID(riid, &IID_IShellFolderView))
1729 *ppvObj = &This->IShellFolderView_iface;
1731 else if(IsEqualIID(riid, &IID_IFolderView) ||
1732 IsEqualIID(riid, &IID_IFolderView2))
1734 *ppvObj = &This->IFolderView2_iface;
1736 else if(IsEqualIID(riid, &IID_IOleCommandTarget))
1738 *ppvObj = &This->IOleCommandTarget_iface;
1740 else if(IsEqualIID(riid, &IID_IDropTarget))
1742 *ppvObj = &This->IDropTarget_iface;
1744 else if(IsEqualIID(riid, &IID_IDropSource))
1746 *ppvObj = &This->IDropSource_iface;
1748 else if(IsEqualIID(riid, &IID_IViewObject))
1750 *ppvObj = &This->IViewObject_iface;
1753 if(*ppvObj)
1755 IUnknown_AddRef( (IUnknown*)*ppvObj );
1756 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1757 return S_OK;
1759 TRACE("-- Interface: E_NOINTERFACE\n");
1760 return E_NOINTERFACE;
1763 /**********************************************************
1764 * IShellView_AddRef
1766 static ULONG WINAPI IShellView_fnAddRef(IShellView3 *iface)
1768 IShellViewImpl *This = impl_from_IShellView3(iface);
1769 ULONG refCount = InterlockedIncrement(&This->ref);
1771 TRACE("(%p)->(count=%u)\n", This, refCount - 1);
1773 return refCount;
1775 /**********************************************************
1776 * IShellView_Release
1778 static ULONG WINAPI IShellView_fnRelease(IShellView3 *iface)
1780 IShellViewImpl *This = impl_from_IShellView3(iface);
1781 ULONG refCount = InterlockedDecrement(&This->ref);
1783 TRACE("(%p)->(count=%i)\n", This, refCount + 1);
1785 if (!refCount)
1787 TRACE(" destroying IShellView(%p)\n",This);
1789 DestroyWindow(This->hWndList);
1791 if(This->pSFParent)
1792 IShellFolder_Release(This->pSFParent);
1794 if(This->pSF2Parent)
1795 IShellFolder2_Release(This->pSF2Parent);
1797 SHFree(This->apidl);
1799 if(This->pAdvSink)
1800 IAdviseSink_Release(This->pAdvSink);
1802 heap_free(This);
1804 return refCount;
1807 /**********************************************************
1808 * ShellView_GetWindow
1810 static HRESULT WINAPI IShellView_fnGetWindow(IShellView3 *iface, HWND *phWnd)
1812 IShellViewImpl *This = impl_from_IShellView3(iface);
1814 TRACE("(%p)\n", This);
1816 *phWnd = This->hWnd;
1817 return S_OK;
1820 static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView3 *iface, BOOL mode)
1822 IShellViewImpl *This = impl_from_IShellView3(iface);
1823 TRACE("(%p)->(%d)\n", This, mode);
1824 return E_NOTIMPL;
1827 /**********************************************************
1828 * IShellView_TranslateAccelerator
1830 * FIXME:
1831 * use the accel functions
1833 static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView3 *iface, MSG *lpmsg)
1835 #if 0
1836 IShellViewImpl *This = (IShellViewImpl *)iface;
1838 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%x wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1839 #endif
1841 if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST))
1843 TRACE("-- key=0x04%lx\n",lpmsg->wParam) ;
1845 return S_FALSE; /* not handled */
1848 static HRESULT WINAPI IShellView_fnEnableModeless(IShellView3 *iface, BOOL fEnable)
1850 IShellViewImpl *This = impl_from_IShellView3(iface);
1852 FIXME("(%p) stub\n", This);
1854 return E_NOTIMPL;
1857 static HRESULT WINAPI IShellView_fnUIActivate(IShellView3 *iface, UINT uState)
1859 IShellViewImpl *This = impl_from_IShellView3(iface);
1862 CHAR szName[MAX_PATH];
1864 LRESULT lResult;
1865 int nPartArray[1] = {-1};
1867 TRACE("%p, %d.\n", This, uState);
1869 /*don't do anything if the state isn't really changing*/
1870 if(This->uState == uState)
1872 return S_OK;
1875 /*OnActivate handles the menu merging and internal state*/
1876 ShellView_OnActivate(This, uState);
1878 /*only do This if we are active*/
1879 if(uState != SVUIA_DEACTIVATE)
1883 GetFolderPath is not a method of IShellFolder
1884 IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1886 /* set the number of parts */
1887 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1888 (LPARAM)nPartArray, &lResult);
1890 /* set the text for the parts */
1892 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1893 0, (LPARAM)szName, &lResult);
1897 return S_OK;
1900 static HRESULT WINAPI IShellView_fnRefresh(IShellView3 *iface)
1902 IShellViewImpl *This = impl_from_IShellView3(iface);
1904 TRACE("(%p)\n", This);
1906 SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0);
1907 ShellView_FillList(This);
1909 return S_OK;
1912 static HRESULT WINAPI IShellView_fnCreateViewWindow(IShellView3 *iface, IShellView *prev_view,
1913 const FOLDERSETTINGS *settings, IShellBrowser *owner, RECT *rect, HWND *hWnd)
1915 IShellViewImpl *This = impl_from_IShellView3(iface);
1916 TRACE("(%p)->(%p %p %p %p %p)\n", This, prev_view, settings, owner, rect, hWnd);
1917 return IShellView3_CreateViewWindow3(iface, owner, prev_view, SV3CVW3_DEFAULT,
1918 settings->fFlags, settings->fFlags, settings->ViewMode, NULL, rect, hWnd);
1921 static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView3 *iface)
1923 IShellViewImpl *This = impl_from_IShellView3(iface);
1925 TRACE("(%p)\n", This);
1927 if (!This->hWnd)
1928 return S_OK;
1930 /* Make absolutely sure all our UI is cleaned up. */
1931 IShellView3_UIActivate(iface, SVUIA_DEACTIVATE);
1933 if (This->hMenu)
1934 DestroyMenu(This->hMenu);
1936 DestroyWindow(This->hWnd);
1937 if (This->pShellBrowser) IShellBrowser_Release(This->pShellBrowser);
1938 if (This->pCommDlgBrowser) ICommDlgBrowser_Release(This->pCommDlgBrowser);
1940 This->hMenu = NULL;
1941 This->hWnd = NULL;
1942 This->pShellBrowser = NULL;
1943 This->pCommDlgBrowser = NULL;
1945 return S_OK;
1948 static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView3 *iface, LPFOLDERSETTINGS lpfs)
1950 IShellViewImpl *This = impl_from_IShellView3(iface);
1952 TRACE("(%p)->(%p) vmode=%x flags=%x\n", This, lpfs,
1953 This->FolderSettings.ViewMode, This->FolderSettings.fFlags);
1955 if (!lpfs) return E_INVALIDARG;
1956 *lpfs = This->FolderSettings;
1957 return S_OK;
1960 static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView3 *iface, DWORD dwReserved,
1961 LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
1963 IShellViewImpl *This = impl_from_IShellView3(iface);
1964 FIXME("(%p) stub\n", This);
1965 return E_NOTIMPL;
1968 static HRESULT WINAPI IShellView_fnSaveViewState(IShellView3 *iface)
1970 IShellViewImpl *This = impl_from_IShellView3(iface);
1971 FIXME("(%p) stub\n", This);
1972 return S_OK;
1975 static HRESULT WINAPI IShellView_fnSelectItem(IShellView3 *iface, LPCITEMIDLIST pidl, UINT flags)
1977 IShellViewImpl *This = impl_from_IShellView3(iface);
1978 int i;
1980 TRACE("(%p)->(pidl=%p, 0x%08x)\n",This, pidl, flags);
1982 i = LV_FindItemByPidl(This, pidl);
1983 if (i == -1) return S_OK;
1985 return IFolderView2_SelectItem(&This->IFolderView2_iface, i, flags);
1988 static HRESULT WINAPI IShellView_fnGetItemObject(IShellView3 *iface, UINT uItem, REFIID riid,
1989 void **ppvOut)
1991 IShellViewImpl *This = impl_from_IShellView3(iface);
1992 HRESULT hr = E_NOINTERFACE;
1994 TRACE("(%p)->(0x%08x, %s, %p)\n",This, uItem, debugstr_guid(riid), ppvOut);
1996 *ppvOut = NULL;
1998 switch(uItem)
2000 case SVGIO_BACKGROUND:
2002 if (IsEqualIID(&IID_IContextMenu, riid))
2003 return BackgroundMenu_Constructor(This->pSFParent, FALSE, riid, ppvOut);
2004 else if (IsEqualIID(&IID_IDispatch, riid)) {
2005 *ppvOut = &This->IShellFolderViewDual3_iface;
2006 IShellFolderViewDual3_AddRef(&This->IShellFolderViewDual3_iface);
2007 return S_OK;
2009 else
2010 FIXME("unsupported interface requested %s\n", debugstr_guid(riid));
2012 break;
2014 case SVGIO_SELECTION:
2015 ShellView_GetSelections(This);
2016 hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, riid, 0, ppvOut);
2017 break;
2019 default:
2020 FIXME("unimplemented for uItem = 0x%08x\n", uItem);
2022 TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
2024 return hr;
2027 static HRESULT WINAPI IShellView2_fnGetView(IShellView3 *iface, SHELLVIEWID *view_guid, ULONG view_type)
2029 FIXME("(%p)->(%s, %#x) stub!\n", iface, debugstr_guid(view_guid), view_type);
2030 return E_NOTIMPL;
2033 static HRESULT WINAPI IShellView2_fnCreateViewWindow2(IShellView3 *iface, SV2CVW2_PARAMS *view_params)
2035 IShellViewImpl *This = impl_from_IShellView3(iface);
2036 TRACE("(%p)->(%p)\n", This, view_params);
2037 return IShellView3_CreateViewWindow3(iface, view_params->psbOwner, view_params->psvPrev,
2038 SV3CVW3_DEFAULT, view_params->pfs->fFlags, view_params->pfs->fFlags,
2039 view_params->pfs->ViewMode, view_params->pvid, view_params->prcView, &view_params->hwndView);
2042 static HRESULT WINAPI IShellView2_fnHandleRename(IShellView3 *iface, LPCITEMIDLIST new_pidl)
2044 FIXME("(%p)->(new_pidl %p) stub!\n", iface, new_pidl);
2045 return E_NOTIMPL;
2048 static HRESULT WINAPI IShellView2_fnSelectAndPositionItem(IShellView3 *iface, LPCITEMIDLIST item,
2049 UINT flags, POINT *point)
2051 IShellViewImpl *This = impl_from_IShellView3(iface);
2052 TRACE("(%p)->(item %p, flags %#x, point %p)\n", This, item, flags, point);
2053 return IFolderView2_SelectAndPositionItems(&This->IFolderView2_iface, 1, &item, point, flags);
2056 static HRESULT WINAPI IShellView3_fnCreateViewWindow3(IShellView3 *iface, IShellBrowser *owner,
2057 IShellView *prev_view, SV3CVW3_FLAGS view_flags, FOLDERFLAGS mask, FOLDERFLAGS flags,
2058 FOLDERVIEWMODE mode, const SHELLVIEWID *view_id, const RECT *rect, HWND *hwnd)
2060 IShellViewImpl *This = impl_from_IShellView3(iface);
2061 INITCOMMONCONTROLSEX icex;
2062 WNDCLASSW wc;
2063 HRESULT hr;
2064 HWND wnd;
2066 TRACE("(%p)->(%p %p 0x%08x 0x%08x 0x%08x %d %s %s %p)\n", This, owner, prev_view, view_flags,
2067 mask, flags, mode, debugstr_guid(view_id), wine_dbgstr_rect(rect), hwnd);
2069 icex.dwSize = sizeof(icex);
2070 icex.dwICC = ICC_LISTVIEW_CLASSES;
2071 InitCommonControlsEx(&icex);
2073 *hwnd = NULL;
2075 if (!owner || This->hWnd)
2076 return E_UNEXPECTED;
2078 if (view_flags != SV3CVW3_DEFAULT)
2079 FIXME("unsupported view flags 0x%08x\n", view_flags);
2081 /* Set up the member variables */
2082 This->pShellBrowser = owner;
2083 This->FolderSettings.ViewMode = mode;
2084 This->FolderSettings.fFlags = mask & flags;
2086 if (view_id)
2088 if (IsEqualGUID(view_id, &VID_LargeIcons))
2089 This->FolderSettings.ViewMode = FVM_ICON;
2090 else if (IsEqualGUID(view_id, &VID_SmallIcons))
2091 This->FolderSettings.ViewMode = FVM_SMALLICON;
2092 else if (IsEqualGUID(view_id, &VID_List))
2093 This->FolderSettings.ViewMode = FVM_LIST;
2094 else if (IsEqualGUID(view_id, &VID_Details))
2095 This->FolderSettings.ViewMode = FVM_DETAILS;
2096 else if (IsEqualGUID(view_id, &VID_Thumbnails))
2097 This->FolderSettings.ViewMode = FVM_THUMBNAIL;
2098 else if (IsEqualGUID(view_id, &VID_Tile))
2099 This->FolderSettings.ViewMode = FVM_TILE;
2100 else if (IsEqualGUID(view_id, &VID_ThumbStrip))
2101 This->FolderSettings.ViewMode = FVM_THUMBSTRIP;
2102 else
2103 FIXME("Ignoring unrecognized VID %s\n", debugstr_guid(view_id));
2106 /* Get our parent window */
2107 IShellBrowser_AddRef(This->pShellBrowser);
2108 IShellBrowser_GetWindow(This->pShellBrowser, &This->hWndParent);
2110 /* Try to get the ICommDlgBrowserInterface, adds a reference !!! */
2111 This->pCommDlgBrowser = NULL;
2112 hr = IShellBrowser_QueryInterface(This->pShellBrowser, &IID_ICommDlgBrowser, (void **)&This->pCommDlgBrowser);
2113 if (hr == S_OK)
2114 TRACE("-- CommDlgBrowser %p\n", This->pCommDlgBrowser);
2116 /* If our window class has not been registered, then do so */
2117 if (!GetClassInfoW(shell32_hInstance, SV_CLASS_NAME, &wc))
2119 wc.style = CS_HREDRAW | CS_VREDRAW;
2120 wc.lpfnWndProc = ShellView_WndProc;
2121 wc.cbClsExtra = 0;
2122 wc.cbWndExtra = 0;
2123 wc.hInstance = shell32_hInstance;
2124 wc.hIcon = 0;
2125 wc.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
2126 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2127 wc.lpszMenuName = NULL;
2128 wc.lpszClassName = SV_CLASS_NAME;
2130 if (!RegisterClassW(&wc)) return E_FAIL;
2133 wnd = CreateWindowExW(0, SV_CLASS_NAME, NULL, WS_CHILD | WS_TABSTOP,
2134 rect->left, rect->top,
2135 rect->right - rect->left,
2136 rect->bottom - rect->top,
2137 This->hWndParent, 0, shell32_hInstance, This);
2139 CheckToolbar(This);
2141 if (!wnd)
2143 IShellBrowser_Release(This->pShellBrowser);
2144 return E_FAIL;
2147 SetWindowPos(wnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
2148 UpdateWindow(wnd);
2150 *hwnd = wnd;
2152 return S_OK;
2155 static const IShellView3Vtbl shellviewvtbl =
2157 IShellView_fnQueryInterface,
2158 IShellView_fnAddRef,
2159 IShellView_fnRelease,
2160 IShellView_fnGetWindow,
2161 IShellView_fnContextSensitiveHelp,
2162 IShellView_fnTranslateAccelerator,
2163 IShellView_fnEnableModeless,
2164 IShellView_fnUIActivate,
2165 IShellView_fnRefresh,
2166 IShellView_fnCreateViewWindow,
2167 IShellView_fnDestroyViewWindow,
2168 IShellView_fnGetCurrentInfo,
2169 IShellView_fnAddPropertySheetPages,
2170 IShellView_fnSaveViewState,
2171 IShellView_fnSelectItem,
2172 IShellView_fnGetItemObject,
2173 IShellView2_fnGetView,
2174 IShellView2_fnCreateViewWindow2,
2175 IShellView2_fnHandleRename,
2176 IShellView2_fnSelectAndPositionItem,
2177 IShellView3_fnCreateViewWindow3
2181 /**********************************************************
2182 * ISVOleCmdTarget_QueryInterface (IUnknown)
2184 static HRESULT WINAPI ISVOleCmdTarget_QueryInterface(IOleCommandTarget *iface, REFIID iid, void **ppvObj)
2186 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2187 return IShellView3_QueryInterface(&This->IShellView3_iface, iid, ppvObj);
2190 /**********************************************************
2191 * ISVOleCmdTarget_AddRef (IUnknown)
2193 static ULONG WINAPI ISVOleCmdTarget_AddRef(IOleCommandTarget *iface)
2195 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2196 return IShellView3_AddRef(&This->IShellView3_iface);
2199 /**********************************************************
2200 * ISVOleCmdTarget_Release (IUnknown)
2202 static ULONG WINAPI ISVOleCmdTarget_Release(IOleCommandTarget *iface)
2204 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2205 return IShellView3_Release(&This->IShellView3_iface);
2208 /**********************************************************
2209 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
2211 static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
2212 IOleCommandTarget *iface,
2213 const GUID *pguidCmdGroup,
2214 ULONG cCmds,
2215 OLECMD *prgCmds,
2216 OLECMDTEXT *pCmdText)
2218 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2219 UINT i;
2221 FIXME("(%p)->(%s %d %p %p)\n",
2222 This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
2224 if (!prgCmds)
2225 return E_INVALIDARG;
2226 for (i = 0; i < cCmds; i++)
2228 FIXME("\tprgCmds[%d].cmdID = %d\n", i, prgCmds[i].cmdID);
2229 prgCmds[i].cmdf = 0;
2231 return OLECMDERR_E_UNKNOWNGROUP;
2234 /**********************************************************
2235 * ISVOleCmdTarget_Exec (IOleCommandTarget)
2237 * nCmdID is the OLECMDID_* enumeration
2239 static HRESULT WINAPI ISVOleCmdTarget_Exec(
2240 IOleCommandTarget *iface,
2241 const GUID* pguidCmdGroup,
2242 DWORD nCmdID,
2243 DWORD nCmdexecopt,
2244 VARIANT* pvaIn,
2245 VARIANT* pvaOut)
2247 IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2249 FIXME("(%p)->(%s %d 0x%08x %s %p)\n",
2250 This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, debugstr_variant(pvaIn), pvaOut);
2252 if (!pguidCmdGroup)
2253 return OLECMDERR_E_UNKNOWNGROUP;
2255 if (IsEqualIID(pguidCmdGroup, &CGID_Explorer) &&
2256 (nCmdID == OLECMDID_SHOWMESSAGE) &&
2257 (nCmdexecopt == 4) && pvaOut)
2258 return S_OK;
2259 if (IsEqualIID(pguidCmdGroup, &CGID_ShellDocView) &&
2260 (nCmdID == OLECMDID_SPELL) &&
2261 (nCmdexecopt == OLECMDEXECOPT_DODEFAULT))
2262 return S_FALSE;
2264 return OLECMDERR_E_UNKNOWNGROUP;
2267 static const IOleCommandTargetVtbl olecommandtargetvtbl =
2269 ISVOleCmdTarget_QueryInterface,
2270 ISVOleCmdTarget_AddRef,
2271 ISVOleCmdTarget_Release,
2272 ISVOleCmdTarget_QueryStatus,
2273 ISVOleCmdTarget_Exec
2276 /**********************************************************
2277 * ISVDropTarget implementation
2280 static HRESULT WINAPI ISVDropTarget_QueryInterface(IDropTarget *iface, REFIID riid, void **ppvObj)
2282 IShellViewImpl *This = impl_from_IDropTarget(iface);
2283 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
2286 static ULONG WINAPI ISVDropTarget_AddRef(IDropTarget *iface)
2288 IShellViewImpl *This = impl_from_IDropTarget(iface);
2289 return IShellView3_AddRef(&This->IShellView3_iface);
2292 static ULONG WINAPI ISVDropTarget_Release(IDropTarget *iface)
2294 IShellViewImpl *This = impl_from_IDropTarget(iface);
2295 return IShellView3_Release(&This->IShellView3_iface);
2298 /******************************************************************************
2299 * drag_notify_subitem [Internal]
2301 * Figure out the shellfolder object, which is currently under the mouse cursor
2302 * and notify it via the IDropTarget interface.
2305 #define SCROLLAREAWIDTH 20
2307 static HRESULT drag_notify_subitem(IShellViewImpl *This, DWORD grfKeyState, POINTL pt,
2308 DWORD *pdwEffect)
2310 LVHITTESTINFO htinfo;
2311 LVITEMW lvItem;
2312 LONG lResult;
2313 HRESULT hr;
2314 RECT clientRect;
2316 /* Map from global to client coordinates and query the index of the listview-item, which is
2317 * currently under the mouse cursor. */
2318 htinfo.pt.x = pt.x;
2319 htinfo.pt.y = pt.y;
2320 htinfo.flags = LVHT_ONITEM;
2321 ScreenToClient(This->hWndList, &htinfo.pt);
2322 lResult = SendMessageW(This->hWndList, LVM_HITTEST, 0, (LPARAM)&htinfo);
2324 /* Send WM_*SCROLL messages every 250 ms during drag-scrolling */
2325 GetClientRect(This->hWndList, &clientRect);
2326 if (htinfo.pt.x == This->ptLastMousePos.x && htinfo.pt.y == This->ptLastMousePos.y &&
2327 (htinfo.pt.x < SCROLLAREAWIDTH || htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH ||
2328 htinfo.pt.y < SCROLLAREAWIDTH || htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH ))
2330 This->cScrollDelay = (This->cScrollDelay + 1) % 5; /* DragOver is called every 50 ms */
2331 if (This->cScrollDelay == 0) { /* Mouse did hover another 250 ms over the scroll-area */
2332 if (htinfo.pt.x < SCROLLAREAWIDTH)
2333 SendMessageW(This->hWndList, WM_HSCROLL, SB_LINEUP, 0);
2334 if (htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH)
2335 SendMessageW(This->hWndList, WM_HSCROLL, SB_LINEDOWN, 0);
2336 if (htinfo.pt.y < SCROLLAREAWIDTH)
2337 SendMessageW(This->hWndList, WM_VSCROLL, SB_LINEUP, 0);
2338 if (htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH)
2339 SendMessageW(This->hWndList, WM_VSCROLL, SB_LINEDOWN, 0);
2341 } else {
2342 This->cScrollDelay = 0; /* Reset, if the cursor is not over the listview's scroll-area */
2344 This->ptLastMousePos = htinfo.pt;
2346 /* If we are still over the previous sub-item, notify it via DragOver and return. */
2347 if (This->pCurDropTarget && lResult == This->iDragOverItem)
2348 return IDropTarget_DragOver(This->pCurDropTarget, grfKeyState, pt, pdwEffect);
2350 /* We've left the previous sub-item, notify it via DragLeave and Release it. */
2351 if (This->pCurDropTarget) {
2352 IDropTarget_DragLeave(This->pCurDropTarget);
2353 IDropTarget_Release(This->pCurDropTarget);
2354 This->pCurDropTarget = NULL;
2357 This->iDragOverItem = lResult;
2358 if (lResult == -1) {
2359 /* We are not above one of the listview's subitems. Bind to the parent folder's
2360 * DropTarget interface. */
2361 hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IDropTarget,
2362 (LPVOID*)&This->pCurDropTarget);
2363 } else {
2364 /* Query the relative PIDL of the shellfolder object represented by the currently
2365 * dragged over listview-item ... */
2366 lvItem.mask = LVIF_PARAM;
2367 lvItem.iItem = lResult;
2368 lvItem.iSubItem = 0;
2369 SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
2371 /* ... and bind pCurDropTarget to the IDropTarget interface of an UIObject of this object */
2372 hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWndList, 1,
2373 (LPCITEMIDLIST*)&lvItem.lParam, &IID_IDropTarget, NULL, (LPVOID*)&This->pCurDropTarget);
2376 /* If anything failed, pCurDropTarget should be NULL now, which ought to be a save state. */
2377 if (FAILED(hr))
2378 return hr;
2380 /* Notify the item just entered via DragEnter. */
2381 return IDropTarget_DragEnter(This->pCurDropTarget, This->pCurDataObject, grfKeyState, pt, pdwEffect);
2384 static HRESULT WINAPI ISVDropTarget_DragEnter(IDropTarget *iface, IDataObject *pDataObject,
2385 DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2387 IShellViewImpl *This = impl_from_IDropTarget(iface);
2389 /* Get a hold on the data object for later calls to DragEnter on the sub-folders */
2390 This->pCurDataObject = pDataObject;
2391 IDataObject_AddRef(pDataObject);
2393 return drag_notify_subitem(This, grfKeyState, pt, pdwEffect);
2396 static HRESULT WINAPI ISVDropTarget_DragOver(IDropTarget *iface, DWORD grfKeyState, POINTL pt,
2397 DWORD *pdwEffect)
2399 IShellViewImpl *This = impl_from_IDropTarget(iface);
2400 return drag_notify_subitem(This, grfKeyState, pt, pdwEffect);
2403 static HRESULT WINAPI ISVDropTarget_DragLeave(IDropTarget *iface)
2405 IShellViewImpl *This = impl_from_IDropTarget(iface);
2407 if (This->pCurDropTarget)
2409 IDropTarget_DragLeave(This->pCurDropTarget);
2410 IDropTarget_Release(This->pCurDropTarget);
2411 This->pCurDropTarget = NULL;
2414 if (This->pCurDataObject)
2416 IDataObject_Release(This->pCurDataObject);
2417 This->pCurDataObject = NULL;
2420 This->iDragOverItem = 0;
2422 return S_OK;
2425 static HRESULT WINAPI ISVDropTarget_Drop(IDropTarget *iface, IDataObject* pDataObject,
2426 DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2428 IShellViewImpl *This = impl_from_IDropTarget(iface);
2430 if (!This->pCurDropTarget) return DRAGDROP_E_INVALIDHWND;
2432 IDropTarget_Drop(This->pCurDropTarget, pDataObject, grfKeyState, pt, pdwEffect);
2434 IDropTarget_Release(This->pCurDropTarget);
2435 IDataObject_Release(This->pCurDataObject);
2436 This->pCurDataObject = NULL;
2437 This->pCurDropTarget = NULL;
2438 This->iDragOverItem = 0;
2440 return S_OK;
2443 static const IDropTargetVtbl droptargetvtbl =
2445 ISVDropTarget_QueryInterface,
2446 ISVDropTarget_AddRef,
2447 ISVDropTarget_Release,
2448 ISVDropTarget_DragEnter,
2449 ISVDropTarget_DragOver,
2450 ISVDropTarget_DragLeave,
2451 ISVDropTarget_Drop
2454 /**********************************************************
2455 * ISVDropSource implementation
2458 static HRESULT WINAPI ISVDropSource_QueryInterface(IDropSource *iface, REFIID riid, void **ppvObj)
2460 IShellViewImpl *This = impl_from_IDropSource(iface);
2461 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
2464 static ULONG WINAPI ISVDropSource_AddRef(IDropSource *iface)
2466 IShellViewImpl *This = impl_from_IDropSource(iface);
2467 return IShellView3_AddRef(&This->IShellView3_iface);
2470 static ULONG WINAPI ISVDropSource_Release(IDropSource *iface)
2472 IShellViewImpl *This = impl_from_IDropSource(iface);
2473 return IShellView3_Release(&This->IShellView3_iface);
2476 static HRESULT WINAPI ISVDropSource_QueryContinueDrag(
2477 IDropSource *iface,
2478 BOOL fEscapePressed,
2479 DWORD grfKeyState)
2481 IShellViewImpl *This = impl_from_IDropSource(iface);
2482 TRACE("(%p)\n",This);
2484 if (fEscapePressed)
2485 return DRAGDROP_S_CANCEL;
2486 else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
2487 return DRAGDROP_S_DROP;
2488 else
2489 return S_OK;
2492 static HRESULT WINAPI ISVDropSource_GiveFeedback(
2493 IDropSource *iface,
2494 DWORD dwEffect)
2496 IShellViewImpl *This = impl_from_IDropSource(iface);
2497 TRACE("(%p)\n",This);
2499 return DRAGDROP_S_USEDEFAULTCURSORS;
2502 static const IDropSourceVtbl dropsourcevtbl =
2504 ISVDropSource_QueryInterface,
2505 ISVDropSource_AddRef,
2506 ISVDropSource_Release,
2507 ISVDropSource_QueryContinueDrag,
2508 ISVDropSource_GiveFeedback
2510 /**********************************************************
2511 * ISVViewObject implementation
2514 static HRESULT WINAPI ISVViewObject_QueryInterface(IViewObject *iface, REFIID riid, void **ppvObj)
2516 IShellViewImpl *This = impl_from_IViewObject(iface);
2517 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
2520 static ULONG WINAPI ISVViewObject_AddRef(IViewObject *iface)
2522 IShellViewImpl *This = impl_from_IViewObject(iface);
2523 return IShellView3_AddRef(&This->IShellView3_iface);
2526 static ULONG WINAPI ISVViewObject_Release(IViewObject *iface)
2528 IShellViewImpl *This = impl_from_IViewObject(iface);
2529 return IShellView3_Release(&This->IShellView3_iface);
2532 static HRESULT WINAPI ISVViewObject_Draw(
2533 IViewObject *iface,
2534 DWORD dwDrawAspect,
2535 LONG lindex,
2536 void* pvAspect,
2537 DVTARGETDEVICE* ptd,
2538 HDC hdcTargetDev,
2539 HDC hdcDraw,
2540 LPCRECTL lprcBounds,
2541 LPCRECTL lprcWBounds,
2542 BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue),
2543 ULONG_PTR dwContinue)
2546 IShellViewImpl *This = impl_from_IViewObject(iface);
2548 FIXME("Stub: This=%p\n",This);
2550 return E_NOTIMPL;
2552 static HRESULT WINAPI ISVViewObject_GetColorSet(
2553 IViewObject *iface,
2554 DWORD dwDrawAspect,
2555 LONG lindex,
2556 void *pvAspect,
2557 DVTARGETDEVICE* ptd,
2558 HDC hicTargetDevice,
2559 LOGPALETTE** ppColorSet)
2562 IShellViewImpl *This = impl_from_IViewObject(iface);
2564 FIXME("Stub: This=%p\n",This);
2566 return E_NOTIMPL;
2568 static HRESULT WINAPI ISVViewObject_Freeze(
2569 IViewObject *iface,
2570 DWORD dwDrawAspect,
2571 LONG lindex,
2572 void* pvAspect,
2573 DWORD* pdwFreeze)
2576 IShellViewImpl *This = impl_from_IViewObject(iface);
2578 FIXME("Stub: This=%p\n",This);
2580 return E_NOTIMPL;
2582 static HRESULT WINAPI ISVViewObject_Unfreeze(
2583 IViewObject *iface,
2584 DWORD dwFreeze)
2587 IShellViewImpl *This = impl_from_IViewObject(iface);
2589 FIXME("Stub: This=%p\n",This);
2591 return E_NOTIMPL;
2593 static HRESULT WINAPI ISVViewObject_SetAdvise(
2594 IViewObject *iface,
2595 DWORD aspects,
2596 DWORD advf,
2597 IAdviseSink* pAdvSink)
2600 IShellViewImpl *This = impl_from_IViewObject(iface);
2602 FIXME("partial stub: %p %08x %08x %p\n",
2603 This, aspects, advf, pAdvSink);
2605 /* FIXME: we set the AdviseSink, but never use it to send any advice */
2606 This->pAdvSink = pAdvSink;
2607 This->dwAspects = aspects;
2608 This->dwAdvf = advf;
2610 return S_OK;
2613 static HRESULT WINAPI ISVViewObject_GetAdvise(
2614 IViewObject *iface,
2615 DWORD* pAspects,
2616 DWORD* pAdvf,
2617 IAdviseSink** ppAdvSink)
2620 IShellViewImpl *This = impl_from_IViewObject(iface);
2622 TRACE("This=%p pAspects=%p pAdvf=%p ppAdvSink=%p\n",
2623 This, pAspects, pAdvf, ppAdvSink);
2625 if( ppAdvSink )
2627 IAdviseSink_AddRef( This->pAdvSink );
2628 *ppAdvSink = This->pAdvSink;
2630 if( pAspects )
2631 *pAspects = This->dwAspects;
2632 if( pAdvf )
2633 *pAdvf = This->dwAdvf;
2635 return S_OK;
2639 static const IViewObjectVtbl viewobjectvtbl =
2641 ISVViewObject_QueryInterface,
2642 ISVViewObject_AddRef,
2643 ISVViewObject_Release,
2644 ISVViewObject_Draw,
2645 ISVViewObject_GetColorSet,
2646 ISVViewObject_Freeze,
2647 ISVViewObject_Unfreeze,
2648 ISVViewObject_SetAdvise,
2649 ISVViewObject_GetAdvise
2652 /* IFolderView2 */
2653 static HRESULT WINAPI FolderView_QueryInterface(IFolderView2 *iface, REFIID riid, void **ppvObj)
2655 IShellViewImpl *This = impl_from_IFolderView2(iface);
2656 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
2659 static ULONG WINAPI FolderView_AddRef(IFolderView2 *iface)
2661 IShellViewImpl *This = impl_from_IFolderView2(iface);
2662 return IShellView3_AddRef(&This->IShellView3_iface);
2665 static ULONG WINAPI FolderView_Release(IFolderView2 *iface)
2667 IShellViewImpl *This = impl_from_IFolderView2(iface);
2668 return IShellView3_Release(&This->IShellView3_iface);
2671 static HRESULT WINAPI FolderView_GetCurrentViewMode(IFolderView2 *iface, UINT *mode)
2673 IShellViewImpl *This = impl_from_IFolderView2(iface);
2674 TRACE("%p, %p.\n", This, mode);
2676 if(!mode)
2677 return E_INVALIDARG;
2679 *mode = This->FolderSettings.ViewMode;
2680 return S_OK;
2683 static HRESULT WINAPI FolderView_SetCurrentViewMode(IFolderView2 *iface, UINT mode)
2685 IShellViewImpl *This = impl_from_IFolderView2(iface);
2686 DWORD dwStyle;
2688 TRACE("%p, %u.\n", This, mode);
2690 if((mode < FVM_FIRST || mode > FVM_LAST) &&
2691 (mode != FVM_AUTO))
2692 return E_INVALIDARG;
2694 /* Windows before Vista uses LVM_SETVIEW and possibly
2695 LVM_SETEXTENDEDLISTVIEWSTYLE to set the style of the listview,
2696 while later versions seem to accomplish this through other
2697 means. */
2698 dwStyle = ViewModeToListStyle(mode);
2699 SetStyle(This, dwStyle, LVS_TYPEMASK);
2701 /* This will not necessarily be the actual mode set above.
2702 This mimics the behavior of Windows XP. */
2703 This->FolderSettings.ViewMode = mode;
2705 return S_OK;
2708 static HRESULT WINAPI FolderView_GetFolder(IFolderView2 *iface, REFIID riid, void **ppv)
2710 IShellViewImpl *This = impl_from_IFolderView2(iface);
2712 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
2714 return IShellFolder_QueryInterface(This->pSFParent, riid, ppv);
2717 static HRESULT WINAPI FolderView_Item(IFolderView2 *iface, int index, PITEMID_CHILD *ppidl)
2719 IShellViewImpl *This = impl_from_IFolderView2(iface);
2720 LVITEMW item;
2722 TRACE("(%p)->(%d %p)\n", This, index, ppidl);
2724 item.mask = LVIF_PARAM;
2725 item.iItem = index;
2727 if (SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM)&item))
2729 *ppidl = ILClone((PITEMID_CHILD)item.lParam);
2730 return S_OK;
2732 else
2734 *ppidl = 0;
2735 return E_INVALIDARG;
2739 static HRESULT WINAPI FolderView_ItemCount(IFolderView2 *iface, UINT flags, int *items)
2741 IShellViewImpl *This = impl_from_IFolderView2(iface);
2743 TRACE("(%p)->(%u %p)\n", This, flags, items);
2745 if (flags != SVGIO_ALLVIEW)
2746 FIXME("some flags unsupported, %x\n", flags & ~SVGIO_ALLVIEW);
2748 *items = SendMessageW(This->hWndList, LVM_GETITEMCOUNT, 0, 0);
2750 return S_OK;
2753 static HRESULT WINAPI FolderView_Items(IFolderView2 *iface, UINT flags, REFIID riid, void **ppv)
2755 IShellViewImpl *This = impl_from_IFolderView2(iface);
2756 FIXME("(%p)->(%u %s %p), stub\n", This, flags, debugstr_guid(riid), ppv);
2757 return E_NOTIMPL;
2760 static HRESULT WINAPI FolderView_GetSelectionMarkedItem(IFolderView2 *iface, int *item)
2762 IShellViewImpl *This = impl_from_IFolderView2(iface);
2764 TRACE("(%p)->(%p)\n", This, item);
2766 *item = SendMessageW(This->hWndList, LVM_GETSELECTIONMARK, 0, 0);
2768 return S_OK;
2771 static HRESULT WINAPI FolderView_GetFocusedItem(IFolderView2 *iface, int *item)
2773 IShellViewImpl *This = impl_from_IFolderView2(iface);
2775 TRACE("(%p)->(%p)\n", This, item);
2777 *item = SendMessageW(This->hWndList, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
2779 return S_OK;
2782 static HRESULT WINAPI FolderView_GetItemPosition(IFolderView2 *iface, PCUITEMID_CHILD pidl, POINT *ppt)
2784 IShellViewImpl *This = impl_from_IFolderView2(iface);
2785 FIXME("(%p)->(%p %p), stub\n", This, pidl, ppt);
2786 return E_NOTIMPL;
2789 static HRESULT WINAPI FolderView_GetSpacing(IFolderView2 *iface, POINT *pt)
2791 IShellViewImpl *This = impl_from_IFolderView2(iface);
2793 TRACE("(%p)->(%p)\n", This, pt);
2795 if (!This->hWndList) return S_FALSE;
2797 if (pt)
2799 DWORD ret;
2800 ret = SendMessageW(This->hWndList, LVM_GETITEMSPACING, 0, 0);
2802 pt->x = LOWORD(ret);
2803 pt->y = HIWORD(ret);
2806 return S_OK;
2809 static HRESULT WINAPI FolderView_GetDefaultSpacing(IFolderView2 *iface, POINT *pt)
2811 IShellViewImpl *This = impl_from_IFolderView2(iface);
2812 FIXME("(%p)->(%p), stub\n", This, pt);
2813 return E_NOTIMPL;
2816 static HRESULT WINAPI FolderView_GetAutoArrange(IFolderView2 *iface)
2818 IShellViewImpl *This = impl_from_IFolderView2(iface);
2819 FIXME("(%p), stub\n", This);
2820 return E_NOTIMPL;
2823 static HRESULT WINAPI FolderView_SelectItem(IFolderView2 *iface, int item, DWORD flags)
2825 IShellViewImpl *This = impl_from_IFolderView2(iface);
2826 LVITEMW lvItem;
2828 TRACE("(%p)->(%d, %x)\n", This, item, flags);
2830 lvItem.state = 0;
2831 lvItem.stateMask = LVIS_SELECTED;
2833 if (flags & SVSI_ENSUREVISIBLE)
2834 SendMessageW(This->hWndList, LVM_ENSUREVISIBLE, item, 0);
2836 /* all items */
2837 if (flags & SVSI_DESELECTOTHERS)
2838 SendMessageW(This->hWndList, LVM_SETITEMSTATE, -1, (LPARAM)&lvItem);
2840 /* this item */
2841 if (flags & SVSI_SELECT)
2842 lvItem.state |= LVIS_SELECTED;
2844 if (flags & SVSI_FOCUSED)
2845 lvItem.stateMask |= LVIS_FOCUSED;
2847 SendMessageW(This->hWndList, LVM_SETITEMSTATE, item, (LPARAM)&lvItem);
2849 if (flags & SVSI_EDIT)
2850 SendMessageW(This->hWndList, LVM_EDITLABELW, item, 0);
2852 return S_OK;
2855 static HRESULT WINAPI FolderView_SelectAndPositionItems(IFolderView2 *iface, UINT cidl,
2856 PCUITEMID_CHILD_ARRAY apidl, POINT *apt, DWORD flags)
2858 IShellViewImpl *This = impl_from_IFolderView2(iface);
2859 FIXME("(%p)->(%u %p %p %x), stub\n", This, cidl, apidl, apt, flags);
2860 return E_NOTIMPL;
2863 static HRESULT WINAPI FolderView2_SetGroupBy(IFolderView2 *iface, REFPROPERTYKEY key, BOOL ascending)
2865 IShellViewImpl *This = impl_from_IFolderView2(iface);
2866 FIXME("(%p)->(%p %d), stub\n", This, key, ascending);
2867 return E_NOTIMPL;
2870 static HRESULT WINAPI FolderView2_GetGroupBy(IFolderView2 *iface, PROPERTYKEY *pkey, BOOL *ascending)
2872 IShellViewImpl *This = impl_from_IFolderView2(iface);
2873 FIXME("(%p)->(%p %p), stub\n", This, pkey, ascending);
2874 return E_NOTIMPL;
2877 static HRESULT WINAPI FolderView2_SetViewProperty(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2878 REFPROPERTYKEY propkey, REFPROPVARIANT propvar)
2880 IShellViewImpl *This = impl_from_IFolderView2(iface);
2881 FIXME("(%p)->(%p %p %p), stub\n", This, pidl, propkey, propvar);
2882 return E_NOTIMPL;
2885 static HRESULT WINAPI FolderView2_GetViewProperty(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2886 REFPROPERTYKEY propkey, PROPVARIANT *propvar)
2888 IShellViewImpl *This = impl_from_IFolderView2(iface);
2889 FIXME("(%p)->(%p %p %p), stub\n", This, pidl, propkey, propvar);
2890 return E_NOTIMPL;
2893 static HRESULT WINAPI FolderView2_SetTileViewProperties(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2894 LPCWSTR prop_list)
2896 IShellViewImpl *This = impl_from_IFolderView2(iface);
2897 FIXME("(%p)->(%p %s), stub\n", This, pidl, debugstr_w(prop_list));
2898 return E_NOTIMPL;
2901 static HRESULT WINAPI FolderView2_SetExtendedTileViewProperties(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2902 LPCWSTR prop_list)
2904 IShellViewImpl *This = impl_from_IFolderView2(iface);
2905 FIXME("(%p)->(%p %s), stub\n", This, pidl, debugstr_w(prop_list));
2906 return E_NOTIMPL;
2909 static HRESULT WINAPI FolderView2_SetText(IFolderView2 *iface, FVTEXTTYPE type, LPCWSTR text)
2911 IShellViewImpl *This = impl_from_IFolderView2(iface);
2912 FIXME("(%p)->(%d %s), stub\n", This, type, debugstr_w(text));
2913 return E_NOTIMPL;
2916 static HRESULT WINAPI FolderView2_SetCurrentFolderFlags(IFolderView2 *iface, DWORD mask, DWORD flags)
2918 IShellViewImpl *This = impl_from_IFolderView2(iface);
2919 FIXME("(%p)->(0x%08x 0x%08x), stub\n", This, mask, flags);
2920 return E_NOTIMPL;
2923 static HRESULT WINAPI FolderView2_GetCurrentFolderFlags(IFolderView2 *iface, DWORD *flags)
2925 IShellViewImpl *This = impl_from_IFolderView2(iface);
2926 FIXME("(%p)->(%p), stub\n", This, flags);
2927 return E_NOTIMPL;
2930 static HRESULT WINAPI FolderView2_GetSortColumnCount(IFolderView2 *iface, int *columns)
2932 IShellViewImpl *This = impl_from_IFolderView2(iface);
2933 FIXME("(%p)->(%p), stub\n", This, columns);
2934 return E_NOTIMPL;
2937 static HRESULT WINAPI FolderView2_SetSortColumns(IFolderView2 *iface, const SORTCOLUMN *columns,
2938 int count)
2940 IShellViewImpl *This = impl_from_IFolderView2(iface);
2941 FIXME("(%p)->(%p %d), stub\n", This, columns, count);
2942 return E_NOTIMPL;
2945 static HRESULT WINAPI FolderView2_GetSortColumns(IFolderView2 *iface, SORTCOLUMN *columns,
2946 int count)
2948 IShellViewImpl *This = impl_from_IFolderView2(iface);
2949 FIXME("(%p)->(%p %d), stub\n", This, columns, count);
2950 return E_NOTIMPL;
2953 static HRESULT WINAPI FolderView2_GetItem(IFolderView2 *iface, int item, REFIID riid, void **ppv)
2955 IShellViewImpl *This = impl_from_IFolderView2(iface);
2956 FIXME("(%p)->(%d %s %p), stub\n", This, item, debugstr_guid(riid), ppv);
2957 return E_NOTIMPL;
2960 static HRESULT WINAPI FolderView2_GetVisibleItem(IFolderView2 *iface, int start, BOOL previous,
2961 int *item)
2963 IShellViewImpl *This = impl_from_IFolderView2(iface);
2964 FIXME("(%p)->(%d %d %p), stub\n", This, start, previous, item);
2965 return E_NOTIMPL;
2968 static HRESULT WINAPI FolderView2_GetSelectedItem(IFolderView2 *iface, int start, int *item)
2970 IShellViewImpl *This = impl_from_IFolderView2(iface);
2971 FIXME("(%p)->(%d %p), stub\n", This, start, item);
2972 return E_NOTIMPL;
2975 static HRESULT WINAPI FolderView2_GetSelection(IFolderView2 *iface, BOOL none_implies_folder,
2976 IShellItemArray **array)
2978 IShellViewImpl *This = impl_from_IFolderView2(iface);
2979 FIXME("(%p)->(%d %p), stub\n", This, none_implies_folder, array);
2980 return E_NOTIMPL;
2983 static HRESULT WINAPI FolderView2_GetSelectionState(IFolderView2 *iface, PCUITEMID_CHILD pidl,
2984 DWORD *flags)
2986 IShellViewImpl *This = impl_from_IFolderView2(iface);
2987 FIXME("(%p)->(%p %p), stub\n", This, pidl, flags);
2988 return E_NOTIMPL;
2991 static HRESULT WINAPI FolderView2_InvokeVerbOnSelection(IFolderView2 *iface, LPCSTR verb)
2993 IShellViewImpl *This = impl_from_IFolderView2(iface);
2994 FIXME("(%p)->(%s), stub\n", This, debugstr_a(verb));
2995 return E_NOTIMPL;
2998 static HRESULT WINAPI FolderView2_SetViewModeAndIconSize(IFolderView2 *iface, FOLDERVIEWMODE mode,
2999 int size)
3001 IShellViewImpl *This = impl_from_IFolderView2(iface);
3002 FIXME("(%p)->(%d %d), stub\n", This, mode, size);
3003 return E_NOTIMPL;
3006 static HRESULT WINAPI FolderView2_GetViewModeAndIconSize(IFolderView2 *iface, FOLDERVIEWMODE *mode,
3007 int *size)
3009 IShellViewImpl *This = impl_from_IFolderView2(iface);
3010 FIXME("(%p)->(%p %p), stub\n", This, mode, size);
3011 return E_NOTIMPL;
3014 static HRESULT WINAPI FolderView2_SetGroupSubsetCount(IFolderView2 *iface, UINT visible_rows)
3016 IShellViewImpl *This = impl_from_IFolderView2(iface);
3017 FIXME("(%p)->(%u), stub\n", This, visible_rows);
3018 return E_NOTIMPL;
3021 static HRESULT WINAPI FolderView2_GetGroupSubsetCount(IFolderView2 *iface, UINT *visible_rows)
3023 IShellViewImpl *This = impl_from_IFolderView2(iface);
3024 FIXME("(%p)->(%p), stub\n", This, visible_rows);
3025 return E_NOTIMPL;
3028 static HRESULT WINAPI FolderView2_SetRedraw(IFolderView2 *iface, BOOL redraw)
3030 IShellViewImpl *This = impl_from_IFolderView2(iface);
3031 TRACE("(%p)->(%d)\n", This, redraw);
3032 SendMessageW(This->hWndList, WM_SETREDRAW, redraw, 0);
3033 return S_OK;
3036 static HRESULT WINAPI FolderView2_IsMoveInSameFolder(IFolderView2 *iface)
3038 IShellViewImpl *This = impl_from_IFolderView2(iface);
3039 FIXME("(%p), stub\n", This);
3040 return E_NOTIMPL;
3043 static HRESULT WINAPI FolderView2_DoRename(IFolderView2 *iface)
3045 IShellViewImpl *This = impl_from_IFolderView2(iface);
3046 FIXME("(%p), stub\n", This);
3047 return E_NOTIMPL;
3050 static const IFolderView2Vtbl folderviewvtbl =
3052 FolderView_QueryInterface,
3053 FolderView_AddRef,
3054 FolderView_Release,
3055 FolderView_GetCurrentViewMode,
3056 FolderView_SetCurrentViewMode,
3057 FolderView_GetFolder,
3058 FolderView_Item,
3059 FolderView_ItemCount,
3060 FolderView_Items,
3061 FolderView_GetSelectionMarkedItem,
3062 FolderView_GetFocusedItem,
3063 FolderView_GetItemPosition,
3064 FolderView_GetSpacing,
3065 FolderView_GetDefaultSpacing,
3066 FolderView_GetAutoArrange,
3067 FolderView_SelectItem,
3068 FolderView_SelectAndPositionItems,
3069 FolderView2_SetGroupBy,
3070 FolderView2_GetGroupBy,
3071 FolderView2_SetViewProperty,
3072 FolderView2_GetViewProperty,
3073 FolderView2_SetTileViewProperties,
3074 FolderView2_SetExtendedTileViewProperties,
3075 FolderView2_SetText,
3076 FolderView2_SetCurrentFolderFlags,
3077 FolderView2_GetCurrentFolderFlags,
3078 FolderView2_GetSortColumnCount,
3079 FolderView2_SetSortColumns,
3080 FolderView2_GetSortColumns,
3081 FolderView2_GetItem,
3082 FolderView2_GetVisibleItem,
3083 FolderView2_GetSelectedItem,
3084 FolderView2_GetSelection,
3085 FolderView2_GetSelectionState,
3086 FolderView2_InvokeVerbOnSelection,
3087 FolderView2_SetViewModeAndIconSize,
3088 FolderView2_GetViewModeAndIconSize,
3089 FolderView2_SetGroupSubsetCount,
3090 FolderView2_GetGroupSubsetCount,
3091 FolderView2_SetRedraw,
3092 FolderView2_IsMoveInSameFolder,
3093 FolderView2_DoRename
3096 /* IShellFolderView */
3097 static HRESULT WINAPI IShellFolderView_fnQueryInterface(IShellFolderView *iface, REFIID riid, void **ppvObj)
3099 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3100 return IShellView3_QueryInterface(&This->IShellView3_iface, riid, ppvObj);
3103 static ULONG WINAPI IShellFolderView_fnAddRef(IShellFolderView *iface)
3105 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3106 return IShellView3_AddRef(&This->IShellView3_iface);
3109 static ULONG WINAPI IShellFolderView_fnRelease(IShellFolderView *iface)
3111 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3112 return IShellView3_Release(&This->IShellView3_iface);
3115 static HRESULT WINAPI IShellFolderView_fnRearrange(IShellFolderView *iface, LPARAM sort)
3117 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3118 FIXME("(%p)->(%ld) stub\n", This, sort);
3119 return E_NOTIMPL;
3122 static HRESULT WINAPI IShellFolderView_fnGetArrangeParam(IShellFolderView *iface, LPARAM *sort)
3124 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3125 FIXME("(%p)->(%p) stub\n", This, sort);
3126 return E_NOTIMPL;
3129 static HRESULT WINAPI IShellFolderView_fnArrangeGrid(IShellFolderView *iface)
3131 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3132 FIXME("(%p) stub\n", This);
3133 return E_NOTIMPL;
3136 static HRESULT WINAPI IShellFolderView_fnAutoArrange(IShellFolderView *iface)
3138 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3139 TRACE("(%p)\n", This);
3140 return IFolderView2_SetCurrentFolderFlags(&This->IFolderView2_iface, FWF_AUTOARRANGE, FWF_AUTOARRANGE);
3143 static HRESULT WINAPI IShellFolderView_fnGetAutoArrange(IShellFolderView *iface)
3145 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3146 TRACE("(%p)\n", This);
3147 return IFolderView2_GetAutoArrange(&This->IFolderView2_iface);
3150 static HRESULT WINAPI IShellFolderView_fnAddObject(
3151 IShellFolderView *iface,
3152 PITEMID_CHILD pidl,
3153 UINT *item)
3155 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3156 FIXME("(%p)->(%p %p) stub\n", This, pidl, item);
3157 return E_NOTIMPL;
3160 static HRESULT WINAPI IShellFolderView_fnGetObject(
3161 IShellFolderView *iface,
3162 PITEMID_CHILD *pidl,
3163 UINT item)
3165 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3166 TRACE("(%p)->(%p %d)\n", This, pidl, item);
3167 return IFolderView2_Item(&This->IFolderView2_iface, item, pidl);
3170 static HRESULT WINAPI IShellFolderView_fnRemoveObject(
3171 IShellFolderView *iface,
3172 PITEMID_CHILD pidl,
3173 UINT *item)
3175 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3177 TRACE("(%p)->(%p %p)\n", This, pidl, item);
3179 if (pidl)
3181 *item = LV_FindItemByPidl(This, ILFindLastID(pidl));
3182 SendMessageW(This->hWndList, LVM_DELETEITEM, *item, 0);
3184 else
3186 *item = 0;
3187 SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0);
3190 return S_OK;
3193 static HRESULT WINAPI IShellFolderView_fnGetObjectCount(
3194 IShellFolderView *iface,
3195 UINT *count)
3197 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3198 TRACE("(%p)->(%p)\n", This, count);
3199 return IFolderView2_ItemCount(&This->IFolderView2_iface, SVGIO_ALLVIEW, (INT*)count);
3202 static HRESULT WINAPI IShellFolderView_fnSetObjectCount(
3203 IShellFolderView *iface,
3204 UINT count,
3205 UINT flags)
3207 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3208 FIXME("(%p)->(%d %x) stub\n", This, count, flags);
3209 return E_NOTIMPL;
3212 static HRESULT WINAPI IShellFolderView_fnUpdateObject(
3213 IShellFolderView *iface,
3214 PITEMID_CHILD pidl_old,
3215 PITEMID_CHILD pidl_new,
3216 UINT *item)
3218 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3219 FIXME("(%p)->(%p %p %p) stub\n", This, pidl_old, pidl_new, item);
3220 return E_NOTIMPL;
3223 static HRESULT WINAPI IShellFolderView_fnRefreshObject(
3224 IShellFolderView *iface,
3225 PITEMID_CHILD pidl,
3226 UINT *item)
3228 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3229 FIXME("(%p)->(%p %p) stub\n", This, pidl, item);
3230 return E_NOTIMPL;
3233 static HRESULT WINAPI IShellFolderView_fnSetRedraw(
3234 IShellFolderView *iface,
3235 BOOL redraw)
3237 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3238 TRACE("(%p)->(%d)\n", This, redraw);
3239 return IFolderView2_SetRedraw(&This->IFolderView2_iface, redraw);
3242 static HRESULT WINAPI IShellFolderView_fnGetSelectedCount(
3243 IShellFolderView *iface,
3244 UINT *count)
3246 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3247 IShellItemArray *selection;
3248 HRESULT hr;
3250 TRACE("(%p)->(%p)\n", This, count);
3252 *count = 0;
3253 hr = IFolderView2_GetSelection(&This->IFolderView2_iface, FALSE, &selection);
3254 if (FAILED(hr))
3255 return hr;
3257 hr = IShellItemArray_GetCount(selection, count);
3258 IShellItemArray_Release(selection);
3259 return hr;
3262 static HRESULT WINAPI IShellFolderView_fnGetSelectedObjects(
3263 IShellFolderView *iface,
3264 PCITEMID_CHILD **pidl,
3265 UINT *items)
3267 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3269 TRACE("(%p)->(%p %p)\n", This, pidl, items);
3271 *items = ShellView_GetSelections( This );
3273 if (*items)
3275 *pidl = LocalAlloc(0, *items*sizeof(LPITEMIDLIST));
3276 if (!*pidl) return E_OUTOFMEMORY;
3278 /* it's documented that caller shouldn't free PIDLs, only array itself */
3279 memcpy((PITEMID_CHILD*)*pidl, This->apidl, *items*sizeof(LPITEMIDLIST));
3282 return S_OK;
3285 static HRESULT WINAPI IShellFolderView_fnIsDropOnSource(
3286 IShellFolderView *iface,
3287 IDropTarget *drop_target)
3289 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3290 FIXME("(%p)->(%p) stub\n", This, drop_target);
3291 return E_NOTIMPL;
3294 static HRESULT WINAPI IShellFolderView_fnGetDragPoint(
3295 IShellFolderView *iface,
3296 POINT *pt)
3298 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3299 FIXME("(%p)->(%p) stub\n", This, pt);
3300 return E_NOTIMPL;
3303 static HRESULT WINAPI IShellFolderView_fnGetDropPoint(
3304 IShellFolderView *iface,
3305 POINT *pt)
3307 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3308 FIXME("(%p)->(%p) stub\n", This, pt);
3309 return E_NOTIMPL;
3312 static HRESULT WINAPI IShellFolderView_fnMoveIcons(
3313 IShellFolderView *iface,
3314 IDataObject *obj)
3316 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3317 TRACE("(%p)->(%p)\n", This, obj);
3318 return E_NOTIMPL;
3321 static HRESULT WINAPI IShellFolderView_fnSetItemPos(
3322 IShellFolderView *iface,
3323 PCUITEMID_CHILD pidl,
3324 POINT *pt)
3326 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3327 FIXME("(%p)->(%p %p) stub\n", This, pidl, pt);
3328 return E_NOTIMPL;
3331 static HRESULT WINAPI IShellFolderView_fnIsBkDropTarget(
3332 IShellFolderView *iface,
3333 IDropTarget *drop_target)
3335 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3336 FIXME("(%p)->(%p) stub\n", This, drop_target);
3337 return E_NOTIMPL;
3340 static HRESULT WINAPI IShellFolderView_fnSetClipboard(
3341 IShellFolderView *iface,
3342 BOOL move)
3344 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3345 FIXME("(%p)->(%d) stub\n", This, move);
3346 return E_NOTIMPL;
3349 static HRESULT WINAPI IShellFolderView_fnSetPoints(
3350 IShellFolderView *iface,
3351 IDataObject *obj)
3353 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3354 FIXME("(%p)->(%p) stub\n", This, obj);
3355 return E_NOTIMPL;
3358 static HRESULT WINAPI IShellFolderView_fnGetItemSpacing(
3359 IShellFolderView *iface,
3360 ITEMSPACING *spacing)
3362 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3363 FIXME("(%p)->(%p) stub\n", This, spacing);
3364 return E_NOTIMPL;
3367 static HRESULT WINAPI IShellFolderView_fnSetCallback(
3368 IShellFolderView *iface,
3369 IShellFolderViewCB *new_cb,
3370 IShellFolderViewCB **old_cb)
3373 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3374 FIXME("(%p)->(%p %p) stub\n", This, new_cb, old_cb);
3375 return E_NOTIMPL;
3378 static HRESULT WINAPI IShellFolderView_fnSelect(
3379 IShellFolderView *iface,
3380 UINT flags)
3382 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3383 FIXME("(%p)->(%d) stub\n", This, flags);
3384 return E_NOTIMPL;
3387 static HRESULT WINAPI IShellFolderView_fnQuerySupport(
3388 IShellFolderView *iface,
3389 UINT *support)
3391 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3392 TRACE("(%p)->(%p)\n", This, support);
3393 return S_OK;
3396 static HRESULT WINAPI IShellFolderView_fnSetAutomationObject(
3397 IShellFolderView *iface,
3398 IDispatch *disp)
3400 IShellViewImpl *This = impl_from_IShellFolderView(iface);
3401 FIXME("(%p)->(%p) stub\n", This, disp);
3402 return E_NOTIMPL;
3405 static const IShellFolderViewVtbl shellfolderviewvtbl =
3407 IShellFolderView_fnQueryInterface,
3408 IShellFolderView_fnAddRef,
3409 IShellFolderView_fnRelease,
3410 IShellFolderView_fnRearrange,
3411 IShellFolderView_fnGetArrangeParam,
3412 IShellFolderView_fnArrangeGrid,
3413 IShellFolderView_fnAutoArrange,
3414 IShellFolderView_fnGetAutoArrange,
3415 IShellFolderView_fnAddObject,
3416 IShellFolderView_fnGetObject,
3417 IShellFolderView_fnRemoveObject,
3418 IShellFolderView_fnGetObjectCount,
3419 IShellFolderView_fnSetObjectCount,
3420 IShellFolderView_fnUpdateObject,
3421 IShellFolderView_fnRefreshObject,
3422 IShellFolderView_fnSetRedraw,
3423 IShellFolderView_fnGetSelectedCount,
3424 IShellFolderView_fnGetSelectedObjects,
3425 IShellFolderView_fnIsDropOnSource,
3426 IShellFolderView_fnGetDragPoint,
3427 IShellFolderView_fnGetDropPoint,
3428 IShellFolderView_fnMoveIcons,
3429 IShellFolderView_fnSetItemPos,
3430 IShellFolderView_fnIsBkDropTarget,
3431 IShellFolderView_fnSetClipboard,
3432 IShellFolderView_fnSetPoints,
3433 IShellFolderView_fnGetItemSpacing,
3434 IShellFolderView_fnSetCallback,
3435 IShellFolderView_fnSelect,
3436 IShellFolderView_fnQuerySupport,
3437 IShellFolderView_fnSetAutomationObject
3440 static HRESULT WINAPI shellfolderviewdual_QueryInterface(IShellFolderViewDual3 *iface, REFIID riid, void **ppvObj)
3442 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3444 TRACE("(%p)->(IID:%s,%p)\n", This, debugstr_guid(riid), ppvObj);
3446 if (IsEqualIID(riid, &IID_IShellFolderViewDual3) ||
3447 IsEqualIID(riid, &IID_IShellFolderViewDual2) ||
3448 IsEqualIID(riid, &IID_IShellFolderViewDual) ||
3449 IsEqualIID(riid, &IID_IDispatch) ||
3450 IsEqualIID(riid, &IID_IUnknown))
3452 *ppvObj = iface;
3453 IShellFolderViewDual3_AddRef(iface);
3454 return S_OK;
3457 WARN("unsupported interface %s\n", debugstr_guid(riid));
3458 return E_NOINTERFACE;
3461 static ULONG WINAPI shellfolderviewdual_AddRef(IShellFolderViewDual3 *iface)
3463 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3464 return IShellView3_AddRef(&This->IShellView3_iface);
3467 static ULONG WINAPI shellfolderviewdual_Release(IShellFolderViewDual3 *iface)
3469 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3470 return IShellView3_Release(&This->IShellView3_iface);
3473 static HRESULT WINAPI shellfolderviewdual_GetTypeInfoCount(IShellFolderViewDual3 *iface, UINT *pctinfo)
3475 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3476 TRACE("%p %p\n", This, pctinfo);
3477 *pctinfo = 1;
3478 return S_OK;
3481 static HRESULT WINAPI shellfolderviewdual_GetTypeInfo(IShellFolderViewDual3 *iface,
3482 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
3484 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3485 HRESULT hr;
3487 TRACE("(%p,%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo);
3489 hr = get_typeinfo(IShellFolderViewDual3_tid, ppTInfo);
3490 if (SUCCEEDED(hr))
3491 ITypeInfo_AddRef(*ppTInfo);
3492 return hr;
3495 static HRESULT WINAPI shellfolderviewdual_GetIDsOfNames(
3496 IShellFolderViewDual3 *iface, REFIID riid, LPOLESTR *rgszNames, UINT
3497 cNames, LCID lcid, DISPID *rgDispId)
3499 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3500 ITypeInfo *ti;
3501 HRESULT hr;
3503 TRACE("(%p, %s, %p, %u, %d, %p)\n", This, debugstr_guid(riid), rgszNames,
3504 cNames, lcid, rgDispId);
3506 hr = get_typeinfo(IShellFolderViewDual3_tid, &ti);
3507 if (SUCCEEDED(hr))
3508 hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId);
3509 return hr;
3512 static HRESULT WINAPI shellfolderviewdual_Invoke(IShellFolderViewDual3 *iface,
3513 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
3514 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
3515 UINT *puArgErr)
3517 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3518 ITypeInfo *ti;
3519 HRESULT hr;
3521 TRACE("(%p, %d, %s, %d, %u, %p, %p, %p, %p)\n", This, dispIdMember,
3522 debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult,
3523 pExcepInfo, puArgErr);
3525 hr = get_typeinfo(IShellFolderViewDual3_tid, &ti);
3526 if (SUCCEEDED(hr))
3527 hr = ITypeInfo_Invoke(ti, &This->IShellFolderViewDual3_iface, dispIdMember, wFlags, pDispParams,
3528 pVarResult, pExcepInfo, puArgErr);
3529 return hr;
3533 static HRESULT WINAPI shellfolderviewdual_get_Application(IShellFolderViewDual3 *iface,
3534 IDispatch **disp)
3536 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3538 TRACE("%p %p\n", This, disp);
3540 if (!disp)
3541 return E_INVALIDARG;
3543 return IShellDispatch_Constructor(NULL, &IID_IDispatch, (void**)disp);
3546 static HRESULT WINAPI shellfolderviewdual_get_Parent(IShellFolderViewDual3 *iface, IDispatch **disp)
3548 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3549 FIXME("%p %p\n", This, disp);
3550 return E_NOTIMPL;
3553 static HRESULT WINAPI shellfolderviewdual_get_Folder(IShellFolderViewDual3 *iface, Folder **folder)
3555 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3556 FIXME("%p %p\n", This, folder);
3557 return E_NOTIMPL;
3560 static HRESULT WINAPI shellfolderviewdual_SelectedItems(IShellFolderViewDual3 *iface, FolderItems **items)
3562 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3563 FIXME("%p %p\n", This, items);
3564 return E_NOTIMPL;
3567 static HRESULT WINAPI shellfolderviewdual_get_FocusedItem(IShellFolderViewDual3 *iface,
3568 FolderItem **item)
3570 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3571 FIXME("%p %p\n", This, item);
3572 return E_NOTIMPL;
3575 static HRESULT WINAPI shellfolderviewdual_SelectItem(IShellFolderViewDual3 *iface,
3576 VARIANT *v, int flags)
3578 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3579 FIXME("%p %s %x\n", This, debugstr_variant(v), flags);
3580 return E_NOTIMPL;
3583 static HRESULT WINAPI shellfolderviewdual_PopupItemMenu(IShellFolderViewDual3 *iface,
3584 FolderItem *item, VARIANT vx, VARIANT vy, BSTR *command)
3586 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3587 FIXME("%p %p %s %s %p\n", This, item, debugstr_variant(&vx), debugstr_variant(&vy), command);
3588 return E_NOTIMPL;
3591 static HRESULT WINAPI shellfolderviewdual_get_Script(IShellFolderViewDual3 *iface, IDispatch **disp)
3593 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3594 FIXME("%p %p\n", This, disp);
3595 return E_NOTIMPL;
3598 static HRESULT WINAPI shellfolderviewdual_get_ViewOptions(IShellFolderViewDual3 *iface, LONG *options)
3600 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3601 FIXME("%p %p\n", This, options);
3602 return E_NOTIMPL;
3605 static HRESULT WINAPI shellfolderviewdual_get_CurrentViewMode(IShellFolderViewDual3 *iface, UINT *mode)
3607 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3608 FIXME("%p %p\n", This, mode);
3609 return E_NOTIMPL;
3612 static HRESULT WINAPI shellfolderviewdual_put_CurrentViewMode(IShellFolderViewDual3 *iface, UINT mode)
3614 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3615 FIXME("%p %u\n", This, mode);
3616 return E_NOTIMPL;
3619 static HRESULT WINAPI shellfolderviewdual_SelectItemRelative(IShellFolderViewDual3 *iface, int relative)
3621 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3622 FIXME("%p %d\n", This, relative);
3623 return E_NOTIMPL;
3626 static HRESULT WINAPI shellfolderviewdual_get_GroupBy(IShellFolderViewDual3 *iface, BSTR *groupby)
3628 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3629 FIXME("%p %p\n", This, groupby);
3630 return E_NOTIMPL;
3633 static HRESULT WINAPI shellfolderviewdual_put_GroupBy(IShellFolderViewDual3 *iface, BSTR groupby)
3635 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3636 FIXME("%p %s\n", This, debugstr_w(groupby));
3637 return E_NOTIMPL;
3640 static HRESULT WINAPI shellfolderviewdual_get_FolderFlags(IShellFolderViewDual3 *iface, DWORD *flags)
3642 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3643 FIXME("%p %p\n", This, flags);
3644 return E_NOTIMPL;
3647 static HRESULT WINAPI shellfolderviewdual_put_FolderFlags(IShellFolderViewDual3 *iface, DWORD flags)
3649 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3650 FIXME("%p 0x%08x\n", This, flags);
3651 return E_NOTIMPL;
3654 static HRESULT WINAPI shellfolderviewdual_get_SortColumns(IShellFolderViewDual3 *iface, BSTR *sortcolumns)
3656 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3657 FIXME("%p %p\n", This, sortcolumns);
3658 return E_NOTIMPL;
3661 static HRESULT WINAPI shellfolderviewdual_put_SortColumns(IShellFolderViewDual3 *iface, BSTR sortcolumns)
3663 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3664 FIXME("%p %s\n", This, debugstr_w(sortcolumns));
3665 return E_NOTIMPL;
3668 static HRESULT WINAPI shellfolderviewdual_put_IconSize(IShellFolderViewDual3 *iface, int icon_size)
3670 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3671 FIXME("%p %d\n", This, icon_size);
3672 return E_NOTIMPL;
3675 static HRESULT WINAPI shellfolderviewdual_get_IconSize(IShellFolderViewDual3 *iface, int *icon_size)
3677 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3678 FIXME("%p %p\n", This, icon_size);
3679 return E_NOTIMPL;
3682 static HRESULT WINAPI shellfolderviewdual_FilterView(IShellFolderViewDual3 *iface, BSTR filter_text)
3684 IShellViewImpl *This = impl_from_IShellFolderViewDual3(iface);
3685 FIXME("%p %s\n", This, debugstr_w(filter_text));
3686 return E_NOTIMPL;
3689 static const IShellFolderViewDual3Vtbl shellfolderviewdualvtbl =
3691 shellfolderviewdual_QueryInterface,
3692 shellfolderviewdual_AddRef,
3693 shellfolderviewdual_Release,
3694 shellfolderviewdual_GetTypeInfoCount,
3695 shellfolderviewdual_GetTypeInfo,
3696 shellfolderviewdual_GetIDsOfNames,
3697 shellfolderviewdual_Invoke,
3698 shellfolderviewdual_get_Application,
3699 shellfolderviewdual_get_Parent,
3700 shellfolderviewdual_get_Folder,
3701 shellfolderviewdual_SelectedItems,
3702 shellfolderviewdual_get_FocusedItem,
3703 shellfolderviewdual_SelectItem,
3704 shellfolderviewdual_PopupItemMenu,
3705 shellfolderviewdual_get_Script,
3706 shellfolderviewdual_get_ViewOptions,
3707 shellfolderviewdual_get_CurrentViewMode,
3708 shellfolderviewdual_put_CurrentViewMode,
3709 shellfolderviewdual_SelectItemRelative,
3710 shellfolderviewdual_get_GroupBy,
3711 shellfolderviewdual_put_GroupBy,
3712 shellfolderviewdual_get_FolderFlags,
3713 shellfolderviewdual_put_FolderFlags,
3714 shellfolderviewdual_get_SortColumns,
3715 shellfolderviewdual_put_SortColumns,
3716 shellfolderviewdual_put_IconSize,
3717 shellfolderviewdual_get_IconSize,
3718 shellfolderviewdual_FilterView
3721 /**********************************************************
3722 * IShellView_Constructor
3724 IShellView *IShellView_Constructor(IShellFolder *folder)
3726 IShellViewImpl *sv;
3728 sv = heap_alloc_zero(sizeof(*sv));
3729 if (!sv)
3730 return NULL;
3732 sv->ref = 1;
3733 sv->IShellView3_iface.lpVtbl = &shellviewvtbl;
3734 sv->IOleCommandTarget_iface.lpVtbl = &olecommandtargetvtbl;
3735 sv->IDropTarget_iface.lpVtbl = &droptargetvtbl;
3736 sv->IDropSource_iface.lpVtbl = &dropsourcevtbl;
3737 sv->IViewObject_iface.lpVtbl = &viewobjectvtbl;
3738 sv->IFolderView2_iface.lpVtbl = &folderviewvtbl;
3739 sv->IShellFolderView_iface.lpVtbl = &shellfolderviewvtbl;
3740 sv->IShellFolderViewDual3_iface.lpVtbl = &shellfolderviewdualvtbl;
3742 sv->pSFParent = folder;
3743 if (folder) IShellFolder_AddRef(folder);
3744 IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (void**)&sv->pSF2Parent);
3746 sv->pCurDropTarget = NULL;
3747 sv->pCurDataObject = NULL;
3748 sv->iDragOverItem = 0;
3749 sv->cScrollDelay = 0;
3750 sv->ptLastMousePos.x = 0;
3751 sv->ptLastMousePos.y = 0;
3753 TRACE("(%p)->(%p)\n", sv, folder);
3754 return (IShellView*)&sv->IShellView3_iface;
3757 /*************************************************************************
3758 * SHCreateShellFolderView [SHELL32.256]
3760 * Create a new instance of the default Shell folder view object.
3762 * RETURNS
3763 * Success: S_OK
3764 * Failure: error value
3766 * NOTES
3767 * see IShellFolder::CreateViewObject
3769 HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *desc, IShellView **shellview)
3771 TRACE("(%p, %p)\n", desc, shellview);
3773 *shellview = NULL;
3775 if (!desc || desc->cbSize != sizeof(*desc))
3776 return E_INVALIDARG;
3778 TRACE("sf=%p outer=%p callback=%p\n", desc->pshf, desc->psvOuter, desc->psfvcb);
3780 if (!desc->pshf)
3781 return E_UNEXPECTED;
3783 *shellview = IShellView_Constructor(desc->pshf);
3784 if (!*shellview)
3785 return E_OUTOFMEMORY;
3787 if (desc->psfvcb)
3789 IShellFolderView *view;
3790 IShellView_QueryInterface(*shellview, &IID_IShellFolderView, (void **)&view);
3791 IShellFolderView_SetCallback(view, desc->psfvcb, NULL);
3792 IShellFolderView_Release(view);
3795 return S_OK;
3798 /*************************************************************************
3799 * SHCreateShellFolderViewEx [SHELL32.174]
3801 * Create a new instance of the default Shell folder view object.
3803 * RETURNS
3804 * Success: S_OK
3805 * Failure: error value
3807 * NOTES
3808 * see IShellFolder::CreateViewObject
3810 HRESULT WINAPI SHCreateShellFolderViewEx(CSFV *desc, IShellView **shellview)
3812 TRACE("(%p, %p)\n", desc, shellview);
3814 TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n", desc->pshf, desc->pidl, desc->pfnCallback,
3815 desc->fvm, desc->psvOuter);
3817 if (!desc->pshf)
3818 return E_UNEXPECTED;
3820 *shellview = IShellView_Constructor(desc->pshf);
3821 if (!*shellview)
3822 return E_OUTOFMEMORY;
3824 return S_OK;