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
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
40 #include "wine/port.h"
47 #define NONAMELESSUNION
60 #include "undocshell.h"
62 #include "wine/debug.h"
66 #include "shell32_main.h"
67 #include "shellfolder.h"
69 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
71 static const WCHAR SV_CLASS_NAME
[] = {'S','H','E','L','L','D','L','L','_','D','e','f','V','i','e','w',0};
77 }LISTVIEW_SORT_INFO
, *LPLISTVIEW_SORT_INFO
;
81 IShellView2 IShellView2_iface
;
82 IOleCommandTarget IOleCommandTarget_iface
;
83 IDropTarget IDropTarget_iface
;
84 IDropSource IDropSource_iface
;
85 IViewObject IViewObject_iface
;
86 IFolderView IFolderView_iface
;
87 IShellFolderView IShellFolderView_iface
;
89 IShellFolder
* pSFParent
;
90 IShellFolder2
* pSF2Parent
;
91 IShellBrowser
* pShellBrowser
;
92 ICommDlgBrowser
* pCommDlgBrowser
;
93 HWND hWnd
; /* SHELLDLL_DefView */
94 HWND hWndList
; /* ListView control */
96 FOLDERSETTINGS FolderSettings
;
101 LISTVIEW_SORT_INFO ListViewSortInfo
;
102 ULONG hNotify
; /* change notification handle */
106 IAdviseSink
*pAdvSink
;
107 IDropTarget
* pCurDropTarget
; /* The sub-item, which is currently dragged over */
108 IDataObject
* pCurDataObject
; /* The dragged data-object */
109 LONG iDragOverItem
; /* Dragged over item's index, iff pCurDropTarget != NULL */
110 UINT cScrollDelay
; /* Send a WM_*SCROLL msg every 250 ms during drag-scroll */
111 POINT ptLastMousePos
; /* Mouse position at last DragOver call */
114 static const IShellView2Vtbl svvt
;
115 static const IOleCommandTargetVtbl ctvt
;
116 static const IDropTargetVtbl dtvt
;
117 static const IDropSourceVtbl dsvt
;
118 static const IViewObjectVtbl vovt
;
119 static const IFolderViewVtbl fviewvt
;
120 static const IShellFolderViewVtbl shellfolderviewvt
;
122 static inline IShellViewImpl
*impl_from_IShellView2(IShellView2
*iface
)
124 return CONTAINING_RECORD(iface
, IShellViewImpl
, IShellView2_iface
);
127 static inline IShellViewImpl
*impl_from_IOleCommandTarget(IOleCommandTarget
*iface
)
129 return CONTAINING_RECORD(iface
, IShellViewImpl
, IOleCommandTarget_iface
);
132 static inline IShellViewImpl
*impl_from_IDropTarget(IDropTarget
*iface
)
134 return CONTAINING_RECORD(iface
, IShellViewImpl
, IDropTarget_iface
);
137 static inline IShellViewImpl
*impl_from_IDropSource(IDropSource
*iface
)
139 return CONTAINING_RECORD(iface
, IShellViewImpl
, IDropSource_iface
);
142 static inline IShellViewImpl
*impl_from_IViewObject(IViewObject
*iface
)
144 return CONTAINING_RECORD(iface
, IShellViewImpl
, IViewObject_iface
);
147 static inline IShellViewImpl
*impl_from_IFolderView(IFolderView
*iface
)
149 return CONTAINING_RECORD(iface
, IShellViewImpl
, IFolderView_iface
);
152 static inline IShellViewImpl
*impl_from_IShellFolderView(IShellFolderView
*iface
)
154 return CONTAINING_RECORD(iface
, IShellViewImpl
, IShellFolderView_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
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
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
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
},
199 typedef void (CALLBACK
*PFNSHGETSETTINGSPROC
)(LPSHELLFLAGSTATE lpsfs
, DWORD dwMask
);
201 /**********************************************************
202 * IShellView_Constructor
204 IShellView
* IShellView_Constructor( IShellFolder
* pFolder
)
205 { IShellViewImpl
* sv
;
206 sv
=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IShellViewImpl
));
208 sv
->IShellView2_iface
.lpVtbl
= &svvt
;
209 sv
->IOleCommandTarget_iface
.lpVtbl
= &ctvt
;
210 sv
->IDropTarget_iface
.lpVtbl
= &dtvt
;
211 sv
->IDropSource_iface
.lpVtbl
= &dsvt
;
212 sv
->IViewObject_iface
.lpVtbl
= &vovt
;
213 sv
->IFolderView_iface
.lpVtbl
= &fviewvt
;
214 sv
->IShellFolderView_iface
.lpVtbl
= &shellfolderviewvt
;
216 sv
->pSFParent
= pFolder
;
217 if(pFolder
) IShellFolder_AddRef(pFolder
);
218 IShellFolder_QueryInterface(sv
->pSFParent
, &IID_IShellFolder2
, (LPVOID
*)&sv
->pSF2Parent
);
220 sv
->pCurDropTarget
= NULL
;
221 sv
->pCurDataObject
= NULL
;
222 sv
->iDragOverItem
= 0;
223 sv
->cScrollDelay
= 0;
224 sv
->ptLastMousePos
.x
= 0;
225 sv
->ptLastMousePos
.y
= 0;
227 TRACE("(%p)->(%p)\n",sv
, pFolder
);
228 return (IShellView
*) sv
;
231 /**********************************************************
233 * ##### helperfunctions for communication with ICommDlgBrowser #####
235 static BOOL
IsInCommDlg(IShellViewImpl
* This
)
236 { return(This
->pCommDlgBrowser
!= NULL
);
239 static HRESULT
IncludeObject(IShellViewImpl
* This
, LPCITEMIDLIST pidl
)
243 if ( IsInCommDlg(This
) )
245 TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl
);
246 ret
= ICommDlgBrowser_IncludeObject(This
->pCommDlgBrowser
, (IShellView
*)This
, pidl
);
247 TRACE("--0x%08x\n", ret
);
252 static HRESULT
OnDefaultCommand(IShellViewImpl
* This
)
254 HRESULT ret
= S_FALSE
;
256 if (IsInCommDlg(This
))
258 TRACE("ICommDlgBrowser::OnDefaultCommand\n");
259 ret
= ICommDlgBrowser_OnDefaultCommand(This
->pCommDlgBrowser
, (IShellView
*)This
);
260 TRACE("-- returns %08x\n", ret
);
265 static HRESULT
OnStateChange(IShellViewImpl
* This
, UINT uFlags
)
267 HRESULT ret
= S_FALSE
;
269 if (IsInCommDlg(This
))
271 TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags
);
272 ret
= ICommDlgBrowser_OnStateChange(This
->pCommDlgBrowser
, (IShellView
*)This
, uFlags
);
277 /**********************************************************
278 * set the toolbar of the filedialog buttons
280 * - activates the buttons from the shellbrowser according to
283 static void CheckToolbar(IShellViewImpl
* This
)
289 if (IsInCommDlg(This
))
291 IShellBrowser_SendControlMsg(This
->pShellBrowser
, FCW_TOOLBAR
, TB_CHECKBUTTON
,
292 FCIDM_TB_SMALLICON
, This
->FolderSettings
.ViewMode
== FVM_LIST
, &result
);
293 IShellBrowser_SendControlMsg(This
->pShellBrowser
, FCW_TOOLBAR
, TB_CHECKBUTTON
,
294 FCIDM_TB_REPORTVIEW
, This
->FolderSettings
.ViewMode
== FVM_DETAILS
, &result
);
295 IShellBrowser_SendControlMsg(This
->pShellBrowser
, FCW_TOOLBAR
, TB_ENABLEBUTTON
,
296 FCIDM_TB_SMALLICON
, TRUE
, &result
);
297 IShellBrowser_SendControlMsg(This
->pShellBrowser
, FCW_TOOLBAR
, TB_ENABLEBUTTON
,
298 FCIDM_TB_REPORTVIEW
, TRUE
, &result
);
302 /**********************************************************
304 * ##### helperfunctions for initializing the view #####
306 /**********************************************************
307 * change the style of the listview control
309 static void SetStyle(IShellViewImpl
* This
, DWORD dwAdd
, DWORD dwRemove
)
313 TRACE("(%p)\n", This
);
315 tmpstyle
= GetWindowLongW(This
->hWndList
, GWL_STYLE
);
316 SetWindowLongW(This
->hWndList
, GWL_STYLE
, dwAdd
| (tmpstyle
& ~dwRemove
));
319 static DWORD
ViewModeToListStyle(UINT ViewMode
)
323 TRACE("%d\n", ViewMode
);
327 case FVM_ICON
: dwStyle
= LVS_ICON
; break;
328 case FVM_DETAILS
: dwStyle
= LVS_REPORT
; break;
329 case FVM_SMALLICON
: dwStyle
= LVS_SMALLICON
; break;
330 case FVM_LIST
: dwStyle
= LVS_LIST
; break;
333 FIXME("ViewMode %d not implemented\n", ViewMode
);
342 /**********************************************************
343 * ShellView_CreateList()
345 * - creates the list view window
347 static BOOL
ShellView_CreateList (IShellViewImpl
* This
)
348 { DWORD dwStyle
, dwExStyle
;
352 dwStyle
= WS_TABSTOP
| WS_VISIBLE
| WS_CHILDWINDOW
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
|
353 LVS_SHAREIMAGELISTS
| LVS_EDITLABELS
| LVS_ALIGNLEFT
| LVS_AUTOARRANGE
;
354 dwExStyle
= WS_EX_CLIENTEDGE
;
356 dwStyle
|= ViewModeToListStyle(This
->FolderSettings
.ViewMode
);
358 if (This
->FolderSettings
.fFlags
& FWF_AUTOARRANGE
) dwStyle
|= LVS_AUTOARRANGE
;
359 if (This
->FolderSettings
.fFlags
& FWF_DESKTOP
)
360 This
->FolderSettings
.fFlags
|= FWF_NOCLIENTEDGE
| FWF_NOSCROLL
;
361 if (This
->FolderSettings
.fFlags
& FWF_SINGLESEL
) dwStyle
|= LVS_SINGLESEL
;
362 if (This
->FolderSettings
.fFlags
& FWF_NOCLIENTEDGE
)
363 dwExStyle
&= ~WS_EX_CLIENTEDGE
;
365 This
->hWndList
=CreateWindowExW( dwExStyle
,
378 This
->ListViewSortInfo
.bIsAscending
= TRUE
;
379 This
->ListViewSortInfo
.nHeaderID
= -1;
380 This
->ListViewSortInfo
.nLastHeaderID
= -1;
382 if (This
->FolderSettings
.fFlags
& FWF_DESKTOP
) {
384 * FIXME: look at the registry value
385 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ListviewShadow
386 * and activate drop shadows if necessary
389 SendMessageW(This
->hWndList
, LVM_SETTEXTBKCOLOR
, 0, CLR_NONE
);
391 SendMessageW(This
->hWndList
, LVM_SETTEXTBKCOLOR
, 0, GetSysColor(COLOR_DESKTOP
));
393 SendMessageW(This
->hWndList
, LVM_SETTEXTCOLOR
, 0, RGB(255,255,255));
396 /* UpdateShellSettings(); */
400 /**********************************************************
401 * ShellView_InitList()
403 * - adds all needed columns to the shellview
405 static void ShellView_InitList(IShellViewImpl
*This
)
407 IShellDetails
*details
= NULL
;
408 HIMAGELIST big_icons
, small_icons
;
415 TRACE("(%p)\n", This
);
417 Shell_GetImageLists( &big_icons
, &small_icons
);
418 SendMessageW(This
->hWndList
, LVM_DELETEALLITEMS
, 0, 0);
419 SendMessageW(This
->hWndList
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)small_icons
);
420 SendMessageW(This
->hWndList
, LVM_SETIMAGELIST
, LVSIL_NORMAL
, (LPARAM
)big_icons
);
422 lvColumn
.mask
= LVCF_FMT
| LVCF_WIDTH
| LVCF_TEXT
;
423 lvColumn
.pszText
= nameW
;
425 if (!This
->pSF2Parent
)
427 hr
= IShellFolder_QueryInterface(This
->pSFParent
, &IID_IShellDetails
, (void**)&details
);
430 WARN("IShellFolder2/IShellDetails not supported\n");
437 if (This
->pSF2Parent
)
438 hr
= IShellFolder2_GetDetailsOf(This
->pSF2Parent
, NULL
, i
, &sd
);
440 hr
= IShellDetails_GetDetailsOf(details
, NULL
, i
, &sd
);
441 if (FAILED(hr
)) break;
443 lvColumn
.fmt
= sd
.fmt
;
444 lvColumn
.cx
= sd
.cxChar
*8; /* chars->pixel */
445 StrRetToStrNW(nameW
, sizeof(nameW
)/sizeof(WCHAR
), &sd
.str
, NULL
);
446 SendMessageW(This
->hWndList
, LVM_INSERTCOLUMNW
, i
, (LPARAM
) &lvColumn
);
449 if (details
) IShellDetails_Release(details
);
452 /**********************************************************
453 * ShellView_CompareItems()
456 * internal, CALLBACK for DSA_Sort
458 static INT CALLBACK
ShellView_CompareItems(LPVOID lParam1
, LPVOID lParam2
, LPARAM lpData
)
461 TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1
, lParam2
, (LPVOID
) lpData
);
463 if(!lpData
) return 0;
465 ret
= (SHORT
) SCODE_CODE(IShellFolder_CompareIDs((LPSHELLFOLDER
)lpData
, 0, (LPITEMIDLIST
)lParam1
, (LPITEMIDLIST
)lParam2
));
466 TRACE("ret=%i\n",ret
);
470 /*************************************************************************
471 * ShellView_ListViewCompareItems
473 * Compare Function for the Listview (FileOpen Dialog)
476 * lParam1 [I] the first ItemIdList to compare with
477 * lParam2 [I] the second ItemIdList to compare with
478 * lpData [I] The column ID for the header Ctrl to process
481 * A negative value if the first item should precede the second,
482 * a positive value if the first item should follow the second,
483 * or zero if the two items are equivalent
486 * FIXME: function does what ShellView_CompareItems is supposed to do.
487 * unify it and figure out how to use the undocumented first parameter
488 * of IShellFolder_CompareIDs to do the job this function does and
489 * move this code to IShellFolder.
490 * make LISTVIEW_SORT_INFO obsolete
491 * the way this function works is only usable if we had only
492 * filesystemfolders (25/10/99 jsch)
494 static INT CALLBACK
ShellView_ListViewCompareItems(LPVOID lParam1
, LPVOID lParam2
, LPARAM lpData
)
498 char strName1
[MAX_PATH
], strName2
[MAX_PATH
];
499 BOOL bIsFolder1
, bIsFolder2
,bIsBothFolder
;
500 LPITEMIDLIST pItemIdList1
= lParam1
;
501 LPITEMIDLIST pItemIdList2
= lParam2
;
502 LISTVIEW_SORT_INFO
*pSortInfo
= (LPLISTVIEW_SORT_INFO
) lpData
;
505 bIsFolder1
= _ILIsFolder(pItemIdList1
);
506 bIsFolder2
= _ILIsFolder(pItemIdList2
);
507 bIsBothFolder
= bIsFolder1
&& bIsFolder2
;
509 /* When sorting between a File and a Folder, the Folder gets sorted first */
510 if( (bIsFolder1
|| bIsFolder2
) && !bIsBothFolder
)
512 nDiff
= bIsFolder1
? -1 : 1;
516 /* Sort by Time: Folders or Files can be sorted */
518 if(pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_TIME
)
520 _ILGetFileDateTime(pItemIdList1
, &fd1
);
521 _ILGetFileDateTime(pItemIdList2
, &fd2
);
522 nDiff
= CompareFileTime(&fd2
, &fd1
);
524 /* Sort by Attribute: Folder or Files can be sorted */
525 else if(pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_ATTRIB
)
527 _ILGetFileAttributes(pItemIdList1
, strName1
, MAX_PATH
);
528 _ILGetFileAttributes(pItemIdList2
, strName2
, MAX_PATH
);
529 nDiff
= lstrcmpiA(strName1
, strName2
);
531 /* Sort by FileName: Folder or Files can be sorted */
532 else if(pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_NAME
|| bIsBothFolder
)
535 _ILSimpleGetText(pItemIdList1
, strName1
, MAX_PATH
);
536 _ILSimpleGetText(pItemIdList2
, strName2
, MAX_PATH
);
537 nDiff
= lstrcmpiA(strName1
, strName2
);
539 /* Sort by File Size, Only valid for Files */
540 else if(pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_SIZE
)
542 nDiff
= (INT
)(_ILGetFileSize(pItemIdList1
, NULL
, 0) - _ILGetFileSize(pItemIdList2
, NULL
, 0));
544 /* Sort by File Type, Only valid for Files */
545 else if(pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_TYPE
)
548 _ILGetFileType(pItemIdList1
, strName1
, MAX_PATH
);
549 _ILGetFileType(pItemIdList2
, strName2
, MAX_PATH
);
550 nDiff
= lstrcmpiA(strName1
, strName2
);
553 /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
557 _ILSimpleGetText(pItemIdList1
, strName1
, MAX_PATH
);
558 _ILSimpleGetText(pItemIdList2
, strName2
, MAX_PATH
);
559 nDiff
= lstrcmpiA(strName1
, strName2
);
562 if(!pSortInfo
->bIsAscending
)
571 /**********************************************************
572 * LV_FindItemByPidl()
574 static int LV_FindItemByPidl(
575 IShellViewImpl
* This
,
580 lvItem
.mask
= LVIF_PARAM
;
581 for(lvItem
.iItem
= 0;
582 SendMessageW(This
->hWndList
, LVM_GETITEMW
, 0, (LPARAM
) &lvItem
);
585 LPITEMIDLIST currentpidl
= (LPITEMIDLIST
) lvItem
.lParam
;
586 HRESULT hr
= IShellFolder_CompareIDs(This
->pSFParent
, 0, pidl
, currentpidl
);
587 if(SUCCEEDED(hr
) && !HRESULT_CODE(hr
))
595 /**********************************************************
598 static BOOLEAN
LV_AddItem(IShellViewImpl
* This
, LPCITEMIDLIST pidl
)
602 TRACE("(%p)(pidl=%p)\n", This
, pidl
);
604 lvItem
.mask
= LVIF_TEXT
| LVIF_IMAGE
| LVIF_PARAM
; /*set the mask*/
605 lvItem
.iItem
= SendMessageW(This
->hWndList
, LVM_GETITEMCOUNT
, 0, 0); /*add the item to the end of the list*/
607 lvItem
.lParam
= (LPARAM
) ILClone(ILFindLastID(pidl
)); /*set the item's data*/
608 lvItem
.pszText
= LPSTR_TEXTCALLBACKW
; /*get text on a callback basis*/
609 lvItem
.iImage
= I_IMAGECALLBACK
; /*get the image on a callback basis*/
610 return ListView_InsertItemW(This
->hWndList
, &lvItem
) != -1;
613 /**********************************************************
616 static BOOLEAN
LV_RenameItem(IShellViewImpl
* This
, LPCITEMIDLIST pidlOld
, LPCITEMIDLIST pidlNew
)
621 TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This
, pidlOld
, pidlNew
);
623 nItem
= LV_FindItemByPidl(This
, ILFindLastID(pidlOld
));
626 lvItem
.mask
= LVIF_PARAM
; /* only the pidl */
627 lvItem
.iItem
= nItem
;
628 SendMessageW(This
->hWndList
, LVM_GETITEMW
, 0, (LPARAM
) &lvItem
);
630 SHFree((LPITEMIDLIST
)lvItem
.lParam
);
631 lvItem
.mask
= LVIF_PARAM
;
632 lvItem
.iItem
= nItem
;
633 lvItem
.lParam
= (LPARAM
) ILClone(ILFindLastID(pidlNew
)); /* set the item's data */
634 SendMessageW(This
->hWndList
, LVM_SETITEMW
, 0, (LPARAM
) &lvItem
);
635 SendMessageW(This
->hWndList
, LVM_UPDATE
, nItem
, 0);
636 return TRUE
; /* FIXME: better handling */
640 /**********************************************************
641 * ShellView_FillList()
643 * - gets the objectlist from the shellfolder
645 * - fills the list into the view
648 static INT CALLBACK
fill_list( LPVOID ptr
, LPVOID arg
)
650 LPITEMIDLIST pidl
= ptr
;
651 IShellViewImpl
*This
= arg
;
652 /* in a commdlg This works as a filemask*/
653 if ( IncludeObject(This
, pidl
)==S_OK
) LV_AddItem(This
, pidl
);
658 static HRESULT
ShellView_FillList(IShellViewImpl
*This
)
660 IShellFolderView
*folderview
= &This
->IShellFolderView_iface
;
661 LPENUMIDLIST pEnumIDList
;
667 TRACE("(%p)\n", This
);
669 /* get the itemlist from the shfolder*/
670 hr
= IShellFolder_EnumObjects(This
->pSFParent
, This
->hWnd
, SHCONTF_NONFOLDERS
| SHCONTF_FOLDERS
, &pEnumIDList
);
671 if (hr
!= S_OK
) return hr
;
673 /* create a pointer array */
674 hdpa
= DPA_Create(16);
677 IEnumIDList_Release(pEnumIDList
);
678 return E_OUTOFMEMORY
;
681 /* copy the items into the array*/
682 while((S_OK
== IEnumIDList_Next(pEnumIDList
, 1, &pidl
, &fetched
)) && fetched
)
684 if (DPA_InsertPtr(hdpa
, DPA_GetPtrCount(hdpa
), pidl
) == -1)
691 DPA_Sort(hdpa
, ShellView_CompareItems
, (LPARAM
)This
->pSFParent
);
693 IShellFolderView_SetRedraw(folderview
, FALSE
);
694 DPA_DestroyCallback(hdpa
, fill_list
, This
);
695 IShellFolderView_SetRedraw(folderview
, TRUE
);
697 IEnumIDList_Release(pEnumIDList
);
702 /**********************************************************
703 * ShellView_OnCreate()
705 static LRESULT
ShellView_OnCreate(IShellViewImpl
*This
)
707 IShellView2
*iface
= &This
->IShellView2_iface
;
708 static const WCHAR accel_nameW
[] = {'s','h','v','_','a','c','c','e','l',0};
709 IPersistFolder2
*ppf2
;
713 TRACE("(%p)\n", This
);
715 if (ShellView_CreateList(This
))
717 ShellView_InitList(This
);
718 ShellView_FillList(This
);
721 hr
= IShellView2_QueryInterface(iface
, &IID_IDropTarget
, (LPVOID
*)&pdt
);
724 RegisterDragDrop(This
->hWnd
, pdt
);
725 IDropTarget_Release(pdt
);
728 /* register for receiving notifications */
729 hr
= IShellFolder_QueryInterface(This
->pSFParent
, &IID_IPersistFolder2
, (LPVOID
*)&ppf2
);
732 LPITEMIDLIST raw_pidl
;
733 SHChangeNotifyEntry ntreg
;
735 hr
= IPersistFolder2_GetCurFolder(ppf2
, &raw_pidl
);
738 LPITEMIDLIST computer_pidl
;
739 SHGetFolderLocation(NULL
,CSIDL_DRIVES
,NULL
,0,&computer_pidl
);
740 if(ILIsParent(computer_pidl
,raw_pidl
,FALSE
))
742 /* Normalize the pidl to unixfs to workaround an issue with
743 * sending notifications on dos paths
745 WCHAR path
[MAX_PATH
];
746 SHGetPathFromIDListW(raw_pidl
,path
);
747 SHParseDisplayName(path
,NULL
,(LPITEMIDLIST
*)&ntreg
.pidl
,0,NULL
);
751 ntreg
.pidl
= raw_pidl
;
752 ntreg
.fRecursive
= TRUE
;
753 This
->hNotify
= SHChangeNotifyRegister(This
->hWnd
, SHCNRF_InterruptLevel
, SHCNE_ALLEVENTS
,
754 SHV_CHANGE_NOTIFY
, 1, &ntreg
);
755 SHFree((LPITEMIDLIST
)ntreg
.pidl
);
756 SHFree(computer_pidl
);
758 IPersistFolder2_Release(ppf2
);
761 This
->hAccel
= LoadAcceleratorsW(shell32_hInstance
, accel_nameW
);
766 /**********************************************************
767 * #### Handling of the menus ####
770 /**********************************************************
771 * ShellView_BuildFileMenu()
773 static HMENU
ShellView_BuildFileMenu(IShellViewImpl
* This
)
774 { WCHAR szText
[MAX_PATH
];
779 TRACE("(%p)\n",This
);
781 hSubMenu
= CreatePopupMenu();
783 { /*get the number of items in our global array*/
784 for(nTools
= 0; Tools
[nTools
].idCommand
!= -1; nTools
++){}
786 /*add the menu items*/
787 for(i
= 0; i
< nTools
; i
++)
789 LoadStringW(shell32_hInstance
, Tools
[i
].idMenuString
, szText
, MAX_PATH
);
791 ZeroMemory(&mii
, sizeof(mii
));
792 mii
.cbSize
= sizeof(mii
);
793 mii
.fMask
= MIIM_TYPE
| MIIM_ID
| MIIM_STATE
;
795 if(BTNS_SEP
!= Tools
[i
].bStyle
) /* no separator*/
797 mii
.fType
= MFT_STRING
;
798 mii
.fState
= MFS_ENABLED
;
799 mii
.dwTypeData
= szText
;
800 mii
.wID
= Tools
[i
].idCommand
;
804 mii
.fType
= MFT_SEPARATOR
;
806 /* tack This item onto the end of the menu */
807 InsertMenuItemW(hSubMenu
, (UINT
)-1, TRUE
, &mii
);
810 TRACE("-- return (menu=%p)\n",hSubMenu
);
813 /**********************************************************
814 * ShellView_MergeFileMenu()
816 static void ShellView_MergeFileMenu(IShellViewImpl
*This
, HMENU hSubMenu
)
818 TRACE("(%p)->(submenu=%p) stub\n",This
,hSubMenu
);
822 static const WCHAR dummyW
[] = {'d','u','m','m','y','4','5',0};
825 /* insert This item at the beginning of the menu */
827 mii
.cbSize
= sizeof(mii
);
828 mii
.fMask
= MIIM_ID
| MIIM_TYPE
;
830 mii
.fType
= MFT_SEPARATOR
;
831 InsertMenuItemW(hSubMenu
, 0, TRUE
, &mii
);
833 mii
.cbSize
= sizeof(mii
);
834 mii
.fMask
= MIIM_ID
| MIIM_TYPE
| MIIM_STATE
;
835 mii
.dwTypeData
= (LPWSTR
)dummyW
;
836 mii
.fState
= MFS_ENABLED
;
837 mii
.wID
= IDM_MYFILEITEM
;
838 mii
.fType
= MFT_STRING
;
839 InsertMenuItemW(hSubMenu
, 0, TRUE
, &mii
);
845 /**********************************************************
846 * ShellView_MergeViewMenu()
849 static void ShellView_MergeViewMenu(IShellViewImpl
*This
, HMENU hSubMenu
)
851 TRACE("(%p)->(submenu=%p)\n",This
,hSubMenu
);
853 /* add a separator at the correct position in the menu */
856 static const WCHAR menuW
[] = {'M','E','N','U','_','0','0','1',0};
857 static const WCHAR viewW
[] = {'V','i','e','w',0};
860 memset(&mii
, 0, sizeof(mii
));
861 mii
.cbSize
= sizeof(mii
);
862 mii
.fMask
= MIIM_ID
| MIIM_TYPE
;
864 mii
.fType
= MFT_SEPARATOR
;
865 InsertMenuItemW(hSubMenu
, FCIDM_MENU_VIEW_SEP_OPTIONS
, FALSE
, &mii
);
867 mii
.cbSize
= sizeof(mii
);
868 mii
.fMask
= MIIM_SUBMENU
| MIIM_TYPE
| MIIM_DATA
;
869 mii
.fType
= MFT_STRING
;
870 mii
.dwTypeData
= (LPWSTR
)viewW
;
871 mii
.hSubMenu
= LoadMenuW(shell32_hInstance
, menuW
);
872 InsertMenuItemW(hSubMenu
, FCIDM_MENU_VIEW_SEP_OPTIONS
, FALSE
, &mii
);
876 /**********************************************************
877 * ShellView_GetSelections()
879 * - fills the this->apidl list with the selected objects
882 * number of selected items
884 static UINT
ShellView_GetSelections(IShellViewImpl
* This
)
891 This
->cidl
= SendMessageW(This
->hWndList
, LVM_GETSELECTEDCOUNT
, 0, 0);
892 This
->apidl
= SHAlloc(This
->cidl
* sizeof(LPITEMIDLIST
));
894 TRACE("selected=%i\n", This
->cidl
);
898 TRACE("-- Items selected =%u\n", This
->cidl
);
900 lvItem
.mask
= LVIF_STATE
| LVIF_PARAM
;
901 lvItem
.stateMask
= LVIS_SELECTED
;
905 while(ListView_GetItemW(This
->hWndList
, &lvItem
) && (i
< This
->cidl
))
907 if(lvItem
.state
& LVIS_SELECTED
)
909 This
->apidl
[i
] = (LPITEMIDLIST
)lvItem
.lParam
;
911 TRACE("-- selected Item found\n");
920 /**********************************************************
921 * ShellView_OpenSelectedItems()
923 static HRESULT
ShellView_OpenSelectedItems(IShellViewImpl
* This
)
925 static UINT CF_IDLIST
= 0;
927 IDataObject
* selection
;
931 LPCITEMIDLIST parent_pidl
;
932 WCHAR parent_path
[MAX_PATH
];
933 LPCWSTR parent_dir
= NULL
;
937 if (0 == ShellView_GetSelections(This
))
941 hr
= IShellFolder_GetUIObjectOf(This
->pSFParent
, This
->hWnd
, This
->cidl
,
942 (LPCITEMIDLIST
*)This
->apidl
, &IID_IDataObject
,
943 0, (LPVOID
*)&selection
);
949 CF_IDLIST
= RegisterClipboardFormatW(CFSTR_SHELLIDLISTW
);
951 fetc
.cfFormat
= CF_IDLIST
;
953 fetc
.dwAspect
= DVASPECT_CONTENT
;
955 fetc
.tymed
= TYMED_HGLOBAL
;
957 hr
= IDataObject_QueryGetData(selection
, &fetc
);
961 hr
= IDataObject_GetData(selection
, &fetc
, &stgm
);
965 pIDList
= GlobalLock(stgm
.u
.hGlobal
);
967 parent_pidl
= (LPCITEMIDLIST
) ((LPBYTE
)pIDList
+pIDList
->aoffset
[0]);
968 hr
= IShellFolder_GetAttributesOf(This
->pSFParent
, 1, &parent_pidl
, &attribs
);
969 if (SUCCEEDED(hr
) && (attribs
& SFGAO_FILESYSTEM
) &&
970 SHGetPathFromIDListW(parent_pidl
, parent_path
))
972 parent_dir
= parent_path
;
975 for (i
= pIDList
->cidl
; i
> 0; --i
)
979 pidl
= (LPCITEMIDLIST
)((LPBYTE
)pIDList
+pIDList
->aoffset
[i
]);
981 attribs
= SFGAO_FOLDER
;
982 hr
= IShellFolder_GetAttributesOf(This
->pSFParent
, 1, &pidl
, &attribs
);
984 if (SUCCEEDED(hr
) && ! (attribs
& SFGAO_FOLDER
))
986 SHELLEXECUTEINFOW shexinfo
;
988 shexinfo
.cbSize
= sizeof(SHELLEXECUTEINFOW
);
989 shexinfo
.fMask
= SEE_MASK_INVOKEIDLIST
; /* SEE_MASK_IDLIST is also possible. */
990 shexinfo
.hwnd
= NULL
;
991 shexinfo
.lpVerb
= NULL
;
992 shexinfo
.lpFile
= NULL
;
993 shexinfo
.lpParameters
= NULL
;
994 shexinfo
.lpDirectory
= parent_dir
;
995 shexinfo
.nShow
= SW_NORMAL
;
996 shexinfo
.lpIDList
= ILCombine(parent_pidl
, pidl
);
998 ShellExecuteExW(&shexinfo
); /* Discard error/success info */
1000 ILFree(shexinfo
.lpIDList
);
1004 GlobalUnlock(stgm
.u
.hGlobal
);
1005 ReleaseStgMedium(&stgm
);
1007 IDataObject_Release(selection
);
1012 /**********************************************************
1013 * ShellView_DoContextMenu()
1015 static void ShellView_DoContextMenu(IShellViewImpl
* This
, WORD x
, WORD y
, BOOL bDefault
)
1019 BOOL fExplore
= FALSE
;
1021 LPCONTEXTMENU pContextMenu
= NULL
;
1022 CMINVOKECOMMANDINFO cmi
;
1024 TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This
, x
, y
, bDefault
);
1026 /* look, what's selected and create a context menu object of it*/
1027 if( ShellView_GetSelections(This
) )
1029 IShellFolder_GetUIObjectOf( This
->pSFParent
, This
->hWndParent
, This
->cidl
, (LPCITEMIDLIST
*)This
->apidl
,
1030 &IID_IContextMenu
, NULL
, (LPVOID
*)&pContextMenu
);
1034 TRACE("-- pContextMenu\n");
1035 hMenu
= CreatePopupMenu();
1039 /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
1040 if(SUCCEEDED(IShellBrowser_GetControlWindow(This
->pShellBrowser
,FCW_TREE
, &hwndTree
)) && hwndTree
)
1042 TRACE("-- explore mode\n");
1046 /* build the flags depending on what we can do with the selected item */
1047 wFlags
= CMF_NORMAL
| (This
->cidl
!= 1 ? 0 : CMF_CANRENAME
) | (fExplore
? CMF_EXPLORE
: 0);
1049 /* let the ContextMenu merge its items in */
1050 if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu
, hMenu
, 0, FCIDM_SHVIEWFIRST
, FCIDM_SHVIEWLAST
, wFlags
)))
1052 if (This
->FolderSettings
.fFlags
& FWF_DESKTOP
)
1053 SetMenuDefaultItem(hMenu
, FCIDM_SHVIEW_OPEN
, MF_BYCOMMAND
);
1057 TRACE("-- get menu default command\n");
1058 uCommand
= GetMenuDefaultItem(hMenu
, FALSE
, GMDI_GOINTOPOPUPS
);
1062 TRACE("-- track popup\n");
1063 uCommand
= TrackPopupMenu( hMenu
,TPM_LEFTALIGN
| TPM_RETURNCMD
,x
,y
,0,This
->hWnd
,NULL
);
1068 TRACE("-- uCommand=%u\n", uCommand
);
1069 if (uCommand
==FCIDM_SHVIEW_OPEN
&& IsInCommDlg(This
))
1071 TRACE("-- dlg: OnDefaultCommand\n");
1072 if (OnDefaultCommand(This
) != S_OK
)
1074 ShellView_OpenSelectedItems(This
);
1079 TRACE("-- explore -- invoke command\n");
1080 ZeroMemory(&cmi
, sizeof(cmi
));
1081 cmi
.cbSize
= sizeof(cmi
);
1082 cmi
.hwnd
= This
->hWndParent
; /* this window has to answer CWM_GETISHELLBROWSER */
1083 cmi
.lpVerb
= MAKEINTRESOURCEA(uCommand
);
1084 IContextMenu_InvokeCommand(pContextMenu
, &cmi
);
1091 IContextMenu_Release(pContextMenu
);
1094 else /* background context menu */
1098 hMenu
= CreatePopupMenu();
1100 BackgroundMenu_Constructor(This
->pSFParent
, FALSE
, &IID_IContextMenu2
, (void**)&pCM
);
1101 IContextMenu2_QueryContextMenu(pCM
, hMenu
, 0, FCIDM_SHVIEWFIRST
, FCIDM_SHVIEWLAST
, 0);
1103 uCommand
= TrackPopupMenu( hMenu
, TPM_LEFTALIGN
| TPM_RETURNCMD
,x
,y
,0,This
->hWnd
,NULL
);
1106 TRACE("-- (%p)->(uCommand=0x%08x )\n",This
, uCommand
);
1108 ZeroMemory(&cmi
, sizeof(cmi
));
1109 cmi
.cbSize
= sizeof(cmi
);
1110 cmi
.lpVerb
= MAKEINTRESOURCEA(uCommand
);
1111 cmi
.hwnd
= This
->hWndParent
;
1112 IContextMenu2_InvokeCommand(pCM
, &cmi
);
1114 IContextMenu2_Release(pCM
);
1118 /**********************************************************
1119 * ##### message handling #####
1122 /**********************************************************
1123 * ShellView_OnSize()
1125 static LRESULT
ShellView_OnSize(IShellViewImpl
* This
, WORD wWidth
, WORD wHeight
)
1127 TRACE("%p width=%u height=%u\n",This
, wWidth
,wHeight
);
1129 /*resize the ListView to fit our window*/
1132 MoveWindow(This
->hWndList
, 0, 0, wWidth
, wHeight
, TRUE
);
1137 /**********************************************************
1138 * ShellView_OnDeactivate()
1143 static void ShellView_OnDeactivate(IShellViewImpl
* This
)
1147 if(This
->uState
!= SVUIA_DEACTIVATE
)
1151 IShellBrowser_SetMenuSB(This
->pShellBrowser
,0, 0, 0);
1152 IShellBrowser_RemoveMenusSB(This
->pShellBrowser
,This
->hMenu
);
1153 DestroyMenu(This
->hMenu
);
1157 This
->uState
= SVUIA_DEACTIVATE
;
1161 /**********************************************************
1162 * ShellView_OnActivate()
1164 static LRESULT
ShellView_OnActivate(IShellViewImpl
*This
, UINT uState
)
1166 OLEMENUGROUPWIDTHS omw
= { {0, 0, 0, 0, 0, 0} };
1169 TRACE("(%p) uState=%x\n",This
,uState
);
1171 /* don't do anything if the state isn't really changing */
1172 if (This
->uState
== uState
) return S_OK
;
1174 ShellView_OnDeactivate(This
);
1176 /* only do This if we are active */
1177 if (uState
!= SVUIA_DEACTIVATE
)
1179 /* merge the menus */
1180 This
->hMenu
= CreateMenu();
1184 static const WCHAR dummyW
[] = {'d','u','m','m','y',' ','3','1',0};
1186 IShellBrowser_InsertMenusSB(This
->pShellBrowser
, This
->hMenu
, &omw
);
1187 TRACE("-- after fnInsertMenusSB\n");
1189 mii
.cbSize
= sizeof(mii
);
1190 mii
.fMask
= MIIM_SUBMENU
| MIIM_TYPE
| MIIM_STATE
;
1191 mii
.fType
= MFT_STRING
;
1192 mii
.fState
= MFS_ENABLED
;
1194 mii
.hSubMenu
= ShellView_BuildFileMenu(This
);
1195 mii
.hbmpChecked
= NULL
;
1196 mii
.hbmpUnchecked
= NULL
;
1198 /* build the top level menu get the menu item's text */
1199 mii
.dwTypeData
= (LPWSTR
)dummyW
;
1201 mii
.hbmpItem
= NULL
;
1203 /* insert our menu into the menu bar */
1205 InsertMenuItemW(This
->hMenu
, FCIDM_MENU_HELP
, FALSE
, &mii
);
1207 /* get the view menu so we can merge with it */
1208 memset(&mii
, 0, sizeof(mii
));
1209 mii
.cbSize
= sizeof(mii
);
1210 mii
.fMask
= MIIM_SUBMENU
;
1212 if (GetMenuItemInfoW(This
->hMenu
, FCIDM_MENU_VIEW
, FALSE
, &mii
))
1213 ShellView_MergeViewMenu(This
, mii
.hSubMenu
);
1215 /* add the items that should only be added if we have the focus */
1216 if (SVUIA_ACTIVATE_FOCUS
== uState
)
1218 /* get the file menu so we can merge with it */
1219 memset(&mii
, 0, sizeof(mii
));
1220 mii
.cbSize
= sizeof(mii
);
1221 mii
.fMask
= MIIM_SUBMENU
;
1223 if (GetMenuItemInfoW(This
->hMenu
, FCIDM_MENU_FILE
, FALSE
, &mii
))
1224 ShellView_MergeFileMenu(This
, mii
.hSubMenu
);
1227 TRACE("-- before fnSetMenuSB\n");
1228 IShellBrowser_SetMenuSB(This
->pShellBrowser
, This
->hMenu
, 0, This
->hWnd
);
1231 This
->uState
= uState
;
1236 /**********************************************************
1237 * ShellView_OnSetFocus()
1240 static LRESULT
ShellView_OnSetFocus(IShellViewImpl
* This
)
1244 /* Tell the browser one of our windows has received the focus. This
1245 should always be done before merging menus (OnActivate merges the
1246 menus) if one of our windows has the focus.*/
1248 IShellBrowser_OnViewWindowActive(This
->pShellBrowser
,(IShellView
*) This
);
1249 ShellView_OnActivate(This
, SVUIA_ACTIVATE_FOCUS
);
1251 /* Set the focus to the listview */
1252 SetFocus(This
->hWndList
);
1254 /* Notify the ICommDlgBrowser interface */
1255 OnStateChange(This
,CDBOSC_SETFOCUS
);
1260 /**********************************************************
1261 * ShellView_OnKillFocus()
1263 static LRESULT
ShellView_OnKillFocus(IShellViewImpl
* This
)
1265 TRACE("(%p) stub\n",This
);
1267 ShellView_OnActivate(This
, SVUIA_ACTIVATE_NOFOCUS
);
1268 /* Notify the ICommDlgBrowser */
1269 OnStateChange(This
,CDBOSC_KILLFOCUS
);
1274 /**********************************************************
1275 * ShellView_OnCommand()
1278 * the CmdIDs are the ones from the context menu
1280 static LRESULT
ShellView_OnCommand(IShellViewImpl
* This
,DWORD dwCmdID
, DWORD dwCmd
, HWND hwndCmd
)
1282 TRACE("(%p)->(0x%08x 0x%08x %p) stub\n",This
, dwCmdID
, dwCmd
, hwndCmd
);
1286 case FCIDM_SHVIEW_SMALLICON
:
1287 This
->FolderSettings
.ViewMode
= FVM_SMALLICON
;
1288 SetStyle (This
, LVS_SMALLICON
, LVS_TYPEMASK
);
1292 case FCIDM_SHVIEW_BIGICON
:
1293 This
->FolderSettings
.ViewMode
= FVM_ICON
;
1294 SetStyle (This
, LVS_ICON
, LVS_TYPEMASK
);
1298 case FCIDM_SHVIEW_LISTVIEW
:
1299 This
->FolderSettings
.ViewMode
= FVM_LIST
;
1300 SetStyle (This
, LVS_LIST
, LVS_TYPEMASK
);
1304 case FCIDM_SHVIEW_REPORTVIEW
:
1305 This
->FolderSettings
.ViewMode
= FVM_DETAILS
;
1306 SetStyle (This
, LVS_REPORT
, LVS_TYPEMASK
);
1310 /* the menu IDs for sorting are 0x30... see shell32.rc */
1315 This
->ListViewSortInfo
.nHeaderID
= dwCmdID
- 0x30;
1316 This
->ListViewSortInfo
.bIsAscending
= TRUE
;
1317 This
->ListViewSortInfo
.nLastHeaderID
= This
->ListViewSortInfo
.nHeaderID
;
1318 SendMessageW(This
->hWndList
, LVM_SORTITEMS
, (WPARAM
) &This
->ListViewSortInfo
, (LPARAM
)ShellView_ListViewCompareItems
);
1322 TRACE("-- COMMAND 0x%04x unhandled\n", dwCmdID
);
1327 /**********************************************************
1328 * ShellView_OnNotify()
1331 static LRESULT
ShellView_OnNotify(IShellViewImpl
* This
, UINT CtlID
, LPNMHDR lpnmh
)
1332 { LPNMLISTVIEW lpnmlv
= (LPNMLISTVIEW
)lpnmh
;
1333 NMLVDISPINFOW
*lpdi
= (NMLVDISPINFOW
*)lpnmh
;
1336 TRACE("%p CtlID=%u lpnmh->code=%x\n",This
,CtlID
,lpnmh
->code
);
1341 TRACE("-- NM_SETFOCUS %p\n",This
);
1342 ShellView_OnSetFocus(This
);
1346 TRACE("-- NM_KILLFOCUS %p\n",This
);
1347 ShellView_OnDeactivate(This
);
1348 /* Notify the ICommDlgBrowser interface */
1349 OnStateChange(This
,CDBOSC_KILLFOCUS
);
1353 TRACE("-- NM_CUSTOMDRAW %p\n",This
);
1354 return CDRF_DODEFAULT
;
1356 case NM_RELEASEDCAPTURE
:
1357 TRACE("-- NM_RELEASEDCAPTURE %p\n",This
);
1361 TRACE("-- NM_CLICK %p\n",This
);
1365 TRACE("-- NM_RCLICK %p\n",This
);
1369 TRACE("-- NM_DBLCLK %p\n",This
);
1370 if (OnDefaultCommand(This
) != S_OK
) ShellView_OpenSelectedItems(This
);
1374 TRACE("-- NM_RETURN %p\n",This
);
1375 if (OnDefaultCommand(This
) != S_OK
) ShellView_OpenSelectedItems(This
);
1379 TRACE("-- HDN_ENDTRACKW %p\n",This
);
1380 /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
1381 nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
1384 case LVN_DELETEITEM
:
1385 TRACE("-- LVN_DELETEITEM %p\n",This
);
1386 SHFree((LPITEMIDLIST
)lpnmlv
->lParam
); /*delete the pidl because we made a copy of it*/
1389 case LVN_DELETEALLITEMS
:
1390 TRACE("-- LVN_DELETEALLITEMS %p\n",This
);
1393 case LVN_INSERTITEM
:
1394 TRACE("-- LVN_INSERTITEM (STUB)%p\n",This
);
1397 case LVN_ITEMACTIVATE
:
1398 TRACE("-- LVN_ITEMACTIVATE %p\n",This
);
1399 OnStateChange(This
, CDBOSC_SELCHANGE
); /* the browser will get the IDataObject now */
1402 case LVN_COLUMNCLICK
:
1403 This
->ListViewSortInfo
.nHeaderID
= lpnmlv
->iSubItem
;
1404 if(This
->ListViewSortInfo
.nLastHeaderID
== This
->ListViewSortInfo
.nHeaderID
)
1406 This
->ListViewSortInfo
.bIsAscending
= !This
->ListViewSortInfo
.bIsAscending
;
1410 This
->ListViewSortInfo
.bIsAscending
= TRUE
;
1412 This
->ListViewSortInfo
.nLastHeaderID
= This
->ListViewSortInfo
.nHeaderID
;
1414 SendMessageW(lpnmlv
->hdr
.hwndFrom
, LVM_SORTITEMS
, (WPARAM
) &This
->ListViewSortInfo
, (LPARAM
)ShellView_ListViewCompareItems
);
1417 case LVN_GETDISPINFOA
:
1418 case LVN_GETDISPINFOW
:
1419 TRACE("-- LVN_GETDISPINFO %p\n",This
);
1420 pidl
= (LPITEMIDLIST
)lpdi
->item
.lParam
;
1422 if(lpdi
->item
.mask
& LVIF_TEXT
) /* text requested */
1424 static WCHAR emptyW
[] = { 0 };
1428 if (This
->pSF2Parent
)
1430 hr
= IShellFolder2_GetDetailsOf(This
->pSF2Parent
, pidl
, lpdi
->item
.iSubItem
, &sd
);
1434 IShellDetails
*details
;
1436 hr
= IShellFolder_QueryInterface(This
->pSFParent
, &IID_IShellDetails
, (void**)&details
);
1439 hr
= IShellDetails_GetDetailsOf(details
, pidl
, lpdi
->item
.iSubItem
, &sd
);
1440 IShellDetails_Release(details
);
1443 WARN("IShellFolder2/IShellDetails not supported\n");
1448 /* set to empty on failure */
1449 sd
.str
.uType
= STRRET_WSTR
;
1450 sd
.str
.u
.pOleStr
= emptyW
;
1453 if (lpnmh
->code
== LVN_GETDISPINFOW
)
1455 StrRetToStrNW( lpdi
->item
.pszText
, lpdi
->item
.cchTextMax
, &sd
.str
, NULL
);
1456 TRACE("-- text=%s\n", debugstr_w(lpdi
->item
.pszText
));
1460 /* LVN_GETDISPINFOA - shouldn't happen */
1461 NMLVDISPINFOA
*lpdiA
= (NMLVDISPINFOA
*)lpnmh
;
1462 StrRetToStrNA( lpdiA
->item
.pszText
, lpdiA
->item
.cchTextMax
, &sd
.str
, NULL
);
1463 TRACE("-- text=%s\n", lpdiA
->item
.pszText
);
1467 if(lpdi
->item
.mask
& LVIF_IMAGE
) /* image requested */
1469 lpdi
->item
.iImage
= SHMapPIDLToSystemImageListIndex(This
->pSFParent
, pidl
, 0);
1473 case LVN_ITEMCHANGED
:
1474 TRACE("-- LVN_ITEMCHANGED %p\n",This
);
1475 OnStateChange(This
, CDBOSC_SELCHANGE
); /* the browser will get the IDataObject now */
1479 case LVN_BEGINRDRAG
:
1480 TRACE("-- LVN_BEGINDRAG\n");
1482 if (ShellView_GetSelections(This
))
1485 DWORD dwAttributes
= SFGAO_CANLINK
;
1486 DWORD dwEffect
= DROPEFFECT_COPY
| DROPEFFECT_MOVE
;
1488 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This
->pSFParent
, This
->hWnd
, This
->cidl
, (LPCITEMIDLIST
*)This
->apidl
, &IID_IDataObject
,0,(LPVOID
*)&pda
)))
1490 IDropSource
*pds
= &This
->IDropSource_iface
; /* own DropSource interface */
1492 if (SUCCEEDED(IShellFolder_GetAttributesOf(This
->pSFParent
, This
->cidl
, (LPCITEMIDLIST
*)This
->apidl
, &dwAttributes
)))
1494 if (dwAttributes
& SFGAO_CANLINK
)
1496 dwEffect
|= DROPEFFECT_LINK
;
1503 DoDragDrop(pda
, pds
, dwEffect
, &dwEffect2
);
1505 IDataObject_Release(pda
);
1510 case LVN_BEGINLABELEDITW
:
1512 DWORD dwAttr
= SFGAO_CANRENAME
;
1513 pidl
= (LPITEMIDLIST
)lpdi
->item
.lParam
;
1515 TRACE("-- LVN_BEGINLABELEDITW %p\n",This
);
1517 IShellFolder_GetAttributesOf(This
->pSFParent
, 1, (LPCITEMIDLIST
*)&pidl
, &dwAttr
);
1518 if (SFGAO_CANRENAME
& dwAttr
)
1525 case LVN_ENDLABELEDITW
:
1527 TRACE("-- LVN_ENDLABELEDITA %p\n",This
);
1528 if (lpdi
->item
.pszText
)
1533 lvItem
.iItem
= lpdi
->item
.iItem
;
1534 lvItem
.iSubItem
= 0;
1535 lvItem
.mask
= LVIF_PARAM
;
1536 SendMessageW(This
->hWndList
, LVM_GETITEMW
, 0, (LPARAM
) &lvItem
);
1538 pidl
= (LPITEMIDLIST
)lpdi
->item
.lParam
;
1539 hr
= IShellFolder_SetNameOf(This
->pSFParent
, 0, pidl
, lpdi
->item
.pszText
, SHGDN_INFOLDER
, &pidl
);
1541 if(SUCCEEDED(hr
) && pidl
)
1543 lvItem
.mask
= LVIF_PARAM
;
1544 lvItem
.lParam
= (LPARAM
)pidl
;
1545 SendMessageW(This
->hWndList
, LVM_SETITEMW
, 0, (LPARAM
) &lvItem
);
1554 LPNMLVKEYDOWN plvKeyDown
= (LPNMLVKEYDOWN
) lpnmh
;
1556 /* initiate a rename of the selected file or directory */
1557 switch (plvKeyDown
->wVKey
)
1561 INT i
= SendMessageW(This
->hWndList
, LVM_GETSELECTEDCOUNT
, 0, 0);
1565 /* get selected item */
1566 i
= SendMessageW(This
->hWndList
, LVM_GETNEXTITEM
, -1, MAKELPARAM (LVNI_SELECTED
, 0));
1568 SendMessageW(This
->hWndList
, LVM_ENSUREVISIBLE
, i
, 0);
1569 SendMessageW(This
->hWndList
, LVM_EDITLABELW
, i
, 0);
1578 LPITEMIDLIST
* pItems
;
1582 hr
= IShellFolder_QueryInterface(This
->pSFParent
, &IID_ISFHelper
, (void**)&psfhlp
);
1583 if (hr
!= S_OK
) return 0;
1585 if(!(count
= SendMessageW(This
->hWndList
, LVM_GETSELECTEDCOUNT
, 0, 0)))
1587 ISFHelper_Release(psfhlp
);
1591 /* allocate memory for the pidl array */
1592 pItems
= HeapAlloc(GetProcessHeap(), 0, sizeof(LPITEMIDLIST
) * count
);
1594 /* retrieve all selected items */
1600 /* get selected item */
1601 item_index
= SendMessageW(This
->hWndList
, LVM_GETNEXTITEM
, item_index
,
1602 MAKELPARAM (LVNI_SELECTED
, 0));
1603 item
.iItem
= item_index
;
1604 item
.mask
= LVIF_PARAM
;
1605 SendMessageW(This
->hWndList
, LVM_GETITEMW
, 0, (LPARAM
)&item
);
1608 pItems
[i
] = (LPITEMIDLIST
)item
.lParam
;
1613 /* perform the item deletion */
1614 ISFHelper_DeleteItems(psfhlp
, i
, (LPCITEMIDLIST
*)pItems
);
1615 ISFHelper_Release(psfhlp
);
1617 /* free pidl array memory */
1618 HeapFree(GetProcessHeap(), 0, pItems
);
1623 /* Initiate a refresh */
1624 IShellView_Refresh((IShellView
*)This
);
1629 LPSHELLBROWSER lpSb
;
1630 if((lpSb
= (LPSHELLBROWSER
)SendMessageW(This
->hWndParent
, CWM_GETISHELLBROWSER
, 0, 0)))
1632 IShellBrowser_BrowseObject(lpSb
, NULL
, SBSP_PARENT
);
1638 FIXME("LVN_KEYDOWN key=0x%08x\n", plvKeyDown
->wVKey
);
1644 TRACE("-- %p WM_COMMAND %x unhandled\n", This
, lpnmh
->code
);
1650 /**********************************************************
1651 * ShellView_OnChange()
1654 static LRESULT
ShellView_OnChange(IShellViewImpl
* This
, const LPCITEMIDLIST
*pidls
, LONG event
)
1658 TRACE("(%p)->(%p, %p, 0x%08x)\n", This
, pidls
[0], pidls
[1], event
);
1664 LV_AddItem(This
, pidls
[0]);
1669 INT i
= LV_FindItemByPidl(This
, ILFindLastID(pidls
[0]));
1670 ret
= SendMessageW(This
->hWndList
, LVM_DELETEITEM
, i
, 0);
1673 case SHCNE_RENAMEFOLDER
:
1674 case SHCNE_RENAMEITEM
:
1675 LV_RenameItem(This
, pidls
[0], pidls
[1]);
1677 case SHCNE_UPDATEITEM
:
1682 /**********************************************************
1686 static LRESULT CALLBACK
ShellView_WndProc(HWND hWnd
, UINT uMessage
, WPARAM wParam
, LPARAM lParam
)
1688 IShellViewImpl
* pThis
= (IShellViewImpl
*)GetWindowLongPtrW(hWnd
, GWLP_USERDATA
);
1689 LPCREATESTRUCTW lpcs
;
1691 TRACE("(hwnd=%p msg=%x wparm=%lx lparm=%lx)\n",hWnd
, uMessage
, wParam
, lParam
);
1696 lpcs
= (LPCREATESTRUCTW
)lParam
;
1697 pThis
= lpcs
->lpCreateParams
;
1698 SetWindowLongPtrW(hWnd
, GWLP_USERDATA
, (ULONG_PTR
)pThis
);
1699 pThis
->hWnd
= hWnd
; /*set the window handle*/
1702 case WM_SIZE
: return ShellView_OnSize(pThis
,LOWORD(lParam
), HIWORD(lParam
));
1703 case WM_SETFOCUS
: return ShellView_OnSetFocus(pThis
);
1704 case WM_KILLFOCUS
: return ShellView_OnKillFocus(pThis
);
1705 case WM_CREATE
: return ShellView_OnCreate(pThis
);
1706 case WM_ACTIVATE
: return ShellView_OnActivate(pThis
, SVUIA_ACTIVATE_FOCUS
);
1707 case WM_NOTIFY
: return ShellView_OnNotify(pThis
,(UINT
)wParam
, (LPNMHDR
)lParam
);
1708 case WM_COMMAND
: return ShellView_OnCommand(pThis
,
1709 GET_WM_COMMAND_ID(wParam
, lParam
),
1710 GET_WM_COMMAND_CMD(wParam
, lParam
),
1711 GET_WM_COMMAND_HWND(wParam
, lParam
));
1712 case SHV_CHANGE_NOTIFY
: return ShellView_OnChange(pThis
, (const LPCITEMIDLIST
*)wParam
, (LONG
)lParam
);
1714 case WM_CONTEXTMENU
: ShellView_DoContextMenu(pThis
, LOWORD(lParam
), HIWORD(lParam
), FALSE
);
1717 case WM_SHOWWINDOW
: UpdateWindow(pThis
->hWndList
);
1720 case WM_GETDLGCODE
: return SendMessageW(pThis
->hWndList
, uMessage
, 0, 0);
1721 case WM_SETFONT
: return SendMessageW(pThis
->hWndList
, WM_SETFONT
, wParam
, lParam
);
1722 case WM_GETFONT
: return SendMessageW(pThis
->hWndList
, WM_GETFONT
, wParam
, lParam
);
1725 RevokeDragDrop(pThis
->hWnd
);
1726 SHChangeNotifyDeregister(pThis
->hNotify
);
1730 if ((pThis
->FolderSettings
.fFlags
& FWF_DESKTOP
) ||
1731 (pThis
->FolderSettings
.fFlags
& FWF_TRANSPARENT
))
1736 return DefWindowProcW(hWnd
, uMessage
, wParam
, lParam
);
1738 /**********************************************************
1741 * The INTERFACE of the IShellView object
1744 **********************************************************
1745 * IShellView_QueryInterface
1747 static HRESULT WINAPI
IShellView_fnQueryInterface(IShellView2
*iface
, REFIID riid
, void **ppvObj
)
1749 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
1751 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,debugstr_guid(riid
),ppvObj
);
1755 if(IsEqualIID(riid
, &IID_IUnknown
) ||
1756 IsEqualIID(riid
, &IID_IShellView
) ||
1757 IsEqualIID(riid
, &IID_IShellView2
))
1759 *ppvObj
= &This
->IShellView2_iface
;
1761 else if(IsEqualIID(riid
, &IID_IShellFolderView
))
1763 *ppvObj
= &This
->IShellFolderView_iface
;
1765 else if(IsEqualIID(riid
, &IID_IFolderView
))
1767 *ppvObj
= &This
->IFolderView_iface
;
1769 else if(IsEqualIID(riid
, &IID_IOleCommandTarget
))
1771 *ppvObj
= &This
->IOleCommandTarget_iface
;
1773 else if(IsEqualIID(riid
, &IID_IDropTarget
))
1775 *ppvObj
= &This
->IDropTarget_iface
;
1777 else if(IsEqualIID(riid
, &IID_IDropSource
))
1779 *ppvObj
= &This
->IDropSource_iface
;
1781 else if(IsEqualIID(riid
, &IID_IViewObject
))
1783 *ppvObj
= &This
->IViewObject_iface
;
1788 IUnknown_AddRef( (IUnknown
*)*ppvObj
);
1789 TRACE("-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
1792 TRACE("-- Interface: E_NOINTERFACE\n");
1793 return E_NOINTERFACE
;
1796 /**********************************************************
1799 static ULONG WINAPI
IShellView_fnAddRef(IShellView2
*iface
)
1801 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
1802 ULONG refCount
= InterlockedIncrement(&This
->ref
);
1804 TRACE("(%p)->(count=%u)\n", This
, refCount
- 1);
1808 /**********************************************************
1809 * IShellView_Release
1811 static ULONG WINAPI
IShellView_fnRelease(IShellView2
*iface
)
1813 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
1814 ULONG refCount
= InterlockedDecrement(&This
->ref
);
1816 TRACE("(%p)->(count=%i)\n", This
, refCount
+ 1);
1820 TRACE(" destroying IShellView(%p)\n",This
);
1822 DestroyWindow(This
->hWndList
);
1825 IShellFolder_Release(This
->pSFParent
);
1827 if(This
->pSF2Parent
)
1828 IShellFolder2_Release(This
->pSF2Parent
);
1830 SHFree(This
->apidl
);
1833 IAdviseSink_Release(This
->pAdvSink
);
1835 HeapFree(GetProcessHeap(),0,This
);
1840 /**********************************************************
1841 * ShellView_GetWindow
1843 static HRESULT WINAPI
IShellView_fnGetWindow(IShellView2
*iface
, HWND
*phWnd
)
1845 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
1847 TRACE("(%p)\n",This
);
1849 *phWnd
= This
->hWnd
;
1854 static HRESULT WINAPI
IShellView_fnContextSensitiveHelp(IShellView2
*iface
, BOOL mode
)
1856 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
1857 TRACE("(%p)->(%d)\n", This
, mode
);
1861 /**********************************************************
1862 * IShellView_TranslateAccelerator
1865 * use the accel functions
1867 static HRESULT WINAPI
IShellView_fnTranslateAccelerator(IShellView2
* iface
,LPMSG lpmsg
)
1870 IShellViewImpl
*This
= (IShellViewImpl
*)iface
;
1872 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%x wp=%x) stub\n",This
,lpmsg
, lpmsg
->hwnd
, lpmsg
->message
, lpmsg
->lParam
, lpmsg
->wParam
);
1875 if ((lpmsg
->message
>=WM_KEYFIRST
) && (lpmsg
->message
>=WM_KEYLAST
))
1877 TRACE("-- key=0x04%lx\n",lpmsg
->wParam
) ;
1879 return S_FALSE
; /* not handled */
1882 static HRESULT WINAPI
IShellView_fnEnableModeless(IShellView2
*iface
, BOOL fEnable
)
1884 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
1886 FIXME("(%p) stub\n",This
);
1891 static HRESULT WINAPI
IShellView_fnUIActivate(IShellView2
*iface
, UINT uState
)
1893 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
1896 CHAR szName[MAX_PATH];
1899 int nPartArray
[1] = {-1};
1901 TRACE("(%p)->(state=%x) stub\n",This
, uState
);
1903 /*don't do anything if the state isn't really changing*/
1904 if(This
->uState
== uState
)
1909 /*OnActivate handles the menu merging and internal state*/
1910 ShellView_OnActivate(This
, uState
);
1912 /*only do This if we are active*/
1913 if(uState
!= SVUIA_DEACTIVATE
)
1917 GetFolderPath is not a method of IShellFolder
1918 IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1920 /* set the number of parts */
1921 IShellBrowser_SendControlMsg(This
->pShellBrowser
, FCW_STATUS
, SB_SETPARTS
, 1,
1922 (LPARAM
)nPartArray
, &lResult
);
1924 /* set the text for the parts */
1926 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1927 0, (LPARAM)szName, &lResult);
1934 static HRESULT WINAPI
IShellView_fnRefresh(IShellView2
*iface
)
1936 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
1938 TRACE("(%p)\n", This
);
1940 SendMessageW(This
->hWndList
, LVM_DELETEALLITEMS
, 0, 0);
1941 ShellView_FillList(This
);
1946 static HRESULT WINAPI
IShellView_fnCreateViewWindow(IShellView2
*iface
, IShellView
*lpPrevView
,
1947 LPCFOLDERSETTINGS lpfs
, IShellBrowser
*psb
, RECT
*prcView
, HWND
*phWnd
)
1950 SV2CVW2_PARAMS view_params
;
1951 view_params
.cbSize
= sizeof(view_params
);
1952 view_params
.psvPrev
= lpPrevView
;
1953 view_params
.pfs
= lpfs
;
1954 view_params
.psbOwner
= psb
;
1955 view_params
.prcView
= prcView
;
1956 view_params
.pvid
= NULL
;
1957 view_params
.hwndView
= 0;
1959 TRACE("(%p) Forwarding to CreateViewWindow2\n", iface
);
1961 hr
= IShellView2_CreateViewWindow2(iface
, &view_params
);
1962 *phWnd
= view_params
.hwndView
;
1967 static HRESULT WINAPI
IShellView_fnDestroyViewWindow(IShellView2
*iface
)
1969 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
1971 TRACE("(%p)\n",This
);
1973 /*Make absolutely sure all our UI is cleaned up.*/
1974 IShellView_UIActivate((IShellView
*)This
, SVUIA_DEACTIVATE
);
1978 DestroyMenu(This
->hMenu
);
1981 DestroyWindow(This
->hWnd
);
1982 if(This
->pShellBrowser
) IShellBrowser_Release(This
->pShellBrowser
);
1983 if(This
->pCommDlgBrowser
) ICommDlgBrowser_Release(This
->pCommDlgBrowser
);
1989 static HRESULT WINAPI
IShellView_fnGetCurrentInfo(IShellView2
*iface
, LPFOLDERSETTINGS lpfs
)
1991 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
1993 TRACE("(%p)->(%p) vmode=%x flags=%x\n",This
, lpfs
,
1994 This
->FolderSettings
.ViewMode
, This
->FolderSettings
.fFlags
);
1996 if (!lpfs
) return E_INVALIDARG
;
1998 *lpfs
= This
->FolderSettings
;
2002 static HRESULT WINAPI
IShellView_fnAddPropertySheetPages(IShellView2
*iface
, DWORD dwReserved
,
2003 LPFNADDPROPSHEETPAGE lpfn
, LPARAM lparam
)
2005 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
2007 FIXME("(%p) stub\n",This
);
2012 static HRESULT WINAPI
IShellView_fnSaveViewState(IShellView2
*iface
)
2014 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
2016 FIXME("(%p) stub\n",This
);
2021 static HRESULT WINAPI
IShellView_fnSelectItem(IShellView2
*iface
, LPCITEMIDLIST pidl
, UINT flags
)
2023 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
2024 IFolderView
*view
= &This
->IFolderView_iface
;
2027 TRACE("(%p)->(pidl=%p, 0x%08x)\n",This
, pidl
, flags
);
2029 i
= LV_FindItemByPidl(This
, pidl
);
2030 if (i
== -1) return S_OK
;
2032 return IFolderView_SelectItem(view
, i
, flags
);
2035 static HRESULT WINAPI
IShellView_fnGetItemObject(IShellView2
*iface
, UINT uItem
, REFIID riid
,
2038 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
2039 HRESULT hr
= E_NOINTERFACE
;
2041 TRACE("(%p)->(0x%08x, %s, %p)\n",This
, uItem
, debugstr_guid(riid
), ppvOut
);
2047 case SVGIO_BACKGROUND
:
2049 if (IsEqualIID(&IID_IContextMenu
, riid
))
2050 return BackgroundMenu_Constructor(This
->pSFParent
, FALSE
, riid
, ppvOut
);
2052 FIXME("unsupported interface requested %s\n", debugstr_guid(riid
));
2056 case SVGIO_SELECTION
:
2057 ShellView_GetSelections(This
);
2058 hr
= IShellFolder_GetUIObjectOf(This
->pSFParent
, This
->hWnd
, This
->cidl
, (LPCITEMIDLIST
*)This
->apidl
, riid
, 0, ppvOut
);
2062 FIXME("unimplemented for uItem = 0x%08x\n", uItem
);
2064 TRACE("-- (%p)->(interface=%p)\n",This
, *ppvOut
);
2069 static HRESULT WINAPI
IShellView2_fnGetView(IShellView2
* iface
, SHELLVIEWID
*view_guid
, ULONG view_type
)
2071 FIXME("(%p)->(view_guid %s, view_type %#x) stub!\n", iface
, debugstr_guid(view_guid
), view_type
);
2075 static HRESULT WINAPI
IShellView2_fnCreateViewWindow2(IShellView2
*iface
,
2076 LPSV2CVW2_PARAMS view_params
)
2078 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
2079 INITCOMMONCONTROLSEX icex
;
2084 icex
.dwSize
= sizeof( icex
);
2085 icex
.dwICC
= ICC_LISTVIEW_CLASSES
;
2086 InitCommonControlsEx( &icex
);
2088 TRACE("(%p)->(view_params %p)\n", iface
, view_params
);
2090 if (view_params
->cbSize
!= sizeof(*view_params
))
2092 FIXME("Got unexpected cbSize %#x\n", view_params
->cbSize
);
2096 TRACE("-- psvPrev %p, pfs %p, psbOwner %p, prcView %p\n",
2097 view_params
->psvPrev
, view_params
->pfs
, view_params
->psbOwner
, view_params
->prcView
);
2098 TRACE("-- vmode %#x, flags %#x, view %s\n", view_params
->pfs
->ViewMode
, view_params
->pfs
->fFlags
, wine_dbgstr_rect(view_params
->prcView
));
2100 if (!view_params
->psbOwner
) return E_UNEXPECTED
;
2102 /* Set up the member variables */
2103 This
->pShellBrowser
= view_params
->psbOwner
;
2104 This
->FolderSettings
= *view_params
->pfs
;
2106 if (view_params
->pvid
)
2108 if (IsEqualGUID(view_params
->pvid
, &VID_LargeIcons
))
2109 This
->FolderSettings
.ViewMode
= FVM_ICON
;
2110 else if (IsEqualGUID(view_params
->pvid
, &VID_SmallIcons
))
2111 This
->FolderSettings
.ViewMode
= FVM_SMALLICON
;
2112 else if (IsEqualGUID(view_params
->pvid
, &VID_List
))
2113 This
->FolderSettings
.ViewMode
= FVM_LIST
;
2114 else if (IsEqualGUID(view_params
->pvid
, &VID_Details
))
2115 This
->FolderSettings
.ViewMode
= FVM_DETAILS
;
2116 else if (IsEqualGUID(view_params
->pvid
, &VID_Thumbnails
))
2117 This
->FolderSettings
.ViewMode
= FVM_THUMBNAIL
;
2118 else if (IsEqualGUID(view_params
->pvid
, &VID_Tile
))
2119 This
->FolderSettings
.ViewMode
= FVM_TILE
;
2120 else if (IsEqualGUID(view_params
->pvid
, &VID_ThumbStrip
))
2121 This
->FolderSettings
.ViewMode
= FVM_THUMBSTRIP
;
2123 FIXME("Ignoring unrecognized VID %s\n", debugstr_guid(view_params
->pvid
));
2126 /* Get our parent window */
2127 IShellBrowser_AddRef(This
->pShellBrowser
);
2128 IShellBrowser_GetWindow(This
->pShellBrowser
, &This
->hWndParent
);
2130 /* Try to get the ICommDlgBrowserInterface, adds a reference !!! */
2131 This
->pCommDlgBrowser
= NULL
;
2132 hr
= IShellBrowser_QueryInterface(This
->pShellBrowser
, &IID_ICommDlgBrowser
, (void **)&This
->pCommDlgBrowser
);
2134 TRACE("-- CommDlgBrowser %p\n", This
->pCommDlgBrowser
);
2136 /* If our window class has not been registered, then do so */
2137 if (!GetClassInfoW(shell32_hInstance
, SV_CLASS_NAME
, &wc
))
2139 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
2140 wc
.lpfnWndProc
= ShellView_WndProc
;
2143 wc
.hInstance
= shell32_hInstance
;
2145 wc
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
2146 wc
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
2147 wc
.lpszMenuName
= NULL
;
2148 wc
.lpszClassName
= SV_CLASS_NAME
;
2150 if (!RegisterClassW(&wc
)) return E_FAIL
;
2153 wnd
= CreateWindowExW(0, SV_CLASS_NAME
, NULL
, WS_CHILD
| WS_TABSTOP
,
2154 view_params
->prcView
->left
, view_params
->prcView
->top
,
2155 view_params
->prcView
->right
- view_params
->prcView
->left
,
2156 view_params
->prcView
->bottom
- view_params
->prcView
->top
,
2157 This
->hWndParent
, 0, shell32_hInstance
, This
);
2163 IShellBrowser_Release(This
->pShellBrowser
);
2167 SetWindowPos(wnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
| SWP_SHOWWINDOW
);
2170 view_params
->hwndView
= wnd
;
2175 static HRESULT WINAPI
IShellView2_fnHandleRename(IShellView2
* iface
, LPCITEMIDLIST new_pidl
)
2177 FIXME("(%p)->(new_pidl %p) stub!\n", iface
, new_pidl
);
2181 static HRESULT WINAPI
IShellView2_fnSelectAndPositionItem(IShellView2
*iface
, LPCITEMIDLIST item
,
2182 UINT flags
, POINT
*point
)
2184 IShellViewImpl
*This
= impl_from_IShellView2(iface
);
2188 TRACE("(%p)->(item %p, flags %#x, point %p)\n", This
, item
, flags
, point
);
2190 hr
= IShellView2_QueryInterface(iface
, &IID_IFolderView
, (void**)&view
);
2193 hr
= IFolderView_SelectAndPositionItems(view
, 1, &item
, point
, flags
);
2194 IFolderView_Release(view
);
2200 static const IShellView2Vtbl svvt
=
2202 IShellView_fnQueryInterface
,
2203 IShellView_fnAddRef
,
2204 IShellView_fnRelease
,
2205 IShellView_fnGetWindow
,
2206 IShellView_fnContextSensitiveHelp
,
2207 IShellView_fnTranslateAccelerator
,
2208 IShellView_fnEnableModeless
,
2209 IShellView_fnUIActivate
,
2210 IShellView_fnRefresh
,
2211 IShellView_fnCreateViewWindow
,
2212 IShellView_fnDestroyViewWindow
,
2213 IShellView_fnGetCurrentInfo
,
2214 IShellView_fnAddPropertySheetPages
,
2215 IShellView_fnSaveViewState
,
2216 IShellView_fnSelectItem
,
2217 IShellView_fnGetItemObject
,
2218 IShellView2_fnGetView
,
2219 IShellView2_fnCreateViewWindow2
,
2220 IShellView2_fnHandleRename
,
2221 IShellView2_fnSelectAndPositionItem
,
2225 /**********************************************************
2226 * ISVOleCmdTarget_QueryInterface (IUnknown)
2228 static HRESULT WINAPI
ISVOleCmdTarget_QueryInterface(
2229 IOleCommandTarget
* iface
,
2233 IShellViewImpl
*This
= impl_from_IOleCommandTarget(iface
);
2235 return IShellView2_QueryInterface(&This
->IShellView2_iface
, iid
, ppvObj
);
2238 /**********************************************************
2239 * ISVOleCmdTarget_AddRef (IUnknown)
2241 static ULONG WINAPI
ISVOleCmdTarget_AddRef(
2242 IOleCommandTarget
* iface
)
2244 IShellViewImpl
*This
= impl_from_IOleCommandTarget(iface
);
2246 return IShellView2_AddRef(&This
->IShellView2_iface
);
2249 /**********************************************************
2250 * ISVOleCmdTarget_Release (IUnknown)
2252 static ULONG WINAPI
ISVOleCmdTarget_Release(
2253 IOleCommandTarget
* iface
)
2255 IShellViewImpl
*This
= impl_from_IOleCommandTarget(iface
);
2257 return IShellView2_Release(&This
->IShellView2_iface
);
2260 /**********************************************************
2261 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
2263 static HRESULT WINAPI
ISVOleCmdTarget_QueryStatus(
2264 IOleCommandTarget
*iface
,
2265 const GUID
*pguidCmdGroup
,
2268 OLECMDTEXT
*pCmdText
)
2270 IShellViewImpl
*This
= impl_from_IOleCommandTarget(iface
);
2273 FIXME("(%p)->(%s %d %p %p)\n",
2274 This
, debugstr_guid(pguidCmdGroup
), cCmds
, prgCmds
, pCmdText
);
2277 return E_INVALIDARG
;
2278 for (i
= 0; i
< cCmds
; i
++)
2280 FIXME("\tprgCmds[%d].cmdID = %d\n", i
, prgCmds
[i
].cmdID
);
2281 prgCmds
[i
].cmdf
= 0;
2283 return OLECMDERR_E_UNKNOWNGROUP
;
2286 /**********************************************************
2287 * ISVOleCmdTarget_Exec (IOleCommandTarget)
2289 * nCmdID is the OLECMDID_* enumeration
2291 static HRESULT WINAPI
ISVOleCmdTarget_Exec(
2292 IOleCommandTarget
*iface
,
2293 const GUID
* pguidCmdGroup
,
2299 IShellViewImpl
*This
= impl_from_IOleCommandTarget(iface
);
2301 FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08x Opt:0x%08x %p %p)\n",
2302 This
, debugstr_guid(pguidCmdGroup
), nCmdID
, nCmdexecopt
, pvaIn
, pvaOut
);
2305 return OLECMDERR_E_UNKNOWNGROUP
;
2306 if (IsEqualIID(pguidCmdGroup
, &CGID_Explorer
) &&
2308 (nCmdexecopt
== 4) && pvaOut
)
2310 if (IsEqualIID(pguidCmdGroup
, &CGID_ShellDocView
) &&
2315 return OLECMDERR_E_UNKNOWNGROUP
;
2318 static const IOleCommandTargetVtbl ctvt
=
2320 ISVOleCmdTarget_QueryInterface
,
2321 ISVOleCmdTarget_AddRef
,
2322 ISVOleCmdTarget_Release
,
2323 ISVOleCmdTarget_QueryStatus
,
2324 ISVOleCmdTarget_Exec
2327 /**********************************************************
2328 * ISVDropTarget implementation
2331 static HRESULT WINAPI
ISVDropTarget_QueryInterface(
2336 IShellViewImpl
*This
= impl_from_IDropTarget(iface
);
2338 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,debugstr_guid(riid
),ppvObj
);
2340 return IShellView2_QueryInterface(&This
->IShellView2_iface
, riid
, ppvObj
);
2343 static ULONG WINAPI
ISVDropTarget_AddRef( IDropTarget
*iface
)
2345 IShellViewImpl
*This
= impl_from_IDropTarget(iface
);
2347 TRACE("(%p)->(count=%u)\n",This
,This
->ref
);
2349 return IShellView2_AddRef(&This
->IShellView2_iface
);
2352 static ULONG WINAPI
ISVDropTarget_Release( IDropTarget
*iface
)
2354 IShellViewImpl
*This
= impl_from_IDropTarget(iface
);
2356 TRACE("(%p)->(count=%u)\n",This
,This
->ref
);
2358 return IShellView2_Release(&This
->IShellView2_iface
);
2361 /******************************************************************************
2362 * drag_notify_subitem [Internal]
2364 * Figure out the shellfolder object, which is currently under the mouse cursor
2365 * and notify it via the IDropTarget interface.
2368 #define SCROLLAREAWIDTH 20
2370 static HRESULT
drag_notify_subitem(IShellViewImpl
*This
, DWORD grfKeyState
, POINTL pt
,
2373 LVHITTESTINFO htinfo
;
2379 /* Map from global to client coordinates and query the index of the listview-item, which is
2380 * currently under the mouse cursor. */
2383 htinfo
.flags
= LVHT_ONITEM
;
2384 ScreenToClient(This
->hWndList
, &htinfo
.pt
);
2385 lResult
= SendMessageW(This
->hWndList
, LVM_HITTEST
, 0, (LPARAM
)&htinfo
);
2387 /* Send WM_*SCROLL messages every 250 ms during drag-scrolling */
2388 GetClientRect(This
->hWndList
, &clientRect
);
2389 if (htinfo
.pt
.x
== This
->ptLastMousePos
.x
&& htinfo
.pt
.y
== This
->ptLastMousePos
.y
&&
2390 (htinfo
.pt
.x
< SCROLLAREAWIDTH
|| htinfo
.pt
.x
> clientRect
.right
- SCROLLAREAWIDTH
||
2391 htinfo
.pt
.y
< SCROLLAREAWIDTH
|| htinfo
.pt
.y
> clientRect
.bottom
- SCROLLAREAWIDTH
))
2393 This
->cScrollDelay
= (This
->cScrollDelay
+ 1) % 5; /* DragOver is called every 50 ms */
2394 if (This
->cScrollDelay
== 0) { /* Mouse did hover another 250 ms over the scroll-area */
2395 if (htinfo
.pt
.x
< SCROLLAREAWIDTH
)
2396 SendMessageW(This
->hWndList
, WM_HSCROLL
, SB_LINEUP
, 0);
2397 if (htinfo
.pt
.x
> clientRect
.right
- SCROLLAREAWIDTH
)
2398 SendMessageW(This
->hWndList
, WM_HSCROLL
, SB_LINEDOWN
, 0);
2399 if (htinfo
.pt
.y
< SCROLLAREAWIDTH
)
2400 SendMessageW(This
->hWndList
, WM_VSCROLL
, SB_LINEUP
, 0);
2401 if (htinfo
.pt
.y
> clientRect
.bottom
- SCROLLAREAWIDTH
)
2402 SendMessageW(This
->hWndList
, WM_VSCROLL
, SB_LINEDOWN
, 0);
2405 This
->cScrollDelay
= 0; /* Reset, if the cursor is not over the listview's scroll-area */
2407 This
->ptLastMousePos
= htinfo
.pt
;
2409 /* If we are still over the previous sub-item, notify it via DragOver and return. */
2410 if (This
->pCurDropTarget
&& lResult
== This
->iDragOverItem
)
2411 return IDropTarget_DragOver(This
->pCurDropTarget
, grfKeyState
, pt
, pdwEffect
);
2413 /* We've left the previous sub-item, notify it via DragLeave and Release it. */
2414 if (This
->pCurDropTarget
) {
2415 IDropTarget_DragLeave(This
->pCurDropTarget
);
2416 IDropTarget_Release(This
->pCurDropTarget
);
2417 This
->pCurDropTarget
= NULL
;
2420 This
->iDragOverItem
= lResult
;
2421 if (lResult
== -1) {
2422 /* We are not above one of the listview's subitems. Bind to the parent folder's
2423 * DropTarget interface. */
2424 hr
= IShellFolder_QueryInterface(This
->pSFParent
, &IID_IDropTarget
,
2425 (LPVOID
*)&This
->pCurDropTarget
);
2427 /* Query the relative PIDL of the shellfolder object represented by the currently
2428 * dragged over listview-item ... */
2429 lvItem
.mask
= LVIF_PARAM
;
2430 lvItem
.iItem
= lResult
;
2431 lvItem
.iSubItem
= 0;
2432 SendMessageW(This
->hWndList
, LVM_GETITEMW
, 0, (LPARAM
) &lvItem
);
2434 /* ... and bind pCurDropTarget to the IDropTarget interface of an UIObject of this object */
2435 hr
= IShellFolder_GetUIObjectOf(This
->pSFParent
, This
->hWndList
, 1,
2436 (LPCITEMIDLIST
*)&lvItem
.lParam
, &IID_IDropTarget
, NULL
, (LPVOID
*)&This
->pCurDropTarget
);
2439 /* If anything failed, pCurDropTarget should be NULL now, which ought to be a save state. */
2443 /* Notify the item just entered via DragEnter. */
2444 return IDropTarget_DragEnter(This
->pCurDropTarget
, This
->pCurDataObject
, grfKeyState
, pt
, pdwEffect
);
2447 static HRESULT WINAPI
ISVDropTarget_DragEnter(IDropTarget
*iface
, IDataObject
*pDataObject
,
2448 DWORD grfKeyState
, POINTL pt
, DWORD
*pdwEffect
)
2450 IShellViewImpl
*This
= impl_from_IDropTarget(iface
);
2452 /* Get a hold on the data object for later calls to DragEnter on the sub-folders */
2453 This
->pCurDataObject
= pDataObject
;
2454 IDataObject_AddRef(pDataObject
);
2456 return drag_notify_subitem(This
, grfKeyState
, pt
, pdwEffect
);
2459 static HRESULT WINAPI
ISVDropTarget_DragOver(IDropTarget
*iface
, DWORD grfKeyState
, POINTL pt
,
2462 IShellViewImpl
*This
= impl_from_IDropTarget(iface
);
2463 return drag_notify_subitem(This
, grfKeyState
, pt
, pdwEffect
);
2466 static HRESULT WINAPI
ISVDropTarget_DragLeave(IDropTarget
*iface
)
2468 IShellViewImpl
*This
= impl_from_IDropTarget(iface
);
2470 if (This
->pCurDropTarget
)
2472 IDropTarget_DragLeave(This
->pCurDropTarget
);
2473 IDropTarget_Release(This
->pCurDropTarget
);
2474 This
->pCurDropTarget
= NULL
;
2477 if (This
->pCurDataObject
)
2479 IDataObject_Release(This
->pCurDataObject
);
2480 This
->pCurDataObject
= NULL
;
2483 This
->iDragOverItem
= 0;
2488 static HRESULT WINAPI
ISVDropTarget_Drop(IDropTarget
*iface
, IDataObject
* pDataObject
,
2489 DWORD grfKeyState
, POINTL pt
, DWORD
*pdwEffect
)
2491 IShellViewImpl
*This
= impl_from_IDropTarget(iface
);
2493 if (!This
->pCurDropTarget
) return DRAGDROP_E_INVALIDHWND
;
2495 IDropTarget_Drop(This
->pCurDropTarget
, pDataObject
, grfKeyState
, pt
, pdwEffect
);
2497 IDropTarget_Release(This
->pCurDropTarget
);
2498 IDataObject_Release(This
->pCurDataObject
);
2499 This
->pCurDataObject
= NULL
;
2500 This
->pCurDropTarget
= NULL
;
2501 This
->iDragOverItem
= 0;
2506 static const IDropTargetVtbl dtvt
=
2508 ISVDropTarget_QueryInterface
,
2509 ISVDropTarget_AddRef
,
2510 ISVDropTarget_Release
,
2511 ISVDropTarget_DragEnter
,
2512 ISVDropTarget_DragOver
,
2513 ISVDropTarget_DragLeave
,
2517 /**********************************************************
2518 * ISVDropSource implementation
2521 static HRESULT WINAPI
ISVDropSource_QueryInterface(
2526 IShellViewImpl
*This
= impl_from_IDropSource(iface
);
2528 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,debugstr_guid(riid
),ppvObj
);
2530 return IShellView2_QueryInterface(&This
->IShellView2_iface
, riid
, ppvObj
);
2533 static ULONG WINAPI
ISVDropSource_AddRef( IDropSource
*iface
)
2535 IShellViewImpl
*This
= impl_from_IDropSource(iface
);
2537 TRACE("(%p)->(count=%u)\n",This
,This
->ref
);
2539 return IShellView2_AddRef(&This
->IShellView2_iface
);
2542 static ULONG WINAPI
ISVDropSource_Release( IDropSource
*iface
)
2544 IShellViewImpl
*This
= impl_from_IDropSource(iface
);
2546 TRACE("(%p)->(count=%u)\n",This
,This
->ref
);
2548 return IShellView2_Release(&This
->IShellView2_iface
);
2551 static HRESULT WINAPI
ISVDropSource_QueryContinueDrag(
2553 BOOL fEscapePressed
,
2556 IShellViewImpl
*This
= impl_from_IDropSource(iface
);
2557 TRACE("(%p)\n",This
);
2560 return DRAGDROP_S_CANCEL
;
2561 else if (!(grfKeyState
& MK_LBUTTON
) && !(grfKeyState
& MK_RBUTTON
))
2562 return DRAGDROP_S_DROP
;
2567 static HRESULT WINAPI
ISVDropSource_GiveFeedback(
2571 IShellViewImpl
*This
= impl_from_IDropSource(iface
);
2572 TRACE("(%p)\n",This
);
2574 return DRAGDROP_S_USEDEFAULTCURSORS
;
2577 static const IDropSourceVtbl dsvt
=
2579 ISVDropSource_QueryInterface
,
2580 ISVDropSource_AddRef
,
2581 ISVDropSource_Release
,
2582 ISVDropSource_QueryContinueDrag
,
2583 ISVDropSource_GiveFeedback
2585 /**********************************************************
2586 * ISVViewObject implementation
2589 static HRESULT WINAPI
ISVViewObject_QueryInterface(
2594 IShellViewImpl
*This
= impl_from_IViewObject(iface
);
2596 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,debugstr_guid(riid
),ppvObj
);
2598 return IShellView2_QueryInterface(&This
->IShellView2_iface
, riid
, ppvObj
);
2601 static ULONG WINAPI
ISVViewObject_AddRef( IViewObject
*iface
)
2603 IShellViewImpl
*This
= impl_from_IViewObject(iface
);
2605 TRACE("(%p)->(count=%u)\n",This
,This
->ref
);
2607 return IShellView2_AddRef(&This
->IShellView2_iface
);
2610 static ULONG WINAPI
ISVViewObject_Release( IViewObject
*iface
)
2612 IShellViewImpl
*This
= impl_from_IViewObject(iface
);
2614 TRACE("(%p)->(count=%u)\n",This
,This
->ref
);
2616 return IShellView2_Release(&This
->IShellView2_iface
);
2619 static HRESULT WINAPI
ISVViewObject_Draw(
2624 DVTARGETDEVICE
* ptd
,
2627 LPCRECTL lprcBounds
,
2628 LPCRECTL lprcWBounds
,
2629 BOOL (CALLBACK
*pfnContinue
)(ULONG_PTR dwContinue
),
2630 ULONG_PTR dwContinue
)
2633 IShellViewImpl
*This
= impl_from_IViewObject(iface
);
2635 FIXME("Stub: This=%p\n",This
);
2639 static HRESULT WINAPI
ISVViewObject_GetColorSet(
2644 DVTARGETDEVICE
* ptd
,
2645 HDC hicTargetDevice
,
2646 LOGPALETTE
** ppColorSet
)
2649 IShellViewImpl
*This
= impl_from_IViewObject(iface
);
2651 FIXME("Stub: This=%p\n",This
);
2655 static HRESULT WINAPI
ISVViewObject_Freeze(
2663 IShellViewImpl
*This
= impl_from_IViewObject(iface
);
2665 FIXME("Stub: This=%p\n",This
);
2669 static HRESULT WINAPI
ISVViewObject_Unfreeze(
2674 IShellViewImpl
*This
= impl_from_IViewObject(iface
);
2676 FIXME("Stub: This=%p\n",This
);
2680 static HRESULT WINAPI
ISVViewObject_SetAdvise(
2684 IAdviseSink
* pAdvSink
)
2687 IShellViewImpl
*This
= impl_from_IViewObject(iface
);
2689 FIXME("partial stub: %p %08x %08x %p\n",
2690 This
, aspects
, advf
, pAdvSink
);
2692 /* FIXME: we set the AdviseSink, but never use it to send any advice */
2693 This
->pAdvSink
= pAdvSink
;
2694 This
->dwAspects
= aspects
;
2695 This
->dwAdvf
= advf
;
2700 static HRESULT WINAPI
ISVViewObject_GetAdvise(
2704 IAdviseSink
** ppAdvSink
)
2707 IShellViewImpl
*This
= impl_from_IViewObject(iface
);
2709 TRACE("This=%p pAspects=%p pAdvf=%p ppAdvSink=%p\n",
2710 This
, pAspects
, pAdvf
, ppAdvSink
);
2714 IAdviseSink_AddRef( This
->pAdvSink
);
2715 *ppAdvSink
= This
->pAdvSink
;
2718 *pAspects
= This
->dwAspects
;
2720 *pAdvf
= This
->dwAdvf
;
2726 static const IViewObjectVtbl vovt
=
2728 ISVViewObject_QueryInterface
,
2729 ISVViewObject_AddRef
,
2730 ISVViewObject_Release
,
2732 ISVViewObject_GetColorSet
,
2733 ISVViewObject_Freeze
,
2734 ISVViewObject_Unfreeze
,
2735 ISVViewObject_SetAdvise
,
2736 ISVViewObject_GetAdvise
2740 static HRESULT WINAPI
IFView_QueryInterface(
2745 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2746 TRACE("(%p)->(IID:%s,%p)\n", This
, debugstr_guid(riid
), ppvObj
);
2747 return IShellView2_QueryInterface(&This
->IShellView2_iface
, riid
, ppvObj
);
2750 static ULONG WINAPI
IFView_AddRef( IFolderView
*iface
)
2752 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2753 TRACE("(%p)->(count=%u)\n", This
, This
->ref
);
2754 return IShellView2_AddRef(&This
->IShellView2_iface
);
2757 static ULONG WINAPI
IFView_Release( IFolderView
*iface
)
2759 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2760 TRACE("(%p)->(count=%u)\n", This
, This
->ref
);
2761 return IShellView2_Release(&This
->IShellView2_iface
);
2764 static HRESULT WINAPI
IFView_GetCurrentViewMode(IFolderView
*iface
, UINT
*mode
)
2766 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2767 TRACE("(%p)->(%p), stub\n", This
, mode
);
2770 return E_INVALIDARG
;
2772 *mode
= This
->FolderSettings
.ViewMode
;
2776 static HRESULT WINAPI
IFView_SetCurrentViewMode(IFolderView
*iface
, UINT mode
)
2778 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2780 TRACE("(%p)->(%u), stub\n", This
, mode
);
2782 if((mode
< FVM_FIRST
|| mode
> FVM_LAST
) &&
2784 return E_INVALIDARG
;
2786 /* Windows before Vista uses LVM_SETVIEW and possibly
2787 LVM_SETEXTENDEDLISTVIEWSTYLE to set the style of the listview,
2788 while later versions seem to accomplish this through other
2790 dwStyle
= ViewModeToListStyle(mode
);
2791 SetStyle(This
, dwStyle
, LVS_TYPEMASK
);
2793 /* This will not necessarily be the actual mode set above.
2794 This mimics the behavior of Windows XP. */
2795 This
->FolderSettings
.ViewMode
= mode
;
2800 static HRESULT WINAPI
IFView_GetFolder(IFolderView
*iface
, REFIID riid
, void **ppv
)
2802 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2804 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppv
);
2806 if (!ppv
) return E_POINTER
;
2808 if (IsEqualIID(riid
, &IID_IShellFolder
))
2810 *ppv
= This
->pSFParent
;
2814 return E_NOINTERFACE
;
2817 static HRESULT WINAPI
IFView_Item(IFolderView
*iface
, int index
, PITEMID_CHILD
*ppidl
)
2819 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2822 TRACE("(%p)->(%d %p)\n", This
, index
, ppidl
);
2824 item
.mask
= LVIF_PARAM
;
2827 if (SendMessageW(This
->hWndList
, LVM_GETITEMW
, 0, (LPARAM
)&item
))
2829 *ppidl
= ILClone((PITEMID_CHILD
)item
.lParam
);
2835 return E_INVALIDARG
;
2839 static HRESULT WINAPI
IFView_ItemCount(IFolderView
*iface
, UINT flags
, int *items
)
2841 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2843 TRACE("(%p)->(%u %p)\n", This
, flags
, items
);
2845 if (flags
!= SVGIO_ALLVIEW
)
2846 FIXME("some flags unsupported, %x\n", flags
& ~SVGIO_ALLVIEW
);
2848 *items
= SendMessageW(This
->hWndList
, LVM_GETITEMCOUNT
, 0, 0);
2853 static HRESULT WINAPI
IFView_Items(IFolderView
*iface
, UINT flags
, REFIID riid
, void **ppv
)
2855 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2856 FIXME("(%p)->(%u %s %p), stub\n", This
, flags
, debugstr_guid(riid
), ppv
);
2860 static HRESULT WINAPI
IFView_GetSelectionMarkedItem(IFolderView
*iface
, int *item
)
2862 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2864 TRACE("(%p)->(%p)\n", This
, item
);
2866 *item
= SendMessageW(This
->hWndList
, LVM_GETSELECTIONMARK
, 0, 0);
2871 static HRESULT WINAPI
IFView_GetFocusedItem(IFolderView
*iface
, int *item
)
2873 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2875 TRACE("(%p)->(%p)\n", This
, item
);
2877 *item
= SendMessageW(This
->hWndList
, LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
);
2882 static HRESULT WINAPI
IFView_GetItemPosition(IFolderView
*iface
, PCUITEMID_CHILD pidl
, POINT
*ppt
)
2884 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2885 FIXME("(%p)->(%p %p), stub\n", This
, pidl
, ppt
);
2889 static HRESULT WINAPI
IFView_GetSpacing(IFolderView
*iface
, POINT
*pt
)
2891 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2893 TRACE("(%p)->(%p)\n", This
, pt
);
2895 if (!This
->hWndList
) return S_FALSE
;
2900 ret
= SendMessageW(This
->hWndList
, LVM_GETITEMSPACING
, 0, 0);
2902 pt
->x
= LOWORD(ret
);
2903 pt
->y
= HIWORD(ret
);
2909 static HRESULT WINAPI
IFView_GetDefaultSpacing(IFolderView
*iface
, POINT
*pt
)
2911 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2912 FIXME("(%p)->(%p), stub\n", This
, pt
);
2916 static HRESULT WINAPI
IFView_GetAutoArrange(IFolderView
*iface
)
2918 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2919 FIXME("(%p), stub\n", This
);
2923 static HRESULT WINAPI
IFView_SelectItem(IFolderView
*iface
, int item
, DWORD flags
)
2925 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2928 TRACE("(%p)->(%d, %x)\n", This
, item
, flags
);
2931 lvItem
.stateMask
= LVIS_SELECTED
;
2933 if (flags
& SVSI_ENSUREVISIBLE
)
2934 SendMessageW(This
->hWndList
, LVM_ENSUREVISIBLE
, item
, 0);
2937 if (flags
& SVSI_DESELECTOTHERS
)
2938 SendMessageW(This
->hWndList
, LVM_SETITEMSTATE
, -1, (LPARAM
)&lvItem
);
2941 if (flags
& SVSI_SELECT
)
2942 lvItem
.state
|= LVIS_SELECTED
;
2944 if (flags
& SVSI_FOCUSED
)
2945 lvItem
.stateMask
|= LVIS_FOCUSED
;
2947 SendMessageW(This
->hWndList
, LVM_SETITEMSTATE
, item
, (LPARAM
)&lvItem
);
2949 if (flags
& SVSI_EDIT
)
2950 SendMessageW(This
->hWndList
, LVM_EDITLABELW
, item
, 0);
2955 static HRESULT WINAPI
IFView_SelectAndPositionItems(IFolderView
*iface
, UINT cidl
,
2956 PCUITEMID_CHILD_ARRAY apidl
, POINT
*apt
, DWORD flags
)
2958 IShellViewImpl
*This
= impl_from_IFolderView(iface
);
2959 FIXME("(%p)->(%u %p %p %x), stub\n", This
, cidl
, apidl
, apt
, flags
);
2963 static const IFolderViewVtbl fviewvt
=
2965 IFView_QueryInterface
,
2968 IFView_GetCurrentViewMode
,
2969 IFView_SetCurrentViewMode
,
2974 IFView_GetSelectionMarkedItem
,
2975 IFView_GetFocusedItem
,
2976 IFView_GetItemPosition
,
2978 IFView_GetDefaultSpacing
,
2979 IFView_GetAutoArrange
,
2981 IFView_SelectAndPositionItems
2984 /* IShellFolderView */
2985 static HRESULT WINAPI
IShellFolderView_fnQueryInterface(
2986 IShellFolderView
*iface
,
2990 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
2991 TRACE("(%p)->(IID:%s,%p)\n", This
, debugstr_guid(riid
), ppvObj
);
2992 return IShellView2_QueryInterface(&This
->IShellView2_iface
, riid
, ppvObj
);
2995 static ULONG WINAPI
IShellFolderView_fnAddRef(IShellFolderView
*iface
)
2997 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
2998 TRACE("(%p)->(count=%u)\n", This
, This
->ref
);
2999 return IShellView2_AddRef(&This
->IShellView2_iface
);
3002 static ULONG WINAPI
IShellFolderView_fnRelease(IShellFolderView
*iface
)
3004 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3005 TRACE("(%p)->(count=%u)\n", This
, This
->ref
);
3006 return IShellView2_Release(&This
->IShellView2_iface
);
3009 static HRESULT WINAPI
IShellFolderView_fnRearrange(IShellFolderView
*iface
, LPARAM sort
)
3011 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3012 FIXME("(%p)->(%ld) stub\n", This
, sort
);
3016 static HRESULT WINAPI
IShellFolderView_fnGetArrangeParam(IShellFolderView
*iface
, LPARAM
*sort
)
3018 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3019 FIXME("(%p)->(%p) stub\n", This
, sort
);
3023 static HRESULT WINAPI
IShellFolderView_fnArrangeGrid(IShellFolderView
*iface
)
3025 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3026 FIXME("(%p) stub\n", This
);
3030 static HRESULT WINAPI
IShellFolderView_fnAutoArrange(IShellFolderView
*iface
)
3032 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3033 FIXME("(%p) stub\n", This
);
3037 static HRESULT WINAPI
IShellFolderView_fnGetAutoArrange(IShellFolderView
*iface
)
3039 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3040 IFolderView
*view
= &This
->IFolderView_iface
;
3042 TRACE("(%p)\n", This
);
3043 return IFolderView_GetAutoArrange(view
);
3046 static HRESULT WINAPI
IShellFolderView_fnAddObject(
3047 IShellFolderView
*iface
,
3051 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3052 FIXME("(%p)->(%p %p) stub\n", This
, pidl
, item
);
3056 static HRESULT WINAPI
IShellFolderView_fnGetObject(
3057 IShellFolderView
*iface
,
3058 PITEMID_CHILD
*pidl
,
3061 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3062 IFolderView
*view
= &This
->IFolderView_iface
;
3064 TRACE("(%p)->(%p %d)\n", This
, pidl
, item
);
3065 return IFolderView_Item(view
, item
, pidl
);
3068 static HRESULT WINAPI
IShellFolderView_fnRemoveObject(
3069 IShellFolderView
*iface
,
3073 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3075 TRACE("(%p)->(%p %p)\n", This
, pidl
, item
);
3079 *item
= LV_FindItemByPidl(This
, ILFindLastID(pidl
));
3080 SendMessageW(This
->hWndList
, LVM_DELETEITEM
, *item
, 0);
3085 SendMessageW(This
->hWndList
, LVM_DELETEALLITEMS
, 0, 0);
3091 static HRESULT WINAPI
IShellFolderView_fnGetObjectCount(
3092 IShellFolderView
*iface
,
3095 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3096 IFolderView
*view
= &This
->IFolderView_iface
;
3098 TRACE("(%p)->(%p)\n", This
, count
);
3099 return IFolderView_ItemCount(view
, SVGIO_ALLVIEW
, (INT
*)count
);
3102 static HRESULT WINAPI
IShellFolderView_fnSetObjectCount(
3103 IShellFolderView
*iface
,
3107 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3108 FIXME("(%p)->(%d %x) stub\n", This
, count
, flags
);
3112 static HRESULT WINAPI
IShellFolderView_fnUpdateObject(
3113 IShellFolderView
*iface
,
3114 PITEMID_CHILD pidl_old
,
3115 PITEMID_CHILD pidl_new
,
3118 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3119 FIXME("(%p)->(%p %p %p) stub\n", This
, pidl_old
, pidl_new
, item
);
3123 static HRESULT WINAPI
IShellFolderView_fnRefreshObject(
3124 IShellFolderView
*iface
,
3128 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3129 FIXME("(%p)->(%p %p) stub\n", This
, pidl
, item
);
3133 static HRESULT WINAPI
IShellFolderView_fnSetRedraw(
3134 IShellFolderView
*iface
,
3137 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3138 TRACE("(%p)->(%d)\n", This
, redraw
);
3140 SendMessageW(This
->hWndList
, WM_SETREDRAW
, redraw
, 0);
3145 static HRESULT WINAPI
IShellFolderView_fnGetSelectedCount(
3146 IShellFolderView
*iface
,
3149 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3150 FIXME("(%p)->(%p) stub\n", This
, count
);
3154 static HRESULT WINAPI
IShellFolderView_fnGetSelectedObjects(
3155 IShellFolderView
*iface
,
3156 PCITEMID_CHILD
**pidl
,
3159 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3161 TRACE("(%p)->(%p %p)\n", This
, pidl
, items
);
3163 *items
= ShellView_GetSelections( This
);
3167 *pidl
= LocalAlloc(0, *items
*sizeof(LPITEMIDLIST
));
3168 if (!*pidl
) return E_OUTOFMEMORY
;
3170 /* it's documented that caller shouldn't free PIDLs, only array itself */
3171 memcpy((PITEMID_CHILD
*)*pidl
, This
->apidl
, *items
*sizeof(LPITEMIDLIST
));
3177 static HRESULT WINAPI
IShellFolderView_fnIsDropOnSource(
3178 IShellFolderView
*iface
,
3179 IDropTarget
*drop_target
)
3181 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3182 FIXME("(%p)->(%p) stub\n", This
, drop_target
);
3186 static HRESULT WINAPI
IShellFolderView_fnGetDragPoint(
3187 IShellFolderView
*iface
,
3190 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3191 FIXME("(%p)->(%p) stub\n", This
, pt
);
3195 static HRESULT WINAPI
IShellFolderView_fnGetDropPoint(
3196 IShellFolderView
*iface
,
3199 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3200 FIXME("(%p)->(%p) stub\n", This
, pt
);
3204 static HRESULT WINAPI
IShellFolderView_fnMoveIcons(
3205 IShellFolderView
*iface
,
3208 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3209 TRACE("(%p)->(%p)\n", This
, obj
);
3213 static HRESULT WINAPI
IShellFolderView_fnSetItemPos(
3214 IShellFolderView
*iface
,
3215 PCUITEMID_CHILD pidl
,
3218 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3219 FIXME("(%p)->(%p %p) stub\n", This
, pidl
, pt
);
3223 static HRESULT WINAPI
IShellFolderView_fnIsBkDropTarget(
3224 IShellFolderView
*iface
,
3225 IDropTarget
*drop_target
)
3227 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3228 FIXME("(%p)->(%p) stub\n", This
, drop_target
);
3232 static HRESULT WINAPI
IShellFolderView_fnSetClipboard(
3233 IShellFolderView
*iface
,
3236 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3237 FIXME("(%p)->(%d) stub\n", This
, move
);
3241 static HRESULT WINAPI
IShellFolderView_fnSetPoints(
3242 IShellFolderView
*iface
,
3245 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3246 FIXME("(%p)->(%p) stub\n", This
, obj
);
3250 static HRESULT WINAPI
IShellFolderView_fnGetItemSpacing(
3251 IShellFolderView
*iface
,
3252 ITEMSPACING
*spacing
)
3254 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3255 FIXME("(%p)->(%p) stub\n", This
, spacing
);
3259 static HRESULT WINAPI
IShellFolderView_fnSetCallback(
3260 IShellFolderView
*iface
,
3261 IShellFolderViewCB
*new_cb
,
3262 IShellFolderViewCB
**old_cb
)
3265 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3266 FIXME("(%p)->(%p %p) stub\n", This
, new_cb
, old_cb
);
3270 static HRESULT WINAPI
IShellFolderView_fnSelect(
3271 IShellFolderView
*iface
,
3274 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3275 FIXME("(%p)->(%d) stub\n", This
, flags
);
3279 static HRESULT WINAPI
IShellFolderView_fnQuerySupport(
3280 IShellFolderView
*iface
,
3283 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3284 TRACE("(%p)->(%p)\n", This
, support
);
3288 static HRESULT WINAPI
IShellFolderView_fnSetAutomationObject(
3289 IShellFolderView
*iface
,
3292 IShellViewImpl
*This
= impl_from_IShellFolderView(iface
);
3293 FIXME("(%p)->(%p) stub\n", This
, disp
);
3297 static const IShellFolderViewVtbl shellfolderviewvt
=
3299 IShellFolderView_fnQueryInterface
,
3300 IShellFolderView_fnAddRef
,
3301 IShellFolderView_fnRelease
,
3302 IShellFolderView_fnRearrange
,
3303 IShellFolderView_fnGetArrangeParam
,
3304 IShellFolderView_fnArrangeGrid
,
3305 IShellFolderView_fnAutoArrange
,
3306 IShellFolderView_fnGetAutoArrange
,
3307 IShellFolderView_fnAddObject
,
3308 IShellFolderView_fnGetObject
,
3309 IShellFolderView_fnRemoveObject
,
3310 IShellFolderView_fnGetObjectCount
,
3311 IShellFolderView_fnSetObjectCount
,
3312 IShellFolderView_fnUpdateObject
,
3313 IShellFolderView_fnRefreshObject
,
3314 IShellFolderView_fnSetRedraw
,
3315 IShellFolderView_fnGetSelectedCount
,
3316 IShellFolderView_fnGetSelectedObjects
,
3317 IShellFolderView_fnIsDropOnSource
,
3318 IShellFolderView_fnGetDragPoint
,
3319 IShellFolderView_fnGetDropPoint
,
3320 IShellFolderView_fnMoveIcons
,
3321 IShellFolderView_fnSetItemPos
,
3322 IShellFolderView_fnIsBkDropTarget
,
3323 IShellFolderView_fnSetClipboard
,
3324 IShellFolderView_fnSetPoints
,
3325 IShellFolderView_fnGetItemSpacing
,
3326 IShellFolderView_fnSetCallback
,
3327 IShellFolderView_fnSelect
,
3328 IShellFolderView_fnQuerySupport
,
3329 IShellFolderView_fnSetAutomationObject