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: CheckToolbar: handle the "new folder" and "folder up" button
28 * FIXME: ShellView_FillList: consider sort orders
33 1. Load/Save the view state from/into the stream provided by the ShellBrowser.
34 2. Let the shell folder sort items.
35 3. Code to merge menus in the shellbrowser is incorrect.
36 4. Move the background context menu creation into shell view. It should store the
37 shell view HWND to send commands.
38 5. Send init, measure, and draw messages to context menu during tracking.
39 6. Shell view should do SetCommandTarget on internet toolbar.
40 7. When editing starts on item, set edit text to for editing value.
41 8. When shell view is called back for item info, let listview save the value.
42 9. Shell view should update status bar.
43 10. Fix shell view to handle view mode popup exec.
44 11. The background context menu should have a pidl just like foreground menus. This
45 causes crashes when dynamic handlers try to use the NULL pidl.
46 12. The SHELLDLL_DefView should not be filled with blue unconditionally. This causes
47 annoying flashing of blue even on XP, and is not correct.
48 13. Reorder of columns doesn't work - might be bug in comctl32
53 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
57 static const WCHAR SV_CLASS_NAME
[] = {'S', 'H', 'E', 'L', 'L', 'D', 'L', 'L', '_', 'D', 'e', 'f', 'V', 'i', 'e', 'w', 0};
63 } LISTVIEW_SORT_INFO
, *LPLISTVIEW_SORT_INFO
;
65 #define SHV_CHANGE_NOTIFY WM_USER + 0x1111
68 public CWindowImpl
<CDefView
, CWindow
, CControlWinTraits
>,
69 public CComObjectRootEx
<CComMultiThreadModelNoCS
>,
72 public IOleCommandTarget
,
76 public IServiceProvider
79 CComPtr
<IShellFolder
> pSFParent
;
80 CComPtr
<IShellFolder2
> pSF2Parent
;
81 CComPtr
<IShellBrowser
> pShellBrowser
;
82 CComPtr
<ICommDlgBrowser
> pCommDlgBrowser
;
83 HWND hWndList
; /* ListView control */
85 FOLDERSETTINGS FolderSettings
;
90 LISTVIEW_SORT_INFO ListViewSortInfo
;
91 ULONG hNotify
; /* change notification handle */
95 CComPtr
<IAdviseSink
> pAdvSink
;
97 CComPtr
<IDropTarget
> pCurDropTarget
; /* The sub-item, which is currently dragged over */
98 CComPtr
<IDataObject
> pCurDataObject
; /* The dragged data-object */
99 LONG iDragOverItem
; /* Dragged over item's index, iff pCurDropTarget != NULL */
100 UINT cScrollDelay
; /* Send a WM_*SCROLL msg every 250 ms during drag-scroll */
101 POINT ptLastMousePos
; /* Mouse position at last DragOver call */
103 CComPtr
<IContextMenu2
> pCM
;
107 HRESULT WINAPI
Initialize(IShellFolder
*shellFolder
);
108 HRESULT
IncludeObject(LPCITEMIDLIST pidl
);
109 HRESULT
OnDefaultCommand();
110 HRESULT
OnStateChange(UINT uFlags
);
112 void SetStyle(DWORD dwAdd
, DWORD dwRemove
);
115 static INT CALLBACK
CompareItems(LPVOID lParam1
, LPVOID lParam2
, LPARAM lpData
);
116 static INT CALLBACK
ListViewCompareItems(LPVOID lParam1
, LPVOID lParam2
, LPARAM lpData
);
117 int LV_FindItemByPidl(LPCITEMIDLIST pidl
);
118 BOOLEAN
LV_AddItem(LPCITEMIDLIST pidl
);
119 BOOLEAN
LV_DeleteItem(LPCITEMIDLIST pidl
);
120 BOOLEAN
LV_RenameItem(LPCITEMIDLIST pidlOld
, LPCITEMIDLIST pidlNew
);
121 static INT CALLBACK
fill_list(LPVOID ptr
, LPVOID arg
);
123 HMENU
BuildFileMenu();
124 void MergeFileMenu(HMENU hSubMenu
);
125 void MergeViewMenu(HMENU hSubMenu
);
126 UINT
GetSelections();
127 HRESULT
OpenSelectedItems();
129 void DoActivate(UINT uState
);
130 HRESULT
drag_notify_subitem(DWORD grfKeyState
, POINTL pt
, DWORD
*pdwEffect
);
132 // *** IOleWindow methods ***
133 virtual HRESULT STDMETHODCALLTYPE
GetWindow(HWND
*lphwnd
);
134 virtual HRESULT STDMETHODCALLTYPE
ContextSensitiveHelp(BOOL fEnterMode
);
136 // *** IShellView methods ***
137 virtual HRESULT STDMETHODCALLTYPE
TranslateAccelerator(MSG
*pmsg
);
138 virtual HRESULT STDMETHODCALLTYPE
EnableModeless(BOOL fEnable
);
139 virtual HRESULT STDMETHODCALLTYPE
UIActivate(UINT uState
);
140 virtual HRESULT STDMETHODCALLTYPE
Refresh();
141 virtual HRESULT STDMETHODCALLTYPE
CreateViewWindow(IShellView
*psvPrevious
, LPCFOLDERSETTINGS pfs
, IShellBrowser
*psb
, RECT
*prcView
, HWND
*phWnd
);
142 virtual HRESULT STDMETHODCALLTYPE
DestroyViewWindow();
143 virtual HRESULT STDMETHODCALLTYPE
GetCurrentInfo(LPFOLDERSETTINGS pfs
);
144 virtual HRESULT STDMETHODCALLTYPE
AddPropertySheetPages(DWORD dwReserved
, LPFNSVADDPROPSHEETPAGE pfn
, LPARAM lparam
);
145 virtual HRESULT STDMETHODCALLTYPE
SaveViewState();
146 virtual HRESULT STDMETHODCALLTYPE
SelectItem(LPCITEMIDLIST pidlItem
, SVSIF uFlags
);
147 virtual HRESULT STDMETHODCALLTYPE
GetItemObject(UINT uItem
, REFIID riid
, void **ppv
);
149 // *** IFolderView methods ***
150 virtual HRESULT STDMETHODCALLTYPE
GetCurrentViewMode(UINT
*pViewMode
);
151 virtual HRESULT STDMETHODCALLTYPE
SetCurrentViewMode(UINT ViewMode
);
152 virtual HRESULT STDMETHODCALLTYPE
GetFolder(REFIID riid
, void **ppv
);
153 virtual HRESULT STDMETHODCALLTYPE
Item(int iItemIndex
, LPITEMIDLIST
*ppidl
);
154 virtual HRESULT STDMETHODCALLTYPE
ItemCount(UINT uFlags
, int *pcItems
);
155 virtual HRESULT STDMETHODCALLTYPE
Items(UINT uFlags
, REFIID riid
, void **ppv
);
156 virtual HRESULT STDMETHODCALLTYPE
GetSelectionMarkedItem(int *piItem
);
157 virtual HRESULT STDMETHODCALLTYPE
GetFocusedItem(int *piItem
);
158 virtual HRESULT STDMETHODCALLTYPE
GetItemPosition(LPCITEMIDLIST pidl
, POINT
*ppt
);
159 virtual HRESULT STDMETHODCALLTYPE
GetSpacing(POINT
*ppt
);
160 virtual HRESULT STDMETHODCALLTYPE
GetDefaultSpacing(POINT
*ppt
);
161 virtual HRESULT STDMETHODCALLTYPE
GetAutoArrange();
162 virtual HRESULT STDMETHODCALLTYPE
SelectItem(int iItem
, DWORD dwFlags
);
163 virtual HRESULT STDMETHODCALLTYPE
SelectAndPositionItems(UINT cidl
, LPCITEMIDLIST
*apidl
, POINT
*apt
, DWORD dwFlags
);
165 // *** IOleCommandTarget methods ***
166 virtual HRESULT STDMETHODCALLTYPE
QueryStatus(const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[ ], OLECMDTEXT
*pCmdText
);
167 virtual HRESULT STDMETHODCALLTYPE
Exec(const GUID
*pguidCmdGroup
, DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
);
169 // *** IDropTarget methods ***
170 virtual HRESULT STDMETHODCALLTYPE
DragEnter(IDataObject
*pDataObj
, DWORD grfKeyState
, POINTL pt
, DWORD
*pdwEffect
);
171 virtual HRESULT STDMETHODCALLTYPE
DragOver(DWORD grfKeyState
, POINTL pt
, DWORD
*pdwEffect
);
172 virtual HRESULT STDMETHODCALLTYPE
DragLeave();
173 virtual HRESULT STDMETHODCALLTYPE
Drop(IDataObject
*pDataObj
, DWORD grfKeyState
, POINTL pt
, DWORD
*pdwEffect
);
175 // *** IDropSource methods ***
176 virtual HRESULT STDMETHODCALLTYPE
QueryContinueDrag(BOOL fEscapePressed
, DWORD grfKeyState
);
177 virtual HRESULT STDMETHODCALLTYPE
GiveFeedback(DWORD dwEffect
);
179 // *** IViewObject methods ***
180 virtual HRESULT STDMETHODCALLTYPE
Draw(DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
, DVTARGETDEVICE
*ptd
,
181 HDC hdcTargetDev
, HDC hdcDraw
, LPCRECTL lprcBounds
, LPCRECTL lprcWBounds
,
182 BOOL ( STDMETHODCALLTYPE
*pfnContinue
)(ULONG_PTR dwContinue
), ULONG_PTR dwContinue
);
183 virtual HRESULT STDMETHODCALLTYPE
GetColorSet(DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
,
184 DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, LOGPALETTE
**ppColorSet
);
185 virtual HRESULT STDMETHODCALLTYPE
Freeze(DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
, DWORD
*pdwFreeze
);
186 virtual HRESULT STDMETHODCALLTYPE
Unfreeze(DWORD dwFreeze
);
187 virtual HRESULT STDMETHODCALLTYPE
SetAdvise(DWORD aspects
, DWORD advf
, IAdviseSink
*pAdvSink
);
188 virtual HRESULT STDMETHODCALLTYPE
GetAdvise(DWORD
*pAspects
, DWORD
*pAdvf
, IAdviseSink
**ppAdvSink
);
190 // *** IServiceProvider methods ***
191 virtual HRESULT STDMETHODCALLTYPE
QueryService(REFGUID guidService
, REFIID riid
, void **ppvObject
);
194 LRESULT
OnShowWindow(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
195 LRESULT
OnGetDlgCode(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
196 LRESULT
OnDestroy(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
197 LRESULT
OnEraseBackground(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
198 LRESULT
OnSysColorChange(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
199 LRESULT
OnGetShellBrowser(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
200 LRESULT
OnCreate(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
201 LRESULT
OnContextMenu(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
202 LRESULT
OnSize(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
203 LRESULT
OnActivate(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
204 LRESULT
OnSetFocus(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
205 LRESULT
OnKillFocus(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
206 LRESULT
OnCommand(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
207 LRESULT
OnNotify(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
208 LRESULT
OnChangeNotify(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
209 LRESULT
OnCustomItem(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
);
211 static ATL::CWndClassInfo
& GetWndClassInfo()
213 static ATL::CWndClassInfo wc
=
215 { sizeof(WNDCLASSEX
), 0, StartWindowProc
,
217 LoadCursor(NULL
, IDC_ARROW
), (HBRUSH
)(COLOR_BACKGROUND
+ 1), NULL
, SV_CLASS_NAME
, NULL
219 NULL
, NULL
, IDC_ARROW
, TRUE
, 0, _T("")
224 virtual WNDPROC
GetWindowProc()
229 static LRESULT CALLBACK
WindowProc(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
234 // must hold a reference during message handling
235 pThis
= reinterpret_cast<CDefView
*>(hWnd
);
237 result
= CWindowImpl
<CDefView
, CWindow
, CControlWinTraits
>::WindowProc(hWnd
, uMsg
, wParam
, lParam
);
242 BEGIN_MSG_MAP(CDefView
)
243 MESSAGE_HANDLER(WM_SIZE
, OnSize
)
244 MESSAGE_HANDLER(WM_SETFOCUS
, OnSetFocus
)
245 MESSAGE_HANDLER(WM_KILLFOCUS
, OnKillFocus
)
246 MESSAGE_HANDLER(WM_CREATE
, OnCreate
)
247 MESSAGE_HANDLER(WM_ACTIVATE
, OnActivate
)
248 MESSAGE_HANDLER(WM_NOTIFY
, OnNotify
)
249 MESSAGE_HANDLER(WM_COMMAND
, OnCommand
)
250 MESSAGE_HANDLER(SHV_CHANGE_NOTIFY
, OnChangeNotify
)
251 MESSAGE_HANDLER(WM_CONTEXTMENU
, OnContextMenu
)
252 MESSAGE_HANDLER(WM_DRAWITEM
, OnCustomItem
)
253 MESSAGE_HANDLER(WM_MEASUREITEM
, OnCustomItem
)
254 MESSAGE_HANDLER(WM_SHOWWINDOW
, OnShowWindow
)
255 MESSAGE_HANDLER(WM_GETDLGCODE
, OnGetDlgCode
)
256 MESSAGE_HANDLER(WM_DESTROY
, OnDestroy
)
257 MESSAGE_HANDLER(WM_ERASEBKGND
, OnEraseBackground
)
258 MESSAGE_HANDLER(WM_SYSCOLORCHANGE
, OnSysColorChange
)
259 MESSAGE_HANDLER(CWM_GETISHELLBROWSER
, OnGetShellBrowser
)
262 BEGIN_COM_MAP(CDefView
)
263 COM_INTERFACE_ENTRY_IID(IID_IOleWindow
, IOleWindow
)
264 COM_INTERFACE_ENTRY_IID(IID_IShellView
, IShellView
)
265 COM_INTERFACE_ENTRY_IID(IID_IFolderView
, IFolderView
)
266 COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget
, IOleCommandTarget
)
267 COM_INTERFACE_ENTRY_IID(IID_IDropTarget
, IDropTarget
)
268 COM_INTERFACE_ENTRY_IID(IID_IDropSource
, IDropSource
)
269 COM_INTERFACE_ENTRY_IID(IID_IViewObject
, IViewObject
)
270 COM_INTERFACE_ENTRY_IID(IID_IServiceProvider
, IServiceProvider
)
274 /* ListView Header ID's */
275 #define LISTVIEW_COLUMN_NAME 0
276 #define LISTVIEW_COLUMN_SIZE 1
277 #define LISTVIEW_COLUMN_TYPE 2
278 #define LISTVIEW_COLUMN_TIME 3
279 #define LISTVIEW_COLUMN_ATTRIB 4
282 #define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500)
283 #define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501)
284 #define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502)
286 #define ID_LISTVIEW 1
289 #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
290 #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
291 #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
294 Items merged into the toolbar and the filemenu
303 } MYTOOLINFO
, *LPMYTOOLINFO
;
305 static const MYTOOLINFO Tools
[] =
307 { FCIDM_SHVIEW_BIGICON
, 0, 0, IDS_VIEW_LARGE
, TBSTATE_ENABLED
, BTNS_BUTTON
},
308 { FCIDM_SHVIEW_SMALLICON
, 0, 0, IDS_VIEW_SMALL
, TBSTATE_ENABLED
, BTNS_BUTTON
},
309 { FCIDM_SHVIEW_LISTVIEW
, 0, 0, IDS_VIEW_LIST
, TBSTATE_ENABLED
, BTNS_BUTTON
},
310 { FCIDM_SHVIEW_REPORTVIEW
, 0, 0, IDS_VIEW_DETAILS
, TBSTATE_ENABLED
, BTNS_BUTTON
},
314 typedef void (CALLBACK
*PFNSHGETSETTINGSPROC
)(LPSHELLFLAGSTATE lpsfs
, DWORD dwMask
);
320 FolderSettings
.fFlags
= 0;
321 FolderSettings
.ViewMode
= 0;
326 ListViewSortInfo
.bIsAscending
= FALSE
;
327 ListViewSortInfo
.nHeaderID
= 0;
328 ListViewSortInfo
.nLastHeaderID
= 0;
335 ptLastMousePos
.x
= 0;
336 ptLastMousePos
.y
= 0;
339 CDefView::~CDefView()
341 TRACE(" destroying IShellView(%p)\n", this);
346 HRESULT WINAPI
CDefView::Initialize(IShellFolder
*shellFolder
)
348 pSFParent
= shellFolder
;
349 shellFolder
->QueryInterface(IID_IShellFolder2
, (LPVOID
*)&pSF2Parent
);
354 /**********************************************************
356 * ##### helperfunctions for communication with ICommDlgBrowser #####
358 HRESULT
CDefView::IncludeObject(LPCITEMIDLIST pidl
)
362 if (pCommDlgBrowser
.p
!= NULL
)
364 TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl
);
365 ret
= pCommDlgBrowser
->IncludeObject((IShellView
*)this, pidl
);
366 TRACE("--0x%08x\n", ret
);
372 HRESULT
CDefView::OnDefaultCommand()
374 HRESULT ret
= S_FALSE
;
376 if (pCommDlgBrowser
.p
!= NULL
)
378 TRACE("ICommDlgBrowser::OnDefaultCommand\n");
379 ret
= pCommDlgBrowser
->OnDefaultCommand((IShellView
*)this);
380 TRACE("-- returns %08x\n", ret
);
386 HRESULT
CDefView::OnStateChange(UINT uFlags
)
388 HRESULT ret
= S_FALSE
;
390 if (pCommDlgBrowser
.p
!= NULL
)
392 TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags
);
393 ret
= pCommDlgBrowser
->OnStateChange((IShellView
*)this, uFlags
);
399 /**********************************************************
400 * set the toolbar of the filedialog buttons
402 * - activates the buttons from the shellbrowser according to
405 void CDefView::CheckToolbar()
411 if (pCommDlgBrowser
!= NULL
)
413 pShellBrowser
->SendControlMsg(FCW_TOOLBAR
, TB_CHECKBUTTON
,
414 FCIDM_TB_SMALLICON
, (FolderSettings
.ViewMode
== FVM_LIST
) ? TRUE
: FALSE
, &result
);
415 pShellBrowser
->SendControlMsg(FCW_TOOLBAR
, TB_CHECKBUTTON
,
416 FCIDM_TB_REPORTVIEW
, (FolderSettings
.ViewMode
== FVM_DETAILS
) ? TRUE
: FALSE
, &result
);
417 pShellBrowser
->SendControlMsg(FCW_TOOLBAR
, TB_ENABLEBUTTON
,
418 FCIDM_TB_SMALLICON
, TRUE
, &result
);
419 pShellBrowser
->SendControlMsg(FCW_TOOLBAR
, TB_ENABLEBUTTON
,
420 FCIDM_TB_REPORTVIEW
, TRUE
, &result
);
424 /**********************************************************
426 * ##### helperfunctions for initializing the view #####
428 /**********************************************************
429 * change the style of the listview control
431 void CDefView::SetStyle(DWORD dwAdd
, DWORD dwRemove
)
435 TRACE("(%p)\n", this);
437 tmpstyle
= ::GetWindowLongPtrW(hWndList
, GWL_STYLE
);
438 ::SetWindowLongPtrW(hWndList
, GWL_STYLE
, dwAdd
| (tmpstyle
& ~dwRemove
));
441 /**********************************************************
442 * ShellView_CreateList()
444 * - creates the list view window
446 BOOL
CDefView::CreateList()
447 { DWORD dwStyle
, dwExStyle
;
451 dwStyle
= WS_TABSTOP
| WS_VISIBLE
| WS_CHILDWINDOW
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
|
452 LVS_SHAREIMAGELISTS
| LVS_EDITLABELS
| LVS_AUTOARRANGE
;
453 dwExStyle
= WS_EX_CLIENTEDGE
;
455 if (FolderSettings
.fFlags
& FWF_DESKTOP
)
456 dwStyle
|= LVS_ALIGNLEFT
;
458 dwStyle
|= LVS_ALIGNTOP
;
460 switch (FolderSettings
.ViewMode
)
467 dwStyle
|= LVS_REPORT
;
471 dwStyle
|= LVS_SMALLICON
;
483 if (FolderSettings
.fFlags
& FWF_AUTOARRANGE
)
484 dwStyle
|= LVS_AUTOARRANGE
;
486 if (FolderSettings
.fFlags
& FWF_DESKTOP
)
487 FolderSettings
.fFlags
|= FWF_NOCLIENTEDGE
| FWF_NOSCROLL
;
489 if (FolderSettings
.fFlags
& FWF_SINGLESEL
)
490 dwStyle
|= LVS_SINGLESEL
;
492 if (FolderSettings
.fFlags
& FWF_NOCLIENTEDGE
)
493 dwExStyle
&= ~WS_EX_CLIENTEDGE
;
495 hWndList
= CreateWindowExW( dwExStyle
,
508 ListViewSortInfo
.bIsAscending
= TRUE
;
509 ListViewSortInfo
.nHeaderID
= -1;
510 ListViewSortInfo
.nLastHeaderID
= -1;
512 if (FolderSettings
.fFlags
& FWF_DESKTOP
)
515 * FIXME: look at the registry value
516 * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ListviewShadow
517 * and activate drop shadows if necessary
521 SendMessageW(hWndList
, LVM_SETTEXTBKCOLOR
, 0, CLR_NONE
);
522 SendMessageW(hWndList
, LVM_SETBKCOLOR
, 0, CLR_NONE
);
526 SendMessageW(hWndList
, LVM_SETTEXTBKCOLOR
, 0, GetSysColor(COLOR_DESKTOP
));
527 SendMessageW(hWndList
, LVM_SETBKCOLOR
, 0, GetSysColor(COLOR_DESKTOP
));
530 SendMessageW(hWndList
, LVM_SETTEXTCOLOR
, 0, RGB(255, 255, 255));
533 /* UpdateShellSettings(); */
537 /**********************************************************
538 * ShellView_InitList()
540 * - adds all needed columns to the shellview
542 BOOL
CDefView::InitList()
550 SendMessageW(hWndList
, LVM_DELETEALLITEMS
, 0, 0);
552 lvColumn
.mask
= LVCF_FMT
| LVCF_WIDTH
| LVCF_TEXT
;
553 lvColumn
.pszText
= szTemp
;
557 for (int i
= 0; 1; i
++)
559 if (FAILED(pSF2Parent
->GetDetailsOf(NULL
, i
, &sd
)))
562 lvColumn
.fmt
= sd
.fmt
;
563 lvColumn
.cx
= sd
.cxChar
* 8; /* chars->pixel */
564 StrRetToStrNW( szTemp
, 50, &sd
.str
, NULL
);
565 SendMessageW(hWndList
, LVM_INSERTCOLUMNW
, i
, (LPARAM
) &lvColumn
);
573 SendMessageW(hWndList
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)ShellSmallIconList
);
574 SendMessageW(hWndList
, LVM_SETIMAGELIST
, LVSIL_NORMAL
, (LPARAM
)ShellBigIconList
);
579 /**********************************************************
580 * ShellView_CompareItems()
583 * internal, CALLBACK for DSA_Sort
585 INT CALLBACK
CDefView::CompareItems(LPVOID lParam1
, LPVOID lParam2
, LPARAM lpData
)
588 TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1
, lParam2
, (LPVOID
) lpData
);
593 ret
= (SHORT
)SCODE_CODE(((IShellFolder
*)lpData
)->CompareIDs(0, (LPITEMIDLIST
)lParam1
, (LPITEMIDLIST
)lParam2
));
594 TRACE("ret=%i\n", ret
);
599 /*************************************************************************
600 * ShellView_ListViewCompareItems
602 * Compare Function for the Listview (FileOpen Dialog)
605 * lParam1 [I] the first ItemIdList to compare with
606 * lParam2 [I] the second ItemIdList to compare with
607 * lpData [I] The column ID for the header Ctrl to process
610 * A negative value if the first item should precede the second,
611 * a positive value if the first item should follow the second,
612 * or zero if the two items are equivalent
615 * FIXME: function does what ShellView_CompareItems is supposed to do.
616 * unify it and figure out how to use the undocumented first parameter
617 * of IShellFolder_CompareIDs to do the job this function does and
618 * move this code to IShellFolder.
619 * make LISTVIEW_SORT_INFO obsolete
620 * the way this function works is only usable if we had only
621 * filesystemfolders (25/10/99 jsch)
623 INT CALLBACK
CDefView::ListViewCompareItems(LPVOID lParam1
, LPVOID lParam2
, LPARAM lpData
)
627 char strName1
[MAX_PATH
], strName2
[MAX_PATH
];
628 BOOL bIsFolder1
, bIsFolder2
, bIsBothFolder
;
629 LPITEMIDLIST pItemIdList1
= (LPITEMIDLIST
) lParam1
;
630 LPITEMIDLIST pItemIdList2
= (LPITEMIDLIST
) lParam2
;
631 LISTVIEW_SORT_INFO
*pSortInfo
= (LPLISTVIEW_SORT_INFO
) lpData
;
634 bIsFolder1
= _ILIsFolder(pItemIdList1
);
635 bIsFolder2
= _ILIsFolder(pItemIdList2
);
636 bIsBothFolder
= bIsFolder1
&& bIsFolder2
;
638 /* When sorting between a File and a Folder, the Folder gets sorted first */
639 if ( (bIsFolder1
|| bIsFolder2
) && !bIsBothFolder
)
641 nDiff
= bIsFolder1
? -1 : 1;
645 /* Sort by Time: Folders or Files can be sorted */
647 if(pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_TIME
)
649 _ILGetFileDateTime(pItemIdList1
, &fd1
);
650 _ILGetFileDateTime(pItemIdList2
, &fd2
);
651 nDiff
= CompareFileTime(&fd2
, &fd1
);
653 /* Sort by Attribute: Folder or Files can be sorted */
654 else if(pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_ATTRIB
)
656 _ILGetFileAttributes(pItemIdList1
, strName1
, MAX_PATH
);
657 _ILGetFileAttributes(pItemIdList2
, strName2
, MAX_PATH
);
658 nDiff
= lstrcmpiA(strName1
, strName2
);
660 /* Sort by FileName: Folder or Files can be sorted */
661 else if (pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_NAME
|| bIsBothFolder
)
664 _ILSimpleGetText(pItemIdList1
, strName1
, MAX_PATH
);
665 _ILSimpleGetText(pItemIdList2
, strName2
, MAX_PATH
);
666 nDiff
= lstrcmpiA(strName1
, strName2
);
668 /* Sort by File Size, Only valid for Files */
669 else if (pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_SIZE
)
671 nDiff
= (INT
)(_ILGetFileSize(pItemIdList1
, NULL
, 0) - _ILGetFileSize(pItemIdList2
, NULL
, 0));
673 /* Sort by File Type, Only valid for Files */
674 else if (pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_TYPE
)
677 _ILGetFileType(pItemIdList1
, strName1
, MAX_PATH
);
678 _ILGetFileType(pItemIdList2
, strName2
, MAX_PATH
);
679 nDiff
= lstrcmpiA(strName1
, strName2
);
682 /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
686 _ILSimpleGetText(pItemIdList1
, strName1
, MAX_PATH
);
687 _ILSimpleGetText(pItemIdList2
, strName2
, MAX_PATH
);
688 nDiff
= lstrcmpiA(strName1
, strName2
);
691 if (!pSortInfo
->bIsAscending
)
699 /**********************************************************
700 * LV_FindItemByPidl()
702 int CDefView::LV_FindItemByPidl(LPCITEMIDLIST pidl
)
706 lvItem
.mask
= LVIF_PARAM
;
708 for (lvItem
.iItem
= 0;
709 SendMessageW(hWndList
, LVM_GETITEMW
, 0, (LPARAM
) &lvItem
);
712 LPITEMIDLIST currentpidl
= (LPITEMIDLIST
) lvItem
.lParam
;
713 HRESULT hr
= pSFParent
->CompareIDs(0, pidl
, currentpidl
);
715 if (SUCCEEDED(hr
) && !HRESULT_CODE(hr
))
723 /**********************************************************
726 BOOLEAN
CDefView::LV_AddItem(LPCITEMIDLIST pidl
)
730 TRACE("(%p)(pidl=%p)\n", this, pidl
);
732 lvItem
.mask
= LVIF_TEXT
| LVIF_IMAGE
| LVIF_PARAM
; /*set the mask*/
733 lvItem
.iItem
= ListView_GetItemCount(hWndList
); /*add the item to the end of the list*/
735 lvItem
.lParam
= (LPARAM
) ILClone(ILFindLastID(pidl
)); /*set the item's data*/
736 lvItem
.pszText
= LPSTR_TEXTCALLBACKW
; /*get text on a callback basis*/
737 lvItem
.iImage
= I_IMAGECALLBACK
; /*get the image on a callback basis*/
739 if (SendMessageW(hWndList
, LVM_INSERTITEMW
, 0, (LPARAM
)&lvItem
) == -1)
745 /**********************************************************
748 BOOLEAN
CDefView::LV_DeleteItem(LPCITEMIDLIST pidl
)
752 TRACE("(%p)(pidl=%p)\n", this, pidl
);
754 nIndex
= LV_FindItemByPidl(ILFindLastID(pidl
));
756 return (-1 == ListView_DeleteItem(hWndList
, nIndex
)) ? FALSE
: TRUE
;
759 /**********************************************************
762 BOOLEAN
CDefView::LV_RenameItem(LPCITEMIDLIST pidlOld
, LPCITEMIDLIST pidlNew
)
767 TRACE("(%p)(pidlold=%p pidlnew=%p)\n", this, pidlOld
, pidlNew
);
769 nItem
= LV_FindItemByPidl(ILFindLastID(pidlOld
));
773 lvItem
.mask
= LVIF_PARAM
; /* only the pidl */
774 lvItem
.iItem
= nItem
;
775 SendMessageW(hWndList
, LVM_GETITEMW
, 0, (LPARAM
) &lvItem
);
777 SHFree((LPITEMIDLIST
)lvItem
.lParam
);
778 lvItem
.mask
= LVIF_PARAM
|LVIF_IMAGE
;
779 lvItem
.iItem
= nItem
;
780 lvItem
.lParam
= (LPARAM
) ILClone(ILFindLastID(pidlNew
)); /* set the item's data */
781 lvItem
.iImage
= SHMapPIDLToSystemImageListIndex(pSFParent
, pidlNew
, 0);
782 SendMessageW(hWndList
, LVM_SETITEMW
, 0, (LPARAM
) &lvItem
);
783 SendMessageW(hWndList
, LVM_UPDATE
, nItem
, 0);
784 return TRUE
; /* FIXME: better handling */
790 /**********************************************************
791 * ShellView_FillList()
793 * - gets the objectlist from the shellfolder
795 * - fills the list into the view
797 INT CALLBACK
CDefView::fill_list( LPVOID ptr
, LPVOID arg
)
799 LPITEMIDLIST pidl
= (LPITEMIDLIST
)ptr
;
800 CDefView
*pThis
= (CDefView
*)arg
;
801 /* in a commdlg This works as a filemask*/
802 if (pThis
->IncludeObject(pidl
) == S_OK
)
803 pThis
->LV_AddItem(pidl
);
809 HRESULT
CDefView::FillList()
811 LPENUMIDLIST pEnumIDList
;
819 /* get the itemlist from the shfolder*/
820 hRes
= pSFParent
->EnumObjects(m_hWnd
, SHCONTF_NONFOLDERS
| SHCONTF_FOLDERS
, &pEnumIDList
);
828 /* create a pointer array */
829 hdpa
= DPA_Create(16);
832 return(E_OUTOFMEMORY
);
835 /* copy the items into the array*/
836 while((S_OK
== pEnumIDList
->Next(1, &pidl
, &dwFetched
)) && dwFetched
)
838 if (DPA_InsertPtr(hdpa
, 0x7fff, pidl
) == -1)
845 DPA_Sort(hdpa
, CompareItems
, (LPARAM
)pSFParent
.p
);
847 /*turn the listview's redrawing off*/
848 SendMessageA(hWndList
, WM_SETREDRAW
, FALSE
, 0);
850 DPA_DestroyCallback( hdpa
, fill_list
, (void *)this);
852 /*turn the listview's redrawing back on and force it to draw*/
853 SendMessageA(hWndList
, WM_SETREDRAW
, TRUE
, 0);
855 pEnumIDList
->Release(); /* destroy the list*/
860 LRESULT
CDefView::OnShowWindow(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
862 ::UpdateWindow(hWndList
);
867 LRESULT
CDefView::OnGetDlgCode(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
869 return SendMessageW(hWndList
, uMsg
, 0, 0);
872 LRESULT
CDefView::OnDestroy(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
874 RevokeDragDrop(m_hWnd
);
875 SHChangeNotifyDeregister(hNotify
);
880 LRESULT
CDefView::OnEraseBackground(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
882 if (FolderSettings
.fFlags
& (FWF_DESKTOP
| FWF_TRANSPARENT
))
883 return SendMessageW(GetParent(), WM_ERASEBKGND
, wParam
, lParam
); /* redirect to parent */
889 LRESULT
CDefView::OnSysColorChange(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
891 /* Forward WM_SYSCOLORCHANGE to common controls */
892 return SendMessageW(hWndList
, uMsg
, 0, 0);
895 LRESULT
CDefView::OnGetShellBrowser(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
897 return (LRESULT
)pShellBrowser
.p
;
900 /**********************************************************
901 * ShellView_OnCreate()
903 LRESULT
CDefView::OnCreate(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
905 CComPtr
<IDropTarget
> pdt
;
906 SHChangeNotifyEntry ntreg
;
907 CComPtr
<IPersistFolder2
> ppf2
;
919 if (SUCCEEDED(this->QueryInterface(IID_IDropTarget
, (LPVOID
*)&pdt
)))
920 RegisterDragDrop(m_hWnd
, pdt
);
922 /* register for receiving notifications */
923 pSFParent
->QueryInterface(IID_IPersistFolder2
, (LPVOID
*)&ppf2
);
926 ppf2
->GetCurFolder((LPITEMIDLIST
*)&ntreg
.pidl
);
927 ntreg
.fRecursive
= TRUE
;
928 hNotify
= SHChangeNotifyRegister(m_hWnd
, SHCNF_IDLIST
, SHCNE_ALLEVENTS
, SHV_CHANGE_NOTIFY
, 1, &ntreg
);
929 SHFree((LPITEMIDLIST
)ntreg
.pidl
);
932 hAccel
= LoadAcceleratorsA(shell32_hInstance
, "shv_accel");
937 /**********************************************************
938 * #### Handling of the menus ####
941 /**********************************************************
942 * ShellView_BuildFileMenu()
944 HMENU
CDefView::BuildFileMenu()
945 { WCHAR szText
[MAX_PATH
];
950 TRACE("(%p)\n", this);
952 hSubMenu
= CreatePopupMenu();
955 /*get the number of items in our global array*/
956 for(nTools
= 0; Tools
[nTools
].idCommand
!= -1; nTools
++) {}
958 /*add the menu items*/
959 for(i
= 0; i
< nTools
; i
++)
961 LoadStringW(shell32_hInstance
, Tools
[i
].idMenuString
, szText
, MAX_PATH
);
963 ZeroMemory(&mii
, sizeof(mii
));
964 mii
.cbSize
= sizeof(mii
);
965 mii
.fMask
= MIIM_TYPE
| MIIM_ID
| MIIM_STATE
;
967 if(BTNS_SEP
!= Tools
[i
].bStyle
) /* no separator*/
969 mii
.fType
= MFT_STRING
;
970 mii
.fState
= MFS_ENABLED
;
971 mii
.dwTypeData
= szText
;
972 mii
.wID
= Tools
[i
].idCommand
;
976 mii
.fType
= MFT_SEPARATOR
;
978 /* tack This item onto the end of the menu */
979 InsertMenuItemW(hSubMenu
, (UINT
) - 1, TRUE
, &mii
);
983 TRACE("-- return (menu=%p)\n", hSubMenu
);
987 /**********************************************************
988 * ShellView_MergeFileMenu()
990 void CDefView::MergeFileMenu(HMENU hSubMenu
)
992 TRACE("(%p)->(submenu=%p) stub\n", this, hSubMenu
);
995 { /*insert This item at the beginning of the menu */
996 _InsertMenuItemW(hSubMenu
, 0, TRUE
, 0, MFT_SEPARATOR
, NULL
, MFS_ENABLED
);
997 _InsertMenuItemW(hSubMenu
, 0, TRUE
, IDM_MYFILEITEM
, MFT_STRING
, L
"dummy45", MFS_ENABLED
);
1003 /**********************************************************
1004 * ShellView_MergeViewMenu()
1006 void CDefView::MergeViewMenu(HMENU hSubMenu
)
1008 TRACE("(%p)->(submenu=%p)\n", this, hSubMenu
);
1012 /*add a separator at the correct position in the menu*/
1014 static WCHAR view
[] = L
"View";
1016 _InsertMenuItemW(hSubMenu
, FCIDM_MENU_VIEW_SEP_OPTIONS
, FALSE
, 0, MFT_SEPARATOR
, NULL
, MFS_ENABLED
);
1018 ZeroMemory(&mii
, sizeof(mii
));
1019 mii
.cbSize
= sizeof(mii
);
1020 mii
.fMask
= MIIM_SUBMENU
| MIIM_TYPE
| MIIM_DATA
;
1021 mii
.fType
= MFT_STRING
;
1022 mii
.dwTypeData
= view
;
1023 mii
.hSubMenu
= LoadMenuW(shell32_hInstance
, L
"MENU_001");
1024 InsertMenuItemW(hSubMenu
, FCIDM_MENU_VIEW_SEP_OPTIONS
, FALSE
, &mii
);
1028 /**********************************************************
1029 * ShellView_GetSelections()
1031 * - fills the this->apidl list with the selected objects
1034 * number of selected items
1036 UINT
CDefView::GetSelections()
1043 cidl
= ListView_GetSelectedCount(hWndList
);
1044 apidl
= (LPITEMIDLIST
*)SHAlloc(cidl
* sizeof(LPITEMIDLIST
));
1046 TRACE("selected=%i\n", cidl
);
1050 TRACE("-- Items selected =%u\n", cidl
);
1052 lvItem
.mask
= LVIF_STATE
| LVIF_PARAM
;
1053 lvItem
.stateMask
= LVIS_SELECTED
;
1055 lvItem
.iSubItem
= 0;
1058 while(SendMessageW(hWndList
, LVM_GETITEMW
, 0, (LPARAM
)&lvItem
) && (i
< cidl
))
1060 if(lvItem
.state
& LVIS_SELECTED
)
1062 apidl
[i
] = (LPITEMIDLIST
)lvItem
.lParam
;
1066 TRACE("-- selected Item found\n");
1075 /**********************************************************
1076 * ShellView_OpenSelectedItems()
1078 HRESULT
CDefView::OpenSelectedItems()
1080 static UINT CF_IDLIST
= 0;
1082 CComPtr
<IDataObject
> selection
;
1083 CComPtr
<IContextMenu
> cm
;
1088 LPCITEMIDLIST parent_pidl
;
1089 WCHAR parent_path
[MAX_PATH
];
1090 LPCWSTR parent_dir
= NULL
;
1093 CMINVOKECOMMANDINFOEX ici
;
1096 if (0 == GetSelections())
1101 hr
= pSFParent
->GetUIObjectOf(m_hWnd
, cidl
,
1102 (LPCITEMIDLIST
*)apidl
, IID_IContextMenu
,
1107 hmenu
= CreatePopupMenu();
1110 hr
= IUnknown_SetSite(cm
, (IShellView
*)this);
1111 if (SUCCEEDED(cm
->QueryContextMenu(hmenu
, 0, 0x20, 0x7fff, CMF_DEFAULTONLY
)))
1113 INT def
= -1, n
= GetMenuItemCount(hmenu
);
1115 for ( i
= 0; i
< n
; i
++ )
1117 memset( &info
, 0, sizeof info
);
1118 info
.cbSize
= sizeof info
;
1119 info
.fMask
= MIIM_FTYPE
| MIIM_STATE
| MIIM_ID
;
1120 if (GetMenuItemInfoW( hmenu
, i
, TRUE
, &info
))
1122 if (info
.fState
& MFS_DEFAULT
)
1131 memset( &ici
, 0, sizeof ici
);
1132 ici
.cbSize
= sizeof ici
;
1133 ici
.lpVerb
= MAKEINTRESOURCEA( def
);
1136 hr
= cm
->InvokeCommand((LPCMINVOKECOMMANDINFO
)&ici
);
1140 hr
= IUnknown_SetSite(cm
, NULL
);
1144 ERR("InvokeCommand failed: %x\n", hr
);
1147 ERR("No default context menu item\n");
1150 DestroyMenu( hmenu
);
1151 hr
= IUnknown_SetSite(cm
, NULL
);
1157 hr
= pSFParent
->GetUIObjectOf(m_hWnd
, cidl
,
1158 (LPCITEMIDLIST
*)apidl
, IID_IDataObject
,
1159 0, (LPVOID
*)&selection
);
1168 CF_IDLIST
= RegisterClipboardFormatW(CFSTR_SHELLIDLIST
);
1171 fetc
.cfFormat
= CF_IDLIST
;
1173 fetc
.dwAspect
= DVASPECT_CONTENT
;
1175 fetc
.tymed
= TYMED_HGLOBAL
;
1177 hr
= selection
->QueryGetData(&fetc
);
1181 hr
= selection
->GetData(&fetc
, &stgm
);
1185 pIDList
= (LPIDA
)GlobalLock(stgm
.hGlobal
);
1187 parent_pidl
= (LPCITEMIDLIST
) ((LPBYTE
)pIDList
+ pIDList
->aoffset
[0]);
1188 hr
= pSFParent
->GetAttributesOf(1, &parent_pidl
, &attribs
);
1189 if (SUCCEEDED(hr
) && (attribs
& SFGAO_FILESYSTEM
) &&
1190 SHGetPathFromIDListW(parent_pidl
, parent_path
))
1192 parent_dir
= parent_path
;
1195 for (i
= pIDList
->cidl
; i
> 0; --i
)
1199 pidl
= (LPCITEMIDLIST
)((LPBYTE
)pIDList
+ pIDList
->aoffset
[i
]);
1201 attribs
= SFGAO_FOLDER
;
1202 hr
= pSFParent
->GetAttributesOf(1, &pidl
, &attribs
);
1204 if (SUCCEEDED(hr
) && ! (attribs
& SFGAO_FOLDER
))
1206 SHELLEXECUTEINFOW shexinfo
;
1208 shexinfo
.cbSize
= sizeof(SHELLEXECUTEINFOW
);
1209 shexinfo
.fMask
= SEE_MASK_INVOKEIDLIST
; /* SEE_MASK_IDLIST is also possible. */
1210 shexinfo
.hwnd
= NULL
;
1211 shexinfo
.lpVerb
= NULL
;
1212 shexinfo
.lpFile
= NULL
;
1213 shexinfo
.lpParameters
= NULL
;
1214 shexinfo
.lpDirectory
= parent_dir
;
1215 shexinfo
.nShow
= SW_NORMAL
;
1216 shexinfo
.lpIDList
= ILCombine(parent_pidl
, pidl
);
1218 ShellExecuteExW(&shexinfo
); /* Discard error/success info */
1220 ILFree((LPITEMIDLIST
)shexinfo
.lpIDList
);
1224 GlobalUnlock(stgm
.hGlobal
);
1225 ReleaseStgMedium(&stgm
);
1230 /**********************************************************
1231 * ShellView_DoContextMenu()
1233 LRESULT
CDefView::OnContextMenu(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
1242 CMINVOKECOMMANDINFO cmi
;
1245 // for some reason I haven't figured out, we sometimes recurse into this method
1252 TRACE("(%p)->(0x%08x 0x%08x) stub\n", this, x
, y
);
1257 /* look, what's selected and create a context menu object of it*/
1258 if (GetSelections())
1260 pSFParent
->GetUIObjectOf(hWndParent
, cidl
, (LPCITEMIDLIST
*)apidl
, IID_IContextMenu
, NULL
, (LPVOID
*)&pCM
);
1264 TRACE("-- pContextMenu\n");
1265 hMenu
= CreatePopupMenu();
1269 hResult
= IUnknown_SetSite(pCM
, (IShellView
*)this);
1271 /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
1272 if (SUCCEEDED(pShellBrowser
->GetControlWindow(FCW_TREE
, &hwndTree
)) && hwndTree
)
1274 TRACE("-- explore mode\n");
1278 /* build the flags depending on what we can do with the selected item */
1279 wFlags
= CMF_NORMAL
| (cidl
!= 1 ? 0 : CMF_CANRENAME
) | (fExplore
? CMF_EXPLORE
: 0);
1281 /* let the ContextMenu merge its items in */
1282 if (SUCCEEDED(pCM
->QueryContextMenu(hMenu
, 0, FCIDM_SHVIEWFIRST
, FCIDM_SHVIEWLAST
, wFlags
)))
1284 if (FolderSettings
.fFlags
& FWF_DESKTOP
)
1285 SetMenuDefaultItem(hMenu
, FCIDM_SHVIEW_OPEN
, MF_BYCOMMAND
);
1287 TRACE("-- track popup\n");
1288 uCommand
= TrackPopupMenu( hMenu
, TPM_LEFTALIGN
| TPM_RETURNCMD
, x
, y
, 0, m_hWnd
, NULL
);
1292 TRACE("-- uCommand=%u\n", uCommand
);
1294 if (uCommand
== FCIDM_SHVIEW_OPEN
&& pCommDlgBrowser
.p
!= NULL
)
1296 TRACE("-- dlg: OnDefaultCommand\n");
1297 if (OnDefaultCommand() != S_OK
)
1298 OpenSelectedItems();
1302 TRACE("-- explore -- invoke command\n");
1303 ZeroMemory(&cmi
, sizeof(cmi
));
1304 cmi
.cbSize
= sizeof(cmi
);
1305 cmi
.hwnd
= hWndParent
; /* this window has to answer CWM_GETISHELLBROWSER */
1306 cmi
.lpVerb
= (LPCSTR
)MAKEINTRESOURCEA(uCommand
);
1307 pCM
->InvokeCommand(&cmi
);
1311 hResult
= IUnknown_SetSite(pCM
, NULL
);
1318 else /* background context menu */
1320 hMenu
= CreatePopupMenu();
1322 CDefFolderMenu_Create2(NULL
, NULL
, cidl
, (LPCITEMIDLIST
*)apidl
, pSFParent
, NULL
, 0, NULL
, (IContextMenu
**)&pCM
);
1323 pCM
->QueryContextMenu(hMenu
, 0, FCIDM_SHVIEWFIRST
, FCIDM_SHVIEWLAST
, 0);
1325 uCommand
= TrackPopupMenu(hMenu
, TPM_LEFTALIGN
| TPM_RETURNCMD
, x
, y
, 0, m_hWnd
, NULL
);
1328 TRACE("-- (%p)->(uCommand=0x%08x )\n", this, uCommand
);
1330 ZeroMemory(&cmi
, sizeof(cmi
));
1331 cmi
.cbSize
= sizeof(cmi
);
1332 cmi
.lpVerb
= (LPCSTR
)MAKEINTRESOURCEA(uCommand
);
1333 cmi
.hwnd
= hWndParent
;
1334 pCM
->InvokeCommand(&cmi
);
1342 /**********************************************************
1343 * ##### message handling #####
1346 /**********************************************************
1347 * ShellView_OnSize()
1349 LRESULT
CDefView::OnSize(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
1354 wWidth
= LOWORD(lParam
);
1355 wHeight
= HIWORD(lParam
);
1357 TRACE("%p width=%u height=%u\n", this, wWidth
, wHeight
);
1359 /*resize the ListView to fit our window*/
1362 ::MoveWindow(hWndList
, 0, 0, wWidth
, wHeight
, TRUE
);
1368 /**********************************************************
1369 * ShellView_OnDeactivate()
1374 void CDefView::OnDeactivate()
1376 TRACE("%p\n", this);
1378 if (uState
!= SVUIA_DEACTIVATE
)
1382 pShellBrowser
->SetMenuSB(0, 0, 0);
1383 pShellBrowser
->RemoveMenusSB(hMenu
);
1388 uState
= SVUIA_DEACTIVATE
;
1392 void CDefView::DoActivate(UINT uState
)
1394 OLEMENUGROUPWIDTHS omw
= { {0, 0, 0, 0, 0, 0} };
1396 CHAR szText
[MAX_PATH
];
1398 TRACE("%p uState=%x\n", this, uState
);
1400 /*don't do anything if the state isn't really changing */
1401 if (uState
== uState
)
1408 /*only do This if we are active */
1409 if(uState
!= SVUIA_DEACTIVATE
)
1411 /*merge the menus */
1412 hMenu
= CreateMenu();
1416 pShellBrowser
->InsertMenusSB(hMenu
, &omw
);
1417 TRACE("-- after fnInsertMenusSB\n");
1419 /*build the top level menu get the menu item's text*/
1420 strcpy(szText
, "dummy 31");
1422 ZeroMemory(&mii
, sizeof(mii
));
1423 mii
.cbSize
= sizeof(mii
);
1424 mii
.fMask
= MIIM_SUBMENU
| MIIM_TYPE
| MIIM_STATE
;
1425 mii
.fType
= MFT_STRING
;
1426 mii
.fState
= MFS_ENABLED
;
1427 mii
.dwTypeData
= szText
;
1428 mii
.hSubMenu
= BuildFileMenu();
1430 /*insert our menu into the menu bar*/
1433 InsertMenuItemA(hMenu
, FCIDM_MENU_HELP
, FALSE
, &mii
);
1436 /*get the view menu so we can merge with it*/
1437 ZeroMemory(&mii
, sizeof(mii
));
1438 mii
.cbSize
= sizeof(mii
);
1439 mii
.fMask
= MIIM_SUBMENU
;
1441 if (GetMenuItemInfoA(hMenu
, FCIDM_MENU_VIEW
, FALSE
, &mii
))
1443 MergeViewMenu(mii
.hSubMenu
);
1446 /*add the items that should only be added if we have the focus*/
1447 if (SVUIA_ACTIVATE_FOCUS
== uState
)
1449 /*get the file menu so we can merge with it */
1450 ZeroMemory(&mii
, sizeof(mii
));
1451 mii
.cbSize
= sizeof(mii
);
1452 mii
.fMask
= MIIM_SUBMENU
;
1454 if (GetMenuItemInfoA(hMenu
, FCIDM_MENU_FILE
, FALSE
, &mii
))
1456 MergeFileMenu(mii
.hSubMenu
);
1460 TRACE("-- before fnSetMenuSB\n");
1461 pShellBrowser
->SetMenuSB(hMenu
, 0, m_hWnd
);
1468 /**********************************************************
1469 * ShellView_OnActivate()
1471 LRESULT
CDefView::OnActivate(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
1473 DoActivate(SVUIA_ACTIVATE_FOCUS
);
1477 /**********************************************************
1478 * ShellView_OnSetFocus()
1481 LRESULT
CDefView::OnSetFocus(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
1483 TRACE("%p\n", this);
1485 /* Tell the browser one of our windows has received the focus. This
1486 should always be done before merging menus (OnActivate merges the
1487 menus) if one of our windows has the focus.*/
1489 pShellBrowser
->OnViewWindowActive((IShellView
*)this);
1490 DoActivate(SVUIA_ACTIVATE_FOCUS
);
1492 /* Set the focus to the listview */
1493 ::SetFocus(hWndList
);
1495 /* Notify the ICommDlgBrowser interface */
1496 OnStateChange(CDBOSC_SETFOCUS
);
1501 /**********************************************************
1502 * ShellView_OnKillFocus()
1504 LRESULT
CDefView::OnKillFocus(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
1506 TRACE("(%p) stub\n", this);
1508 DoActivate(SVUIA_ACTIVATE_NOFOCUS
);
1509 /* Notify the ICommDlgBrowser */
1510 OnStateChange(CDBOSC_KILLFOCUS
);
1515 /**********************************************************
1516 * ShellView_OnCommand()
1519 * the CmdID's are the ones from the context menu
1521 LRESULT
CDefView::OnCommand(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
1527 dwCmdID
= GET_WM_COMMAND_ID(wParam
, lParam
);
1528 dwCmd
= GET_WM_COMMAND_CMD(wParam
, lParam
);
1529 hwndCmd
= GET_WM_COMMAND_HWND(wParam
, lParam
);
1531 TRACE("(%p)->(0x%08x 0x%08x %p) stub\n", this, dwCmdID
, dwCmd
, hwndCmd
);
1535 case FCIDM_SHVIEW_SMALLICON
:
1536 FolderSettings
.ViewMode
= FVM_SMALLICON
;
1537 SetStyle (LVS_SMALLICON
, LVS_TYPEMASK
);
1541 case FCIDM_SHVIEW_BIGICON
:
1542 FolderSettings
.ViewMode
= FVM_ICON
;
1543 SetStyle (LVS_ICON
, LVS_TYPEMASK
);
1547 case FCIDM_SHVIEW_LISTVIEW
:
1548 FolderSettings
.ViewMode
= FVM_LIST
;
1549 SetStyle (LVS_LIST
, LVS_TYPEMASK
);
1553 case FCIDM_SHVIEW_REPORTVIEW
:
1554 FolderSettings
.ViewMode
= FVM_DETAILS
;
1555 SetStyle (LVS_REPORT
, LVS_TYPEMASK
);
1559 /* the menu-ID's for sorting are 0x30... see shrec.rc */
1564 ListViewSortInfo
.nHeaderID
= (LPARAM
) (dwCmdID
- 0x30);
1565 ListViewSortInfo
.bIsAscending
= TRUE
;
1566 ListViewSortInfo
.nLastHeaderID
= ListViewSortInfo
.nHeaderID
;
1567 SendMessageA(hWndList
, LVM_SORTITEMS
, (WPARAM
) &ListViewSortInfo
, (LPARAM
)ListViewCompareItems
);
1571 TRACE("-- COMMAND 0x%04x unhandled\n", dwCmdID
);
1577 /**********************************************************
1578 * ShellView_OnNotify()
1581 LRESULT
CDefView::OnNotify(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
1585 LPNMLISTVIEW lpnmlv
;
1586 NMLVDISPINFOW
*lpdi
;
1591 lpnmh
= (LPNMHDR
)lParam
;
1592 lpnmlv
= (LPNMLISTVIEW
)lpnmh
;
1593 lpdi
= (NMLVDISPINFOW
*)lpnmh
;
1595 TRACE("%p CtlID=%u lpnmh->code=%x\n", this, CtlID
, lpnmh
->code
);
1597 switch (lpnmh
->code
)
1600 TRACE("-- NM_SETFOCUS %p\n", this);
1601 OnSetFocus(0, 0, 0, unused
);
1605 TRACE("-- NM_KILLFOCUS %p\n", this);
1607 /* Notify the ICommDlgBrowser interface */
1608 OnStateChange(CDBOSC_KILLFOCUS
);
1612 TRACE("-- NM_CUSTOMDRAW %p\n", this);
1613 return CDRF_DODEFAULT
;
1615 case NM_RELEASEDCAPTURE
:
1616 TRACE("-- NM_RELEASEDCAPTURE %p\n", this);
1620 TRACE("-- NM_CLICK %p\n", this);
1624 TRACE("-- NM_RCLICK %p\n", this);
1628 TRACE("-- NM_DBLCLK %p\n", this);
1629 if (OnDefaultCommand() != S_OK
) OpenSelectedItems();
1633 TRACE("-- NM_RETURN %p\n", this);
1634 if (OnDefaultCommand() != S_OK
) OpenSelectedItems();
1638 TRACE("-- HDN_ENDTRACKW %p\n", this);
1639 /*nColumn1 = ListView_GetColumnWidth(hWndList, 0);
1640 nColumn2 = ListView_GetColumnWidth(hWndList, 1);*/
1643 case LVN_DELETEITEM
:
1644 TRACE("-- LVN_DELETEITEM %p\n", this);
1645 SHFree((LPITEMIDLIST
)lpnmlv
->lParam
); /*delete the pidl because we made a copy of it*/
1648 case LVN_DELETEALLITEMS
:
1649 TRACE("-- LVN_DELETEALLITEMS %p\n", this);
1652 case LVN_INSERTITEM
:
1653 TRACE("-- LVN_INSERTITEM (STUB)%p\n", this);
1656 case LVN_ITEMACTIVATE
:
1657 TRACE("-- LVN_ITEMACTIVATE %p\n", this);
1658 OnStateChange(CDBOSC_SELCHANGE
); /* the browser will get the IDataObject now */
1661 case LVN_COLUMNCLICK
:
1662 ListViewSortInfo
.nHeaderID
= lpnmlv
->iSubItem
;
1663 if (ListViewSortInfo
.nLastHeaderID
== ListViewSortInfo
.nHeaderID
)
1665 ListViewSortInfo
.bIsAscending
= !ListViewSortInfo
.bIsAscending
;
1669 ListViewSortInfo
.bIsAscending
= TRUE
;
1671 ListViewSortInfo
.nLastHeaderID
= ListViewSortInfo
.nHeaderID
;
1673 SendMessageW(lpnmlv
->hdr
.hwndFrom
, LVM_SORTITEMS
, (WPARAM
) &ListViewSortInfo
, (LPARAM
)ListViewCompareItems
);
1676 case LVN_GETDISPINFOA
:
1677 case LVN_GETDISPINFOW
:
1678 TRACE("-- LVN_GETDISPINFO %p\n", this);
1679 pidl
= (LPITEMIDLIST
)lpdi
->item
.lParam
;
1681 if (lpdi
->item
.mask
& LVIF_TEXT
) /* text requested */
1686 if (FAILED(pSF2Parent
->GetDetailsOf(pidl
, lpdi
->item
.iSubItem
, &sd
)))
1688 FIXME("failed to get details\n");
1692 if (lpnmh
->code
== LVN_GETDISPINFOA
)
1694 /* shouldn't happen */
1695 NMLVDISPINFOA
*lpdiA
= (NMLVDISPINFOA
*)lpnmh
;
1696 StrRetToStrNA( lpdiA
->item
.pszText
, lpdiA
->item
.cchTextMax
, &sd
.str
, NULL
);
1697 TRACE("-- text=%s\n", lpdiA
->item
.pszText
);
1699 else /* LVN_GETDISPINFOW */
1701 StrRetToStrNW( lpdi
->item
.pszText
, lpdi
->item
.cchTextMax
, &sd
.str
, NULL
);
1702 TRACE("-- text=%s\n", debugstr_w(lpdi
->item
.pszText
));
1710 if(lpdi
->item
.mask
& LVIF_IMAGE
) /* image requested */
1712 lpdi
->item
.iImage
= SHMapPIDLToSystemImageListIndex(pSFParent
, pidl
, 0);
1714 lpdi
->item
.mask
|= LVIF_DI_SETITEM
;
1717 case LVN_ITEMCHANGED
:
1718 TRACE("-- LVN_ITEMCHANGED %p\n", this);
1719 OnStateChange(CDBOSC_SELCHANGE
); /* the browser will get the IDataObject now */
1723 case LVN_BEGINRDRAG
:
1724 TRACE("-- LVN_BEGINDRAG\n");
1726 if (GetSelections())
1729 DWORD dwAttributes
= SFGAO_CANLINK
;
1730 DWORD dwEffect
= DROPEFFECT_COPY
| DROPEFFECT_MOVE
;
1732 if (SUCCEEDED(pSFParent
->GetUIObjectOf(m_hWnd
, cidl
, (LPCITEMIDLIST
*)apidl
, IID_IDataObject
, 0, (LPVOID
*)&pda
)))
1734 IDropSource
* pds
= (IDropSource
*)this; /* own DropSource interface */
1736 if (SUCCEEDED(pSFParent
->GetAttributesOf(cidl
, (LPCITEMIDLIST
*)apidl
, &dwAttributes
)))
1738 if (dwAttributes
& SFGAO_CANLINK
)
1740 dwEffect
|= DROPEFFECT_LINK
;
1747 DoDragDrop(pda
, pds
, dwEffect
, &dwEffect2
);
1754 case LVN_BEGINLABELEDITW
:
1756 DWORD dwAttr
= SFGAO_CANRENAME
;
1757 pidl
= (LPITEMIDLIST
)lpdi
->item
.lParam
;
1759 TRACE("-- LVN_BEGINLABELEDITW %p\n", this);
1761 pSFParent
->GetAttributesOf(1, (LPCITEMIDLIST
*)&pidl
, &dwAttr
);
1762 if (SFGAO_CANRENAME
& dwAttr
)
1769 case LVN_ENDLABELEDITW
:
1771 TRACE("-- LVN_ENDLABELEDITW %p\n", this);
1772 if (lpdi
->item
.pszText
)
1777 lvItem
.iItem
= lpdi
->item
.iItem
;
1778 lvItem
.iSubItem
= 0;
1779 lvItem
.mask
= LVIF_PARAM
;
1780 SendMessageW(hWndList
, LVM_GETITEMW
, 0, (LPARAM
) &lvItem
);
1782 pidl
= (LPITEMIDLIST
)lpdi
->item
.lParam
;
1783 hr
= pSFParent
->SetNameOf(0, pidl
, lpdi
->item
.pszText
, SHGDN_INFOLDER
, &pidl
);
1785 if (SUCCEEDED(hr
) && pidl
)
1787 lvItem
.mask
= LVIF_PARAM
|LVIF_IMAGE
;
1788 lvItem
.lParam
= (LPARAM
)pidl
;
1789 lvItem
.iImage
= SHMapPIDLToSystemImageListIndex(pSFParent
, pidl
, 0);
1790 SendMessageW(hWndList
, LVM_SETITEMW
, 0, (LPARAM
) &lvItem
);
1791 SendMessageW(hWndList
, LVM_UPDATE
, lpdi
->item
.iItem
, 0);
1804 msg.message = WM_KEYDOWN;
1805 msg.wParam = plvKeyDown->wVKey;
1810 LPNMLVKEYDOWN plvKeyDown
= (LPNMLVKEYDOWN
) lpnmh
;
1811 SHORT ctrl
= GetKeyState(VK_CONTROL
) & 0x8000;
1813 /* initiate a rename of the selected file or directory */
1814 if (plvKeyDown
->wVKey
== VK_F2
)
1816 /* see how many files are selected */
1817 int i
= ListView_GetSelectedCount(hWndList
);
1819 /* get selected item */
1822 /* get selected item */
1823 i
= ListView_GetNextItem(hWndList
, -1, LVNI_SELECTED
);
1825 SendMessageW(hWndList
, LVM_ENSUREVISIBLE
, i
, 0);
1826 SendMessageW(hWndList
, LVM_EDITLABELW
, i
, 0);
1830 TranslateAccelerator(m_hWnd
, hAccel
, &msg
)
1832 else if(plvKeyDown
->wVKey
== VK_DELETE
)
1837 LPITEMIDLIST
* pItems
;
1840 pSFParent
->QueryInterface(IID_ISFHelper
,
1846 if (!(i
= ListView_GetSelectedCount(hWndList
)))
1849 /* allocate memory for the pidl array */
1850 pItems
= (LPITEMIDLIST
*)HeapAlloc(GetProcessHeap(), 0,
1851 sizeof(LPITEMIDLIST
) * i
);
1853 /* retrieve all selected items */
1856 while (ListView_GetSelectedCount(hWndList
) > i
)
1858 /* get selected item */
1859 item_index
= ListView_GetNextItem(hWndList
,
1860 item_index
, LVNI_SELECTED
);
1861 item
.iItem
= item_index
;
1862 item
.mask
= LVIF_PARAM
;
1863 SendMessageA(hWndList
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1866 pItems
[i
] = (LPITEMIDLIST
)item
.lParam
;
1871 /* perform the item deletion */
1872 psfhlp
->DeleteItems(i
, (LPCITEMIDLIST
*)pItems
);
1874 /* free pidl array memory */
1875 HeapFree(GetProcessHeap(), 0, pItems
);
1877 /* Initiate a refresh */
1878 else if (plvKeyDown
->wVKey
== VK_F5
)
1882 else if (plvKeyDown
->wVKey
== VK_BACK
)
1884 LPSHELLBROWSER lpSb
;
1885 if ((lpSb
= (LPSHELLBROWSER
)SendMessageW(hWndParent
, CWM_GETISHELLBROWSER
, 0, 0)))
1887 lpSb
->BrowseObject(NULL
, SBSP_PARENT
);
1890 else if (plvKeyDown
->wVKey
== 'C' && ctrl
)
1892 if (GetSelections())
1894 CComPtr
<IDataObject
> pda
;
1896 if (SUCCEEDED(pSFParent
->GetUIObjectOf(m_hWnd
, cidl
, (LPCITEMIDLIST
*)apidl
, IID_IDataObject
, 0, (LPVOID
*)&pda
)))
1898 HRESULT hr
= OleSetClipboard(pda
);
1901 WARN("OleSetClipboard failed");
1907 else if(plvKeyDown
->wVKey
== 'V' && ctrl
)
1909 CComPtr
<IDataObject
> pda
;
1911 FORMATETC formatetc
;
1912 LPITEMIDLIST
* apidl
;
1914 CComPtr
<IShellFolder
> psfFrom
;
1915 CComPtr
<IShellFolder
> psfDesktop
;
1916 CComPtr
<IShellFolder
> psfTarget
;
1918 CComPtr
<ISFHelper
> psfhlpdst
;
1919 CComPtr
<ISFHelper
> psfhlpsrc
;
1922 hr
= OleGetClipboard(&pda
);
1925 ERR("Failed to get clipboard with %lx\n", hr
);
1929 InitFormatEtc(formatetc
, RegisterClipboardFormatW(CFSTR_SHELLIDLIST
), TYMED_HGLOBAL
);
1930 hr
= pda
->GetData(&formatetc
, &medium
);
1934 ERR("Failed to get clipboard data with %lx\n", hr
);
1938 /* lock the handle */
1939 lpcida
= (LPIDA
)GlobalLock(medium
.hGlobal
);
1942 ERR("failed to lock pidl\n");
1943 ReleaseStgMedium(&medium
);
1947 /* convert the data into pidl */
1948 apidl
= _ILCopyCidaToaPidl(&pidl
, lpcida
);
1952 ERR("failed to copy pidl\n");
1956 if (FAILED(SHGetDesktopFolder(&psfDesktop
)))
1958 ERR("failed to get desktop folder\n");
1960 _ILFreeaPidl(apidl
, lpcida
->cidl
);
1961 ReleaseStgMedium(&medium
);
1965 if (_ILIsDesktop(pidl
))
1967 /* use desktop shellfolder */
1968 psfFrom
= psfDesktop
;
1970 else if (FAILED(psfDesktop
->BindToObject(pidl
, NULL
, IID_IShellFolder
, (LPVOID
*)&psfFrom
)))
1972 ERR("no IShellFolder\n");
1975 _ILFreeaPidl(apidl
, lpcida
->cidl
);
1976 ReleaseStgMedium(&medium
);
1981 psfTarget
= pSFParent
;
1984 /* get source and destination shellfolder */
1985 if (FAILED(psfTarget
->QueryInterface(IID_ISFHelper
, (LPVOID
*)&psfhlpdst
)))
1987 ERR("no IID_ISFHelper for destination\n");
1990 _ILFreeaPidl(apidl
, lpcida
->cidl
);
1991 ReleaseStgMedium(&medium
);
1996 if (FAILED(psfFrom
->QueryInterface(IID_ISFHelper
, (LPVOID
*)&psfhlpsrc
)))
1998 ERR("no IID_ISFHelper for source\n");
2001 _ILFreeaPidl(apidl
, lpcida
->cidl
);
2002 ReleaseStgMedium(&medium
);
2007 * do we want to perform a copy or move ???
2009 hr
= psfhlpdst
->CopyItems(psfFrom
, lpcida
->cidl
, (LPCITEMIDLIST
*)apidl
);
2012 _ILFreeaPidl(apidl
, lpcida
->cidl
);
2013 ReleaseStgMedium(&medium
);
2015 TRACE("paste end hr %x\n", hr
);
2019 FIXME("LVN_KEYDOWN key=0x%08x\n", plvKeyDown
->wVKey
);
2024 TRACE("-- %p WM_COMMAND %x unhandled\n", this, lpnmh
->code
);
2031 /**********************************************************
2032 * ShellView_OnChange()
2034 LRESULT
CDefView::OnChangeNotify(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
2036 LPITEMIDLIST
*Pidls
;
2038 Pidls
= (LPITEMIDLIST
*)wParam
;
2040 TRACE("(%p)(%p,%p,0x%08x)\n", this, Pidls
[0], Pidls
[1], lParam
);
2046 LV_AddItem(Pidls
[0]);
2051 LV_DeleteItem(Pidls
[0]);
2054 case SHCNE_RENAMEFOLDER
:
2055 case SHCNE_RENAMEITEM
:
2056 LV_RenameItem(Pidls
[0], Pidls
[1]);
2059 case SHCNE_UPDATEITEM
:
2066 /**********************************************************
2067 * ShellView_DoMeasureItem
2069 LRESULT
CDefView::OnCustomItem(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
2074 ERR("no menu!!!\n");
2078 if (pCM
.p
->HandleMenuMsg(uMsg
, (WPARAM
)m_hWnd
, lParam
) == S_OK
)
2084 /**********************************************************
2087 * The INTERFACE of the IShellView object
2090 **********************************************************
2093 /**********************************************************
2094 * ShellView_GetWindow
2096 HRESULT WINAPI
CDefView::GetWindow(HWND
*phWnd
)
2098 TRACE("(%p)\n", this);
2105 HRESULT WINAPI
CDefView::ContextSensitiveHelp(BOOL fEnterMode
)
2107 FIXME("(%p) stub\n", this);
2112 /**********************************************************
2113 * IShellView_TranslateAccelerator
2116 * use the accel functions
2118 HRESULT WINAPI
CDefView::TranslateAccelerator(LPMSG lpmsg
)
2121 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%x wp=%x) stub\n", this, lpmsg
, lpmsg
->hwnd
, lpmsg
->message
, lpmsg
->lParam
, lpmsg
->wParam
);
2124 if (lpmsg
->message
>= WM_KEYFIRST
&& lpmsg
->message
>= WM_KEYLAST
)
2126 TRACE("-- key=0x04%lx\n", lpmsg
->wParam
) ;
2129 return S_FALSE
; /* not handled */
2132 HRESULT WINAPI
CDefView::EnableModeless(BOOL fEnable
)
2134 FIXME("(%p) stub\n", this);
2139 HRESULT WINAPI
CDefView::UIActivate(UINT uState
)
2142 CHAR szName[MAX_PATH];
2145 int nPartArray
[1] = { -1};
2147 TRACE("(%p)->(state=%x) stub\n", this, uState
);
2149 /*don't do anything if the state isn't really changing*/
2150 if (uState
== uState
)
2155 /*OnActivate handles the menu merging and internal state*/
2158 /*only do This if we are active*/
2159 if (uState
!= SVUIA_DEACTIVATE
)
2163 GetFolderPath is not a method of IShellFolder
2164 IShellFolder_GetFolderPath( pSFParent, szName, sizeof(szName) );
2166 /* set the number of parts */
2167 pShellBrowser
->SendControlMsg(FCW_STATUS
, SB_SETPARTS
, 1, (LPARAM
)nPartArray
, &lResult
);
2169 /* set the text for the parts */
2171 pShellBrowser->SendControlMsg(FCW_STATUS, SB_SETTEXTA, 0, (LPARAM)szName, &lResult);
2178 HRESULT WINAPI
CDefView::Refresh()
2180 TRACE("(%p)\n", this);
2182 SendMessageW(hWndList
, LVM_DELETEALLITEMS
, 0, 0);
2188 HRESULT WINAPI
CDefView::CreateViewWindow(IShellView
*lpPrevView
, LPCFOLDERSETTINGS lpfs
, IShellBrowser
*psb
, RECT
*prcView
, HWND
*phWnd
)
2192 TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n", this, lpPrevView
, lpfs
, psb
, prcView
, phWnd
);
2195 TRACE("-- vmode=%x flags=%x\n", lpfs
->ViewMode
, lpfs
->fFlags
);
2196 if (prcView
!= NULL
)
2197 TRACE("-- left=%i top=%i right=%i bottom=%i\n", prcView
->left
, prcView
->top
, prcView
->right
, prcView
->bottom
);
2199 /* Validate the Shell Browser */
2201 return E_UNEXPECTED
;
2203 /*set up the member variables*/
2204 pShellBrowser
= psb
;
2205 FolderSettings
= *lpfs
;
2207 /*get our parent window*/
2208 pShellBrowser
->GetWindow(&hWndParent
);
2210 /* try to get the ICommDlgBrowserInterface, adds a reference !!! */
2211 pCommDlgBrowser
= NULL
;
2212 if (SUCCEEDED(pShellBrowser
->QueryInterface(IID_ICommDlgBrowser
, (LPVOID
*)&pCommDlgBrowser
)))
2214 TRACE("-- CommDlgBrowser\n");
2217 Create(hWndParent
, prcView
, NULL
, WS_CHILD
| WS_TABSTOP
, 0, 0U);
2228 SetWindowPos(HWND_TOP
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
| SWP_SHOWWINDOW
);
2234 HRESULT WINAPI
CDefView::DestroyViewWindow()
2236 TRACE("(%p)\n", this);
2238 /*Make absolutely sure all our UI is cleaned up.*/
2239 UIActivate(SVUIA_DEACTIVATE
);
2247 pShellBrowser
.Release();
2248 pCommDlgBrowser
.Release();
2253 HRESULT WINAPI
CDefView::GetCurrentInfo(LPFOLDERSETTINGS lpfs
)
2255 TRACE("(%p)->(%p) vmode=%x flags=%x\n", this, lpfs
,
2256 FolderSettings
.ViewMode
, FolderSettings
.fFlags
);
2259 return E_INVALIDARG
;
2261 *lpfs
= FolderSettings
;
2265 HRESULT WINAPI
CDefView::AddPropertySheetPages(DWORD dwReserved
, LPFNADDPROPSHEETPAGE lpfn
, LPARAM lparam
)
2267 FIXME("(%p) stub\n", this);
2272 HRESULT WINAPI
CDefView::SaveViewState()
2274 FIXME("(%p) stub\n", this);
2279 HRESULT WINAPI
CDefView::SelectItem(LPCITEMIDLIST pidl
, UINT uFlags
)
2283 TRACE("(%p)->(pidl=%p, 0x%08x) stub\n", this, pidl
, uFlags
);
2285 i
= LV_FindItemByPidl(pidl
);
2291 if(uFlags
& SVSI_ENSUREVISIBLE
)
2292 SendMessageW(hWndList
, LVM_ENSUREVISIBLE
, i
, 0);
2294 lvItem
.mask
= LVIF_STATE
;
2295 lvItem
.stateMask
= LVIS_SELECTED
| LVIS_FOCUSED
;
2297 lvItem
.iSubItem
= 0;
2299 while (SendMessageW(hWndList
, LVM_GETITEMW
, 0, (LPARAM
) &lvItem
))
2301 if (lvItem
.iItem
== i
)
2303 if (uFlags
& SVSI_SELECT
)
2304 lvItem
.state
|= LVIS_SELECTED
;
2306 lvItem
.state
&= ~LVIS_SELECTED
;
2308 if (uFlags
& SVSI_FOCUSED
)
2309 lvItem
.state
&= ~LVIS_FOCUSED
;
2313 if (uFlags
& SVSI_DESELECTOTHERS
)
2314 lvItem
.state
&= ~LVIS_SELECTED
;
2317 SendMessageW(hWndList
, LVM_SETITEMW
, 0, (LPARAM
) &lvItem
);
2322 if(uFlags
& SVSI_EDIT
)
2323 SendMessageW(hWndList
, LVM_EDITLABELW
, i
, 0);
2329 HRESULT WINAPI
CDefView::GetItemObject(UINT uItem
, REFIID riid
, LPVOID
*ppvOut
)
2331 HRESULT hr
= E_NOINTERFACE
;
2333 TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n", this, uItem
, debugstr_guid(&riid
), ppvOut
);
2339 case SVGIO_BACKGROUND
:
2340 if (IsEqualIID(riid
, IID_IContextMenu
))
2342 //*ppvOut = ISvBgCm_Constructor(pSFParent, FALSE);
2343 CDefFolderMenu_Create2(NULL
, NULL
, cidl
, (LPCITEMIDLIST
*)apidl
, pSFParent
, NULL
, 0, NULL
, (IContextMenu
**)ppvOut
);
2351 case SVGIO_SELECTION
:
2353 hr
= pSFParent
->GetUIObjectOf(m_hWnd
, cidl
, (LPCITEMIDLIST
*)apidl
, riid
, 0, ppvOut
);
2357 TRACE("-- (%p)->(interface=%p)\n", this, *ppvOut
);
2362 HRESULT STDMETHODCALLTYPE
CDefView::GetCurrentViewMode(UINT
*pViewMode
)
2364 TRACE("(%p)->(%p), stub\n", this, pViewMode
);
2367 return E_INVALIDARG
;
2369 *pViewMode
= this->FolderSettings
.ViewMode
;
2373 HRESULT STDMETHODCALLTYPE
CDefView::SetCurrentViewMode(UINT ViewMode
)
2376 TRACE("(%p)->(%u), stub\n", this, ViewMode
);
2378 if ((ViewMode
< FVM_FIRST
|| ViewMode
> FVM_LAST
) /* && (ViewMode != FVM_AUTO) */ )
2379 return E_INVALIDARG
;
2381 /* Windows before Vista uses LVM_SETVIEW and possibly
2382 LVM_SETEXTENDEDLISTVIEWSTYLE to set the style of the listview,
2383 while later versions seem to accomplish this through other
2391 dwStyle
= LVS_REPORT
;
2394 dwStyle
= LVS_SMALLICON
;
2401 FIXME("ViewMode %d not implemented\n", ViewMode
);
2407 SetStyle(dwStyle
, LVS_TYPEMASK
);
2409 /* This will not necessarily be the actual mode set above.
2410 This mimics the behavior of Windows XP. */
2411 this->FolderSettings
.ViewMode
= ViewMode
;
2416 HRESULT STDMETHODCALLTYPE
CDefView::GetFolder(REFIID riid
, void **ppv
)
2418 if (pSFParent
== NULL
)
2421 return pSFParent
->QueryInterface(riid
, ppv
);
2424 HRESULT STDMETHODCALLTYPE
CDefView::Item(int iItemIndex
, LPITEMIDLIST
*ppidl
)
2428 TRACE("(%p)->(%d %p)\n", this, iItemIndex
, ppidl
);
2430 item
.mask
= LVIF_PARAM
;
2431 item
.iItem
= iItemIndex
;
2433 if (SendMessageW(this->hWndList
, LVM_GETITEMW
, 0, (LPARAM
)&item
))
2435 *ppidl
= ILClone((PITEMID_CHILD
)item
.lParam
);
2441 return E_INVALIDARG
;
2444 HRESULT STDMETHODCALLTYPE
CDefView::ItemCount(UINT uFlags
, int *pcItems
)
2446 TRACE("(%p)->(%u %p)\n", this, uFlags
, pcItems
);
2448 if (uFlags
!= SVGIO_ALLVIEW
)
2449 FIXME("some flags unsupported, %x\n", uFlags
& ~SVGIO_ALLVIEW
);
2451 *pcItems
= SendMessageW(this->hWndList
, LVM_GETITEMCOUNT
, 0, 0);
2456 HRESULT STDMETHODCALLTYPE
CDefView::Items(UINT uFlags
, REFIID riid
, void **ppv
)
2461 HRESULT STDMETHODCALLTYPE
CDefView::GetSelectionMarkedItem(int *piItem
)
2463 TRACE("(%p)->(%p)\n", this, piItem
);
2465 *piItem
= SendMessageW(this->hWndList
, LVM_GETSELECTIONMARK
, 0, 0);
2470 HRESULT STDMETHODCALLTYPE
CDefView::GetFocusedItem(int *piItem
)
2472 TRACE("(%p)->(%p)\n", this, piItem
);
2474 *piItem
= SendMessageW(this->hWndList
, LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
);
2479 HRESULT STDMETHODCALLTYPE
CDefView::GetItemPosition(LPCITEMIDLIST pidl
, POINT
*ppt
)
2484 HRESULT STDMETHODCALLTYPE
CDefView::GetSpacing(POINT
*ppt
)
2486 TRACE("(%p)->(%p)\n", this, ppt
);
2488 if (NULL
== this->hWndList
) return S_FALSE
;
2492 const DWORD ret
= SendMessageW(this->hWndList
, LVM_GETITEMSPACING
, 0, 0);
2494 ppt
->x
= LOWORD(ret
);
2495 ppt
->y
= HIWORD(ret
);
2501 HRESULT STDMETHODCALLTYPE
CDefView::GetDefaultSpacing(POINT
*ppt
)
2506 HRESULT STDMETHODCALLTYPE
CDefView::GetAutoArrange()
2511 HRESULT STDMETHODCALLTYPE
CDefView::SelectItem(int iItem
, DWORD dwFlags
)
2515 TRACE("(%p)->(%d, %x)\n", this, iItem
, dwFlags
);
2518 lvItem
.stateMask
= LVIS_SELECTED
;
2520 if (dwFlags
& SVSI_ENSUREVISIBLE
)
2521 SendMessageW(this->hWndList
, LVM_ENSUREVISIBLE
, iItem
, 0);
2524 if (dwFlags
& SVSI_DESELECTOTHERS
)
2525 SendMessageW(this->hWndList
, LVM_SETITEMSTATE
, -1, (LPARAM
)&lvItem
);
2528 if (dwFlags
& SVSI_SELECT
)
2529 lvItem
.state
|= LVIS_SELECTED
;
2531 if (dwFlags
& SVSI_FOCUSED
)
2532 lvItem
.stateMask
|= LVIS_FOCUSED
;
2534 SendMessageW(this->hWndList
, LVM_SETITEMSTATE
, iItem
, (LPARAM
)&lvItem
);
2536 if (dwFlags
& SVSI_EDIT
)
2537 SendMessageW(this->hWndList
, LVM_EDITLABELW
, iItem
, 0);
2542 HRESULT STDMETHODCALLTYPE
CDefView::SelectAndPositionItems(UINT cidl
, LPCITEMIDLIST
*apidl
, POINT
*apt
, DWORD dwFlags
)
2547 /**********************************************************
2548 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
2550 HRESULT WINAPI
CDefView::QueryStatus(const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD
*prgCmds
, OLECMDTEXT
*pCmdText
)
2552 FIXME("(%p)->(%p(%s) 0x%08x %p %p\n",
2553 this, pguidCmdGroup
, debugstr_guid(pguidCmdGroup
), cCmds
, prgCmds
, pCmdText
);
2556 return E_INVALIDARG
;
2558 for (UINT i
= 0; i
< cCmds
; i
++)
2560 FIXME("\tprgCmds[%d].cmdID = %d\n", i
, prgCmds
[i
].cmdID
);
2561 prgCmds
[i
].cmdf
= 0;
2564 return OLECMDERR_E_UNKNOWNGROUP
;
2567 /**********************************************************
2568 * ISVOleCmdTarget_Exec (IOleCommandTarget)
2570 * nCmdID is the OLECMDID_* enumeration
2572 HRESULT WINAPI
CDefView::Exec(const GUID
*pguidCmdGroup
, DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
2574 FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08x Opt:0x%08x %p %p)\n",
2575 this, debugstr_guid(pguidCmdGroup
), nCmdID
, nCmdexecopt
, pvaIn
, pvaOut
);
2578 return OLECMDERR_E_UNKNOWNGROUP
;
2580 if (IsEqualIID(*pguidCmdGroup
, CGID_Explorer
) &&
2582 (nCmdexecopt
== 4) && pvaOut
)
2585 if (IsEqualIID(*pguidCmdGroup
, CGID_ShellDocView
) &&
2590 return OLECMDERR_E_UNKNOWNGROUP
;
2593 /**********************************************************
2594 * ISVDropTarget implementation
2597 /******************************************************************************
2598 * drag_notify_subitem [Internal]
2600 * Figure out the shellfolder object, which is currently under the mouse cursor
2601 * and notify it via the IDropTarget interface.
2604 #define SCROLLAREAWIDTH 20
2606 HRESULT
CDefView::drag_notify_subitem(DWORD grfKeyState
, POINTL pt
, DWORD
*pdwEffect
)
2608 LVHITTESTINFO htinfo
;
2614 /* Map from global to client coordinates and query the index of the listview-item, which is
2615 * currently under the mouse cursor. */
2618 htinfo
.flags
= LVHT_ONITEM
;
2619 ::ScreenToClient(hWndList
, &htinfo
.pt
);
2620 lResult
= SendMessageW(hWndList
, LVM_HITTEST
, 0, (LPARAM
)&htinfo
);
2622 /* Send WM_*SCROLL messages every 250 ms during drag-scrolling */
2623 ::GetClientRect(hWndList
, &clientRect
);
2624 if (htinfo
.pt
.x
== ptLastMousePos
.x
&& htinfo
.pt
.y
== ptLastMousePos
.y
&&
2625 (htinfo
.pt
.x
< SCROLLAREAWIDTH
|| htinfo
.pt
.x
> clientRect
.right
- SCROLLAREAWIDTH
||
2626 htinfo
.pt
.y
< SCROLLAREAWIDTH
|| htinfo
.pt
.y
> clientRect
.bottom
- SCROLLAREAWIDTH
))
2628 cScrollDelay
= (cScrollDelay
+ 1) % 5; /* DragOver is called every 50 ms */
2629 if (cScrollDelay
== 0)
2631 /* Mouse did hover another 250 ms over the scroll-area */
2632 if (htinfo
.pt
.x
< SCROLLAREAWIDTH
)
2633 SendMessageW(hWndList
, WM_HSCROLL
, SB_LINEUP
, 0);
2635 if (htinfo
.pt
.x
> clientRect
.right
- SCROLLAREAWIDTH
)
2636 SendMessageW(hWndList
, WM_HSCROLL
, SB_LINEDOWN
, 0);
2638 if (htinfo
.pt
.y
< SCROLLAREAWIDTH
)
2639 SendMessageW(hWndList
, WM_VSCROLL
, SB_LINEUP
, 0);
2641 if (htinfo
.pt
.y
> clientRect
.bottom
- SCROLLAREAWIDTH
)
2642 SendMessageW(hWndList
, WM_VSCROLL
, SB_LINEDOWN
, 0);
2647 cScrollDelay
= 0; /* Reset, if the cursor is not over the listview's scroll-area */
2650 ptLastMousePos
= htinfo
.pt
;
2652 /* If we are still over the previous sub-item, notify it via DragOver and return. */
2653 if (pCurDropTarget
&& lResult
== iDragOverItem
)
2654 return pCurDropTarget
->DragOver(grfKeyState
, pt
, pdwEffect
);
2656 /* We've left the previous sub-item, notify it via DragLeave and Release it. */
2659 pCurDropTarget
->DragLeave();
2660 pCurDropTarget
.Release();
2663 iDragOverItem
= lResult
;
2666 /* We are not above one of the listview's subitems. Bind to the parent folder's
2667 * DropTarget interface. */
2668 hr
= pSFParent
->QueryInterface(IID_IDropTarget
,
2669 (LPVOID
*)&pCurDropTarget
);
2673 /* Query the relative PIDL of the shellfolder object represented by the currently
2674 * dragged over listview-item ... */
2675 lvItem
.mask
= LVIF_PARAM
;
2676 lvItem
.iItem
= lResult
;
2677 lvItem
.iSubItem
= 0;
2678 SendMessageW(hWndList
, LVM_GETITEMW
, 0, (LPARAM
) &lvItem
);
2680 /* ... and bind pCurDropTarget to the IDropTarget interface of an UIObject of this object */
2681 hr
= pSFParent
->GetUIObjectOf(hWndList
, 1,
2682 (LPCITEMIDLIST
*)&lvItem
.lParam
, IID_IDropTarget
, NULL
, (LPVOID
*)&pCurDropTarget
);
2685 /* If anything failed, pCurDropTarget should be NULL now, which ought to be a save state. */
2689 /* Notify the item just entered via DragEnter. */
2690 return pCurDropTarget
->DragEnter(pCurDataObject
, grfKeyState
, pt
, pdwEffect
);
2693 HRESULT WINAPI
CDefView::DragEnter(IDataObject
*pDataObject
, DWORD grfKeyState
, POINTL pt
, DWORD
*pdwEffect
)
2695 /* Get a hold on the data object for later calls to DragEnter on the sub-folders */
2696 pCurDataObject
= pDataObject
;
2697 pDataObject
->AddRef();
2699 return drag_notify_subitem(grfKeyState
, pt
, pdwEffect
);
2702 HRESULT WINAPI
CDefView::DragOver(DWORD grfKeyState
, POINTL pt
, DWORD
*pdwEffect
)
2704 return drag_notify_subitem(grfKeyState
, pt
, pdwEffect
);
2707 HRESULT WINAPI
CDefView::DragLeave()
2711 pCurDropTarget
->DragLeave();
2712 pCurDropTarget
.Release();
2715 if (pCurDataObject
!= NULL
)
2717 pCurDataObject
.Release();
2725 HRESULT WINAPI
CDefView::Drop(IDataObject
* pDataObject
, DWORD grfKeyState
, POINTL pt
, DWORD
*pdwEffect
)
2729 pCurDropTarget
->Drop(pDataObject
, grfKeyState
, pt
, pdwEffect
);
2730 pCurDropTarget
.Release();
2733 pCurDataObject
.Release();
2739 /**********************************************************
2740 * ISVDropSource implementation
2743 HRESULT WINAPI
CDefView::QueryContinueDrag(BOOL fEscapePressed
, DWORD grfKeyState
)
2745 TRACE("(%p)\n", this);
2748 return DRAGDROP_S_CANCEL
;
2749 else if (!(grfKeyState
& MK_LBUTTON
) && !(grfKeyState
& MK_RBUTTON
))
2750 return DRAGDROP_S_DROP
;
2755 HRESULT WINAPI
CDefView::GiveFeedback(DWORD dwEffect
)
2757 TRACE("(%p)\n", this);
2759 return DRAGDROP_S_USEDEFAULTCURSORS
;
2762 /**********************************************************
2763 * ISVViewObject implementation
2766 HRESULT WINAPI
CDefView::Draw(DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
, DVTARGETDEVICE
*ptd
, HDC hdcTargetDev
, HDC hdcDraw
, LPCRECTL lprcBounds
, LPCRECTL lprcWBounds
, BOOL (CALLBACK
*pfnContinue
)(ULONG_PTR dwContinue
), ULONG_PTR dwContinue
)
2768 FIXME("Stub: this=%p\n", this);
2773 HRESULT WINAPI
CDefView::GetColorSet(DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
, DVTARGETDEVICE
*ptd
, HDC hicTargetDevice
, LOGPALETTE
**ppColorSet
)
2775 FIXME("Stub: this=%p\n", this);
2780 HRESULT WINAPI
CDefView::Freeze(DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
, DWORD
*pdwFreeze
)
2782 FIXME("Stub: this=%p\n", this);
2787 HRESULT WINAPI
CDefView::Unfreeze(DWORD dwFreeze
)
2789 FIXME("Stub: this=%p\n", this);
2794 HRESULT WINAPI
CDefView::SetAdvise(DWORD aspects
, DWORD advf
, IAdviseSink
*pAdvSink
)
2796 FIXME("partial stub: %p %08x %08x %p\n", this, aspects
, advf
, pAdvSink
);
2798 /* FIXME: we set the AdviseSink, but never use it to send any advice */
2799 pAdvSink
= pAdvSink
;
2800 dwAspects
= aspects
;
2806 HRESULT WINAPI
CDefView::GetAdvise(DWORD
*pAspects
, DWORD
*pAdvf
, IAdviseSink
**ppAdvSink
)
2808 TRACE("this=%p pAspects=%p pAdvf=%p ppAdvSink=%p\n", this, pAspects
, pAdvf
, ppAdvSink
);
2812 *ppAdvSink
= pAdvSink
;
2813 pAdvSink
.p
->AddRef();
2817 *pAspects
= dwAspects
;
2825 HRESULT STDMETHODCALLTYPE
CDefView::QueryService(REFGUID guidService
, REFIID riid
, void **ppvObject
)
2827 if (IsEqualIID(guidService
, SID_IShellBrowser
))
2828 return pShellBrowser
->QueryInterface(riid
, ppvObject
);
2829 else if(IsEqualIID(guidService
, SID_IFolderView
))
2830 return QueryInterface(riid
, ppvObject
);
2832 return E_NOINTERFACE
;
2835 /**********************************************************
2836 * IShellView_Constructor
2838 HRESULT WINAPI
IShellView_Constructor(IShellFolder
*pFolder
, IShellView
**newView
)
2840 CComObject
<CDefView
> *theView
;
2841 CComPtr
<IShellView
> result
;
2844 if (newView
== NULL
)
2848 ATLTRY (theView
= new CComObject
<CDefView
>);
2850 if (theView
== NULL
)
2851 return E_OUTOFMEMORY
;
2853 hResult
= theView
->QueryInterface (IID_IShellView
, (void **)&result
);
2854 if (FAILED (hResult
))
2860 hResult
= theView
->Initialize (pFolder
);
2861 if (FAILED (hResult
))
2863 *newView
= result
.Detach ();