source: trunk/src/shell32/shlview.c@ 5655

Last change on this file since 5655 was 5618, checked in by sandervl, 24 years ago

resync with latest wine

File size: 58.5 KB
Line 
1/*
2 * ShellView
3 *
4 * Copyright 1998,1999 <juergen.schmied@debitel.net>
5 *
6 * This is the view visualizing the data provied by the shellfolder.
7 * No direct access to data from pidls should be done from here.
8 *
9 * FIXME: The order by part of the background context menu should be
10 * buily according to the columns shown.
11 *
12 * FIXME: Load/Save the view state from/into the stream provied by
13 * the ShellBrowser
14 *
15 * FIXME: CheckToolbar: handle the "new folder" and "folder up" button
16 *
17 * FIXME: ShellView_FillList: consider sort orders
18 *
19 * FIXME: implement the drag and drop in the old (msg-based) way
20 *
21 * FIXME: when the ShellView_WndProc gets a WM_NCDESTROY should we do a
22 * Release() ???
23 */
24
25#include <stdlib.h>
26#include <string.h>
27
28#include "windef.h"
29#include "winerror.h"
30#include "winnls.h"
31#include "servprov.h"
32#include "shlguid.h"
33#include "shlobj.h"
34#include "wine/undocshell.h"
35#include "shresdef.h"
36#include "debugtools.h"
37
38#include "docobj.h"
39#include "pidl.h"
40#include "shell32_main.h"
41#include "shellfolder.h"
42
43DEFAULT_DEBUG_CHANNEL(shell);
44
45typedef struct
46{ BOOL bIsAscending;
47 INT nHeaderID;
48 INT nLastHeaderID;
49}LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO;
50
51typedef struct
52{ ICOM_VFIELD(IShellView);
53 DWORD ref;
54 ICOM_VTABLE(IOleCommandTarget)* lpvtblOleCommandTarget;
55 ICOM_VTABLE(IDropTarget)* lpvtblDropTarget;
56 ICOM_VTABLE(IDropSource)* lpvtblDropSource;
57 ICOM_VTABLE(IViewObject)* lpvtblViewObject;
58 IShellFolder* pSFParent;
59 IShellFolder2* pSF2Parent;
60 IShellBrowser* pShellBrowser;
61 ICommDlgBrowser* pCommDlgBrowser;
62 HWND hWnd; /* SHELLDLL_DefView */
63 HWND hWndList; /* ListView control */
64 HWND hWndParent;
65 FOLDERSETTINGS FolderSettings;
66 HMENU hMenu;
67 UINT uState;
68 UINT cidl;
69 LPITEMIDLIST *apidl;
70 LISTVIEW_SORT_INFO ListViewSortInfo;
71 HANDLE hNotify; /* change notification handle */
72 HANDLE hAccel;
73} IShellViewImpl;
74
75static struct ICOM_VTABLE(IShellView) svvt;
76
77static struct ICOM_VTABLE(IOleCommandTarget) ctvt;
78#define _IOleCommandTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblOleCommandTarget)))
79#define _ICOM_THIS_From_IOleCommandTarget(class, name) class* This = (class*)(((char*)name)-_IOleCommandTarget_Offset);
80
81static struct ICOM_VTABLE(IDropTarget) dtvt;
82#define _IDropTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropTarget)))
83#define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
84
85static struct ICOM_VTABLE(IDropSource) dsvt;
86#define _IDropSource_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropSource)))
87#define _ICOM_THIS_From_IDropSource(class, name) class* This = (class*)(((char*)name)-_IDropSource_Offset);
88
89static struct ICOM_VTABLE(IViewObject) vovt;
90#define _IViewObject_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblViewObject)))
91#define _ICOM_THIS_From_IViewObject(class, name) class* This = (class*)(((char*)name)-_IViewObject_Offset);
92
93/* ListView Header ID's */
94#define LISTVIEW_COLUMN_NAME 0
95#define LISTVIEW_COLUMN_SIZE 1
96#define LISTVIEW_COLUMN_TYPE 2
97#define LISTVIEW_COLUMN_TIME 3
98#define LISTVIEW_COLUMN_ATTRIB 4
99
100/*menu items */
101#define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500)
102#define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501)
103#define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502)
104
105#define ID_LISTVIEW 2000
106
107#define SHV_CHANGE_NOTIFY WM_USER + 0x1111
108
109/*windowsx.h */
110#define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
111#define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
112#define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
113
114extern void WINAPI _InsertMenuItem (HMENU hmenu, UINT indexMenu, BOOL fByPosition,
115 UINT wID, UINT fType, LPSTR dwTypeData, UINT fState);
116
117/*
118 Items merged into the toolbar and and the filemenu
119*/
120typedef struct
121{ int idCommand;
122 int iImage;
123 int idButtonString;
124 int idMenuString;
125 BYTE bState;
126 BYTE bStyle;
127} MYTOOLINFO, *LPMYTOOLINFO;
128
129MYTOOLINFO Tools[] =
130{
131{ FCIDM_SHVIEW_BIGICON, 0, 0, IDS_VIEW_LARGE, TBSTATE_ENABLED, TBSTYLE_BUTTON },
132{ FCIDM_SHVIEW_SMALLICON, 0, 0, IDS_VIEW_SMALL, TBSTATE_ENABLED, TBSTYLE_BUTTON },
133{ FCIDM_SHVIEW_LISTVIEW, 0, 0, IDS_VIEW_LIST, TBSTATE_ENABLED, TBSTYLE_BUTTON },
134{ FCIDM_SHVIEW_REPORTVIEW, 0, 0, IDS_VIEW_DETAILS, TBSTATE_ENABLED, TBSTYLE_BUTTON },
135{ -1, 0, 0, 0, 0, 0}
136};
137
138#ifdef __WIN32OS2__
139typedef void (* CALLBACK PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
140#else
141typedef void CALLBACK (*PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
142#endif
143
144/**********************************************************
145 * IShellView_Constructor
146 */
147IShellView * IShellView_Constructor( IShellFolder * pFolder)
148{ IShellViewImpl * sv;
149 sv=(IShellViewImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl));
150 sv->ref=1;
151 ICOM_VTBL(sv)=&svvt;
152 sv->lpvtblOleCommandTarget=&ctvt;
153 sv->lpvtblDropTarget=&dtvt;
154 sv->lpvtblDropSource=&dsvt;
155 sv->lpvtblViewObject=&vovt;
156
157 sv->pSFParent = pFolder;
158 if(pFolder) IShellFolder_AddRef(pFolder);
159 IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (LPVOID*)&sv->pSF2Parent);
160
161 TRACE("(%p)->(%p)\n",sv, pFolder);
162 shell32_ObjCount++;
163 return (IShellView *) sv;
164}
165
166/**********************************************************
167 *
168 * ##### helperfunctions for communication with ICommDlgBrowser #####
169 */
170static BOOL IsInCommDlg(IShellViewImpl * This)
171{ return(This->pCommDlgBrowser != NULL);
172}
173
174static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl)
175{
176 HRESULT ret = S_OK;
177
178 if ( IsInCommDlg(This) )
179 {
180 TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
181 ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView*)This, pidl);
182 TRACE("--0x%08lx\n", ret);
183 }
184 return ret;
185}
186
187static HRESULT OnDefaultCommand(IShellViewImpl * This)
188{
189 HRESULT ret = S_FALSE;
190
191 if (IsInCommDlg(This))
192 {
193 TRACE("ICommDlgBrowser::OnDefaultCommand\n");
194 ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView*)This);
195 TRACE("--\n");
196 }
197 return ret;
198}
199
200static HRESULT OnStateChange(IShellViewImpl * This, UINT uFlags)
201{
202 HRESULT ret = S_FALSE;
203
204 if (IsInCommDlg(This))
205 {
206 TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags);
207 ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView*)This, uFlags);
208 TRACE("--\n");
209 }
210 return ret;
211}
212/**********************************************************
213 * set the toolbar of the filedialog buttons
214 *
215 * - activates the buttons from the shellbrowser according to
216 * the view state
217 */
218static void CheckToolbar(IShellViewImpl * This)
219{
220 LRESULT result;
221
222 TRACE("\n");
223
224 if (IsInCommDlg(This))
225 {
226 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
227 FCIDM_TB_SMALLICON, (This->FolderSettings.ViewMode==FVM_LIST)? TRUE : FALSE, &result);
228 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
229 FCIDM_TB_REPORTVIEW, (This->FolderSettings.ViewMode==FVM_DETAILS)? TRUE : FALSE, &result);
230 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
231 FCIDM_TB_SMALLICON, TRUE, &result);
232 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
233 FCIDM_TB_REPORTVIEW, TRUE, &result);
234 }
235}
236
237/**********************************************************
238 *
239 * ##### helperfunctions for initializing the view #####
240 */
241/**********************************************************
242 * change the style of the listview control
243 */
244static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove)
245{
246 DWORD tmpstyle;
247
248 TRACE("(%p)\n", This);
249
250 tmpstyle = GetWindowLongA(This->hWndList, GWL_STYLE);
251 SetWindowLongA(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove));
252}
253
254/**********************************************************
255* ShellView_CreateList()
256*
257* - creates the list view window
258*/
259static BOOL ShellView_CreateList (IShellViewImpl * This)
260{ DWORD dwStyle;
261
262 TRACE("%p\n",This);
263
264 dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
265 LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_AUTOARRANGE;
266
267 switch (This->FolderSettings.ViewMode)
268 {
269 case FVM_ICON: dwStyle |= LVS_ICON; break;
270 case FVM_DETAILS: dwStyle |= LVS_REPORT; break;
271 case FVM_SMALLICON: dwStyle |= LVS_SMALLICON; break;
272 case FVM_LIST: dwStyle |= LVS_LIST; break;
273 default: dwStyle |= LVS_LIST; break;
274 }
275
276 if (This->FolderSettings.fFlags & FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE;
277 /*if (This->FolderSettings.fFlags && FWF_DESKTOP); used from explorer*/
278 if (This->FolderSettings.fFlags & FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL;
279
280 This->hWndList=CreateWindowExA( WS_EX_CLIENTEDGE,
281 WC_LISTVIEWA,
282 NULL,
283 dwStyle,
284 0,0,0,0,
285 This->hWnd,
286 (HMENU)ID_LISTVIEW,
287 shell32_hInstance,
288 NULL);
289
290 if(!This->hWndList)
291 return FALSE;
292
293 This->ListViewSortInfo.bIsAscending = TRUE;
294 This->ListViewSortInfo.nHeaderID = -1;
295 This->ListViewSortInfo.nLastHeaderID = -1;
296
297 /* UpdateShellSettings(); */
298 return TRUE;
299}
300
301/**********************************************************
302* ShellView_InitList()
303*
304* - adds all needed columns to the shellview
305*/
306static BOOL ShellView_InitList(IShellViewImpl * This)
307{
308 LVCOLUMNA lvColumn;
309 SHELLDETAILS sd;
310 int i;
311 char szTemp[50];
312
313 TRACE("%p\n",This);
314
315 ListView_DeleteAllItems(This->hWndList);
316
317 lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
318 lvColumn.pszText = szTemp;
319
320 if (This->pSF2Parent)
321 {
322 for (i=0; 1; i++)
323 {
324 if (!SUCCEEDED(IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, i, &sd)))
325 break;
326 lvColumn.fmt = sd.fmt;
327 lvColumn.cx = sd.cxChar*8; /* chars->pixel */
328 StrRetToStrNA( szTemp, 50, &sd.str, NULL);
329 ListView_InsertColumnA(This->hWndList, i, &lvColumn);
330 }
331 }
332 else
333 {
334 FIXME("no SF2\n");
335 }
336
337 ListView_SetImageList(This->hWndList, ShellSmallIconList, LVSIL_SMALL);
338 ListView_SetImageList(This->hWndList, ShellBigIconList, LVSIL_NORMAL);
339
340 return TRUE;
341}
342/**********************************************************
343* ShellView_CompareItems()
344*
345* NOTES
346* internal, CALLBACK for DSA_Sort
347*/
348static INT CALLBACK ShellView_CompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
349{
350 int ret;
351 TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1, lParam2, (LPVOID) lpData);
352
353 if(!lpData) return 0;
354
355 ret = (SHORT) SCODE_CODE(IShellFolder_CompareIDs((LPSHELLFOLDER)lpData, 0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2));
356 TRACE("ret=%i\n",ret);
357 return ret;
358}
359
360/*************************************************************************
361 * ShellView_ListViewCompareItems
362 *
363 * Compare Function for the Listview (FileOpen Dialog)
364 *
365 * PARAMS
366 * lParam1 [I] the first ItemIdList to compare with
367 * lParam2 [I] the second ItemIdList to compare with
368 * lpData [I] The column ID for the header Ctrl to process
369 *
370 * RETURNS
371 * A negative value if the first item should precede the second,
372 * a positive value if the first item should follow the second,
373 * or zero if the two items are equivalent
374 *
375 * NOTES
376 * FIXME: function does what ShellView_CompareItems is supposed to do.
377 * unify it and figure out how to use the undocumented first parameter
378 * of IShellFolder_CompareIDs to do the job this function does and
379 * move this code to IShellFolder.
380 * make LISTVIEW_SORT_INFO obsolete
381 * the way this function works is only usable if we had only
382 * filesystemfolders (25/10/99 jsch)
383 */
384static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
385{
386 INT nDiff=0;
387 FILETIME fd1, fd2;
388 char strName1[MAX_PATH], strName2[MAX_PATH];
389 BOOL bIsFolder1, bIsFolder2,bIsBothFolder;
390 LPITEMIDLIST pItemIdList1 = (LPITEMIDLIST) lParam1;
391 LPITEMIDLIST pItemIdList2 = (LPITEMIDLIST) lParam2;
392 LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData;
393
394
395 bIsFolder1 = _ILIsFolder(pItemIdList1);
396 bIsFolder2 = _ILIsFolder(pItemIdList2);
397 bIsBothFolder = bIsFolder1 && bIsFolder2;
398
399 /* When sorting between a File and a Folder, the Folder gets sorted first */
400 if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder)
401 {
402 nDiff = bIsFolder1 ? -1 : 1;
403 }
404 else
405 {
406 /* Sort by Time: Folders or Files can be sorted */
407
408 if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)
409 {
410 _ILGetFileDateTime(pItemIdList1, &fd1);
411 _ILGetFileDateTime(pItemIdList2, &fd2);
412 nDiff = CompareFileTime(&fd2, &fd1);
413 }
414 /* Sort by Attribute: Folder or Files can be sorted */
415 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB)
416 {
417 _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH);
418 _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH);
419 nDiff = strcasecmp(strName1, strName2);
420 }
421 /* Sort by FileName: Folder or Files can be sorted */
422 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder)
423 {
424 /* Sort by Text */
425 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
426 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
427 nDiff = strcasecmp(strName1, strName2);
428 }
429 /* Sort by File Size, Only valid for Files */
430 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)
431 {
432 nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0));
433 }
434 /* Sort by File Type, Only valid for Files */
435 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)
436 {
437 /* Sort by Type */
438 _ILGetFileType(pItemIdList1, strName1, MAX_PATH);
439 _ILGetFileType(pItemIdList2, strName2, MAX_PATH);
440 nDiff = strcasecmp(strName1, strName2);
441 }
442 }
443 /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
444
445 if(nDiff == 0)
446 {
447 _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
448 _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
449 nDiff = strcasecmp(strName1, strName2);
450 }
451
452 if(!pSortInfo->bIsAscending)
453 {
454 nDiff = -nDiff;
455 }
456
457 return nDiff;
458
459}
460
461/**********************************************************
462* LV_FindItemByPidl()
463*/
464static int LV_FindItemByPidl(
465 IShellViewImpl * This,
466 LPCITEMIDLIST pidl)
467{
468 LVITEMA lvItem;
469 ZeroMemory(&lvItem, sizeof(LVITEMA));
470 lvItem.mask = LVIF_PARAM;
471 for(lvItem.iItem = 0; ListView_GetItemA(This->hWndList, &lvItem); lvItem.iItem++)
472 {
473 LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam;
474 HRESULT hr = IShellFolder_CompareIDs(This->pSFParent, 0, pidl, currentpidl);
475 if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
476 {
477 return lvItem.iItem;
478 }
479 }
480 return -1;
481}
482
483/**********************************************************
484* LV_AddItem()
485*/
486static BOOLEAN LV_AddItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
487{
488 LVITEMA lvItem;
489
490 TRACE("(%p)(pidl=%p)\n", This, pidl);
491
492 ZeroMemory(&lvItem, sizeof(lvItem)); /* create the listview item*/
493 lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; /*set the mask*/
494 lvItem.iItem = ListView_GetItemCount(This->hWndList); /*add the item to the end of the list*/
495 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidl)); /*set the item's data*/
496 lvItem.pszText = LPSTR_TEXTCALLBACKA; /*get text on a callback basis*/
497 lvItem.iImage = I_IMAGECALLBACK; /*get the image on a callback basis*/
498 return (-1==ListView_InsertItemA(This->hWndList, &lvItem))? FALSE: TRUE;
499}
500
501/**********************************************************
502* LV_DeleteItem()
503*/
504static BOOLEAN LV_DeleteItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
505{
506 int nIndex;
507
508 TRACE("(%p)(pidl=%p)\n", This, pidl);
509
510 nIndex = LV_FindItemByPidl(This, ILFindLastID(pidl));
511 return (-1==ListView_DeleteItem(This->hWndList, nIndex))? FALSE: TRUE;
512}
513
514/**********************************************************
515* LV_RenameItem()
516*/
517static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew )
518{
519 int nItem;
520 LVITEMA lvItem;
521
522 TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew);
523
524 nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld));
525 if ( -1 != nItem )
526 {
527 ZeroMemory(&lvItem, sizeof(lvItem)); /* create the listview item*/
528 lvItem.mask = LVIF_PARAM; /* only the pidl */
529 lvItem.iItem = nItem;
530 ListView_GetItemA(This->hWndList, &lvItem);
531
532 SHFree((LPITEMIDLIST)lvItem.lParam);
533 lvItem.mask = LVIF_PARAM;
534 lvItem.iItem = nItem;
535 lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew)); /* set the item's data */
536 ListView_SetItemA(This->hWndList, &lvItem);
537 ListView_Update(This->hWndList, nItem);
538 return TRUE; /* fixme: better handling */
539 }
540 return FALSE;
541}
542/**********************************************************
543* ShellView_FillList()
544*
545* - gets the objectlist from the shellfolder
546* - sorts the list
547* - fills the list into the view
548*/
549
550static HRESULT ShellView_FillList(IShellViewImpl * This)
551{
552 LPENUMIDLIST pEnumIDList;
553 LPITEMIDLIST pidl;
554 DWORD dwFetched;
555 UINT i;
556 HRESULT hRes;
557 HDPA hdpa;
558
559 TRACE("%p\n",This);
560
561 /* get the itemlist from the shfolder*/
562 hRes = IShellFolder_EnumObjects(This->pSFParent,This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList);
563 if (hRes != S_OK)
564 {
565 if (hRes==S_FALSE)
566 return(NOERROR);
567 return(hRes);
568 }
569
570 /* create a pointer array */
571 hdpa = pDPA_Create(16);
572 if (!hdpa)
573 {
574 return(E_OUTOFMEMORY);
575 }
576
577 /* copy the items into the array*/
578 while((S_OK == IEnumIDList_Next(pEnumIDList,1, &pidl, &dwFetched)) && dwFetched)
579 {
580 if (pDPA_InsertPtr(hdpa, 0x7fff, pidl) == -1)
581 {
582 SHFree(pidl);
583 }
584 }
585
586 /* sort the array */
587 pDPA_Sort(hdpa, ShellView_CompareItems, (LPARAM)This->pSFParent);
588
589 /*turn the listview's redrawing off*/
590 SendMessageA(This->hWndList, WM_SETREDRAW, FALSE, 0);
591
592 for (i=0; i < DPA_GetPtrCount(hdpa); ++i) /* DPA_GetPtrCount is a macro*/
593 {
594 pidl = (LPITEMIDLIST)pDPA_GetPtr(hdpa, i);
595
596 /* in a commdlg This works as a filemask*/
597 if ( IncludeObject(This, pidl)==S_OK )
598 LV_AddItem(This, pidl);
599 SHFree(pidl);
600 }
601
602 /*turn the listview's redrawing back on and force it to draw*/
603 SendMessageA(This->hWndList, WM_SETREDRAW, TRUE, 0);
604
605 IEnumIDList_Release(pEnumIDList); /* destroy the list*/
606 pDPA_Destroy(hdpa);
607
608 return S_OK;
609}
610
611/**********************************************************
612* ShellView_OnCreate()
613*/
614static LRESULT ShellView_OnCreate(IShellViewImpl * This)
615{
616 IDropTarget* pdt;
617 NOTIFYREGISTER ntreg;
618 IPersistFolder2 * ppf2 = NULL;
619
620 TRACE("%p\n",This);
621
622 if(ShellView_CreateList(This))
623 {
624 if(ShellView_InitList(This))
625 {
626 ShellView_FillList(This);
627 }
628 }
629
630 if(GetShellOle())
631 {
632 if (SUCCEEDED(IShellFolder_CreateViewObject(This->pSFParent, This->hWnd, &IID_IDropTarget, (LPVOID*)&pdt)))
633 {
634 pRegisterDragDrop(This->hWnd, pdt);
635 IDropTarget_Release(pdt);
636 }
637 }
638
639 /* register for receiving notifications */
640 IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2);
641 if (ppf2)
642 {
643 IPersistFolder2_GetCurFolder(ppf2, &ntreg.pidlPath);
644 ntreg.bWatchSubtree = FALSE;
645 This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNF_IDLIST, SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg);
646 SHFree(ntreg.pidlPath);
647 IPersistFolder2_Release(ppf2);
648 }
649
650 This->hAccel = LoadAcceleratorsA(shell32_hInstance, "shv_accel");
651
652 return S_OK;
653}
654
655/**********************************************************
656 * #### Handling of the menus ####
657 */
658
659/**********************************************************
660* ShellView_BuildFileMenu()
661*/
662static HMENU ShellView_BuildFileMenu(IShellViewImpl * This)
663{ CHAR szText[MAX_PATH];
664 MENUITEMINFOA mii;
665 int nTools,i;
666 HMENU hSubMenu;
667
668 TRACE("(%p)\n",This);
669
670 hSubMenu = CreatePopupMenu();
671 if(hSubMenu)
672 { /*get the number of items in our global array*/
673 for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){}
674
675 /*add the menu items*/
676 for(i = 0; i < nTools; i++)
677 {
678 LoadStringA(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH);
679
680 ZeroMemory(&mii, sizeof(mii));
681 mii.cbSize = sizeof(mii);
682 mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
683
684 if(TBSTYLE_SEP != Tools[i].bStyle) /* no seperator*/
685 {
686 mii.fType = MFT_STRING;
687 mii.fState = MFS_ENABLED;
688 mii.dwTypeData = szText;
689 mii.wID = Tools[i].idCommand;
690 }
691 else
692 {
693 mii.fType = MFT_SEPARATOR;
694 }
695 /* tack This item onto the end of the menu */
696 InsertMenuItemA(hSubMenu, (UINT)-1, TRUE, &mii);
697 }
698 }
699 TRACE("-- return (menu=0x%x)\n",hSubMenu);
700 return hSubMenu;
701}
702/**********************************************************
703* ShellView_MergeFileMenu()
704*/
705static void ShellView_MergeFileMenu(IShellViewImpl * This, HMENU hSubMenu)
706{ TRACE("(%p)->(submenu=0x%08x) stub\n",This,hSubMenu);
707
708 if(hSubMenu)
709 { /*insert This item at the beginning of the menu */
710 _InsertMenuItem(hSubMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
711 _InsertMenuItem(hSubMenu, 0, TRUE, IDM_MYFILEITEM, MFT_STRING, "dummy45", MFS_ENABLED);
712
713 }
714 TRACE("--\n");
715}
716
717/**********************************************************
718* ShellView_MergeViewMenu()
719*/
720
721static void ShellView_MergeViewMenu(IShellViewImpl * This, HMENU hSubMenu)
722{ MENUITEMINFOA mii;
723
724 TRACE("(%p)->(submenu=0x%08x)\n",This,hSubMenu);
725
726 if(hSubMenu)
727 { /*add a separator at the correct position in the menu*/
728 _InsertMenuItem(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
729
730 ZeroMemory(&mii, sizeof(mii));
731 mii.cbSize = sizeof(mii);
732 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;;
733 mii.fType = MFT_STRING;
734 mii.dwTypeData = "View";
735 mii.hSubMenu = LoadMenuA(shell32_hInstance, "MENU_001");
736 InsertMenuItemA(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
737 }
738}
739
740/**********************************************************
741* ShellView_GetSelections()
742*
743* - fills the this->apidl list with the selected objects
744*
745* RETURNS
746* number of selected items
747*/
748static UINT ShellView_GetSelections(IShellViewImpl * This)
749{
750 LVITEMA lvItem;
751 UINT i = 0;
752
753 if (This->apidl)
754 {
755 SHFree(This->apidl);
756 }
757
758 This->cidl = ListView_GetSelectedCount(This->hWndList);
759 This->apidl = (LPITEMIDLIST*)SHAlloc(This->cidl * sizeof(LPITEMIDLIST));
760
761 TRACE("selected=%i\n", This->cidl);
762
763 if(This->apidl)
764 {
765 TRACE("-- Items selected =%u\n", This->cidl);
766
767 ZeroMemory(&lvItem, sizeof(lvItem));
768 lvItem.mask = LVIF_STATE | LVIF_PARAM;
769 lvItem.stateMask = LVIS_SELECTED;
770
771 while(ListView_GetItemA(This->hWndList, &lvItem) && (i < This->cidl))
772 {
773 if(lvItem.state & LVIS_SELECTED)
774 {
775 This->apidl[i] = (LPITEMIDLIST)lvItem.lParam;
776 i++;
777 TRACE("-- selected Item found\n");
778 }
779 lvItem.iItem++;
780 }
781 }
782 return This->cidl;
783
784}
785/**********************************************************
786 * ShellView_DoContextMenu()
787 */
788static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL bDefault)
789{ UINT uCommand;
790 DWORD wFlags;
791 HMENU hMenu;
792 BOOL fExplore = FALSE;
793 HWND hwndTree = 0;
794 LPCONTEXTMENU pContextMenu = NULL;
795 IContextMenu * pCM = NULL;
796 CMINVOKECOMMANDINFO cmi;
797
798 TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, bDefault);
799
800 /* look, what's selected and create a context menu object of it*/
801 if( ShellView_GetSelections(This) )
802 {
803 IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, This->apidl,
804 (REFIID)&IID_IContextMenu, NULL, (LPVOID *)&pContextMenu);
805
806 if(pContextMenu)
807 {
808 TRACE("-- pContextMenu\n");
809 hMenu = CreatePopupMenu();
810
811 if( hMenu )
812 {
813 /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
814 if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree)
815 {
816 TRACE("-- explore mode\n");
817 fExplore = TRUE;
818 }
819
820 /* build the flags depending on what we can do with the selected item */
821 wFlags = CMF_NORMAL | (This->cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0);
822
823 /* let the ContextMenu merge its items in */
824 if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags )))
825 {
826 if( bDefault )
827 {
828 TRACE("-- get menu default command\n");
829 uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS);
830 }
831 else
832 {
833 TRACE("-- track popup\n");
834 uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
835 }
836
837 if(uCommand > 0)
838 {
839 TRACE("-- uCommand=%u\n", uCommand);
840 if (IsInCommDlg(This) && ((uCommand==FCIDM_SHVIEW_EXPLORE) || (uCommand==FCIDM_SHVIEW_OPEN)))
841 {
842 TRACE("-- dlg: OnDefaultCommand\n");
843 OnDefaultCommand(This);
844 }
845 else
846 {
847 TRACE("-- explore -- invoke command\n");
848 ZeroMemory(&cmi, sizeof(cmi));
849 cmi.cbSize = sizeof(cmi);
850 cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */
851 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
852 IContextMenu_InvokeCommand(pContextMenu, &cmi);
853 }
854 }
855 DestroyMenu(hMenu);
856 }
857 }
858 if (pContextMenu)
859 IContextMenu_Release(pContextMenu);
860 }
861 }
862 else /* background context menu */
863 {
864 hMenu = CreatePopupMenu();
865
866 pCM = ISvBgCm_Constructor(This->pSFParent);
867 IContextMenu_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
868
869 uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
870 DestroyMenu(hMenu);
871
872 TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand);
873
874 ZeroMemory(&cmi, sizeof(cmi));
875 cmi.cbSize = sizeof(cmi);
876 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
877 cmi.hwnd = This->hWndParent;
878 IContextMenu_InvokeCommand(pCM, &cmi);
879
880 IContextMenu_Release(pCM);
881 }
882}
883
884/**********************************************************
885 * ##### message handling #####
886 */
887
888/**********************************************************
889* ShellView_OnSize()
890*/
891static LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight)
892{
893 TRACE("%p width=%u height=%u\n",This, wWidth,wHeight);
894
895 /*resize the ListView to fit our window*/
896 if(This->hWndList)
897 {
898 MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE);
899 }
900
901 return S_OK;
902}
903/**********************************************************
904* ShellView_OnDeactivate()
905*
906* NOTES
907* internal
908*/
909static void ShellView_OnDeactivate(IShellViewImpl * This)
910{
911 TRACE("%p\n",This);
912
913 if(This->uState != SVUIA_DEACTIVATE)
914 {
915 if(This->hMenu)
916 {
917 IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0);
918 IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu);
919 DestroyMenu(This->hMenu);
920 This->hMenu = 0;
921 }
922
923 This->uState = SVUIA_DEACTIVATE;
924 }
925}
926
927/**********************************************************
928* ShellView_OnActivate()
929*/
930static LRESULT ShellView_OnActivate(IShellViewImpl * This, UINT uState)
931{ OLEMENUGROUPWIDTHS omw = { {0, 0, 0, 0, 0, 0} };
932 MENUITEMINFOA mii;
933 CHAR szText[MAX_PATH];
934
935 TRACE("%p uState=%x\n",This,uState);
936
937 /*don't do anything if the state isn't really changing */
938 if(This->uState == uState)
939 {
940 return S_OK;
941 }
942
943 ShellView_OnDeactivate(This);
944
945 /*only do This if we are active */
946 if(uState != SVUIA_DEACTIVATE)
947 {
948 /*merge the menus */
949 This->hMenu = CreateMenu();
950
951 if(This->hMenu)
952 {
953 IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw);
954 TRACE("-- after fnInsertMenusSB\n");
955
956 /*build the top level menu get the menu item's text*/
957 strcpy(szText,"dummy 31");
958
959 ZeroMemory(&mii, sizeof(mii));
960 mii.cbSize = sizeof(mii);
961 mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
962 mii.fType = MFT_STRING;
963 mii.fState = MFS_ENABLED;
964 mii.dwTypeData = szText;
965 mii.hSubMenu = ShellView_BuildFileMenu(This);
966
967 /*insert our menu into the menu bar*/
968 if(mii.hSubMenu)
969 {
970 InsertMenuItemA(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii);
971 }
972
973 /*get the view menu so we can merge with it*/
974 ZeroMemory(&mii, sizeof(mii));
975 mii.cbSize = sizeof(mii);
976 mii.fMask = MIIM_SUBMENU;
977
978 if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii))
979 {
980 ShellView_MergeViewMenu(This, mii.hSubMenu);
981 }
982
983 /*add the items that should only be added if we have the focus*/
984 if(SVUIA_ACTIVATE_FOCUS == uState)
985 {
986 /*get the file menu so we can merge with it */
987 ZeroMemory(&mii, sizeof(mii));
988 mii.cbSize = sizeof(mii);
989 mii.fMask = MIIM_SUBMENU;
990
991 if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii))
992 {
993 ShellView_MergeFileMenu(This, mii.hSubMenu);
994 }
995 }
996 TRACE("-- before fnSetMenuSB\n");
997 IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd);
998 }
999 }
1000 This->uState = uState;
1001 TRACE("--\n");
1002 return S_OK;
1003}
1004
1005/**********************************************************
1006* ShellView_OnSetFocus()
1007*
1008*/
1009static LRESULT ShellView_OnSetFocus(IShellViewImpl * This)
1010{
1011 TRACE("%p\n",This);
1012
1013 /* Tell the browser one of our windows has received the focus. This
1014 should always be done before merging menus (OnActivate merges the
1015 menus) if one of our windows has the focus.*/
1016
1017 IShellBrowser_OnViewWindowActive(This->pShellBrowser,(IShellView*) This);
1018 ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS);
1019
1020 /* Set the focus to the listview */
1021 SetFocus(This->hWndList);
1022
1023 /* Notify the ICommDlgBrowser interface */
1024 OnStateChange(This,CDBOSC_SETFOCUS);
1025
1026 return 0;
1027}
1028
1029/**********************************************************
1030* ShellView_OnKillFocus()
1031*/
1032static LRESULT ShellView_OnKillFocus(IShellViewImpl * This)
1033{
1034 TRACE("(%p) stub\n",This);
1035
1036 ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS);
1037 /* Notify the ICommDlgBrowser */
1038 OnStateChange(This,CDBOSC_KILLFOCUS);
1039
1040 return 0;
1041}
1042
1043/**********************************************************
1044* ShellView_OnCommand()
1045*
1046* NOTES
1047* the CmdID's are the ones from the context menu
1048*/
1049static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd)
1050{
1051 TRACE("(%p)->(0x%08lx 0x%08lx 0x%08x) stub\n",This, dwCmdID, dwCmd, hwndCmd);
1052
1053 switch(dwCmdID)
1054 {
1055 case FCIDM_SHVIEW_SMALLICON:
1056 This->FolderSettings.ViewMode = FVM_SMALLICON;
1057 SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK);
1058 CheckToolbar(This);
1059 break;
1060
1061 case FCIDM_SHVIEW_BIGICON:
1062 This->FolderSettings.ViewMode = FVM_ICON;
1063 SetStyle (This, LVS_ICON, LVS_TYPEMASK);
1064 CheckToolbar(This);
1065 break;
1066
1067 case FCIDM_SHVIEW_LISTVIEW:
1068 This->FolderSettings.ViewMode = FVM_LIST;
1069 SetStyle (This, LVS_LIST, LVS_TYPEMASK);
1070 CheckToolbar(This);
1071 break;
1072
1073 case FCIDM_SHVIEW_REPORTVIEW:
1074 This->FolderSettings.ViewMode = FVM_DETAILS;
1075 SetStyle (This, LVS_REPORT, LVS_TYPEMASK);
1076 CheckToolbar(This);
1077 break;
1078
1079 /* the menu-ID's for sorting are 0x30... see shrec.rc */
1080 case 0x30:
1081 case 0x31:
1082 case 0x32:
1083 case 0x33:
1084 This->ListViewSortInfo.nHeaderID = (LPARAM) (dwCmdID - 0x30);
1085 This->ListViewSortInfo.bIsAscending = TRUE;
1086 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1087 ListView_SortItems(This->hWndList, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1088 break;
1089
1090 default:
1091 TRACE("-- COMMAND 0x%04lx unhandled\n", dwCmdID);
1092 }
1093 return 0;
1094}
1095
1096/**********************************************************
1097* ShellView_OnNotify()
1098*/
1099
1100static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
1101{ LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
1102 NMLVDISPINFOA *lpdi = (NMLVDISPINFOA *)lpnmh;
1103 LPITEMIDLIST pidl;
1104
1105 TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code);
1106
1107 switch(lpnmh->code)
1108 {
1109 case NM_SETFOCUS:
1110 TRACE("-- NM_SETFOCUS %p\n",This);
1111 ShellView_OnSetFocus(This);
1112 break;
1113
1114 case NM_KILLFOCUS:
1115 TRACE("-- NM_KILLFOCUS %p\n",This);
1116 ShellView_OnDeactivate(This);
1117 /* Notify the ICommDlgBrowser interface */
1118 OnStateChange(This,CDBOSC_KILLFOCUS);
1119 break;
1120
1121 case HDN_ENDTRACKA:
1122 TRACE("-- HDN_ENDTRACKA %p\n",This);
1123 /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
1124 nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
1125 break;
1126
1127 case LVN_DELETEITEM:
1128 TRACE("-- LVN_DELETEITEM %p\n",This);
1129 SHFree((LPITEMIDLIST)lpnmlv->lParam); /*delete the pidl because we made a copy of it*/
1130 break;
1131
1132 case LVN_ITEMACTIVATE:
1133 TRACE("-- LVN_ITEMACTIVATE %p\n",This);
1134 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1135 ShellView_DoContextMenu(This, 0, 0, TRUE);
1136 break;
1137
1138 case LVN_COLUMNCLICK:
1139 This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem;
1140 if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID)
1141 {
1142 This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending;
1143 }
1144 else
1145 {
1146 This->ListViewSortInfo.bIsAscending = TRUE;
1147 }
1148 This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1149
1150 ListView_SortItems(lpnmlv->hdr.hwndFrom, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1151 break;
1152
1153 case LVN_GETDISPINFOA:
1154 TRACE("-- LVN_GETDISPINFOA %p\n",This);
1155 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1156
1157 if(lpdi->item.mask & LVIF_TEXT) /* text requested */
1158 {
1159 if (This->pSF2Parent)
1160 {
1161 SHELLDETAILS sd;
1162 IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
1163 StrRetToStrNA( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1164 TRACE("-- text=%s\n",lpdi->item.pszText);
1165 }
1166 else
1167 {
1168 FIXME("no SF2\n");
1169 }
1170 }
1171 if(lpdi->item.mask & LVIF_IMAGE) /* image requested */
1172 {
1173 lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
1174 }
1175 break;
1176
1177 case LVN_ITEMCHANGED:
1178 TRACE("-- LVN_ITEMCHANGED %p\n",This);
1179 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1180 break;
1181
1182 case LVN_BEGINDRAG:
1183 case LVN_BEGINRDRAG:
1184 TRACE("-- LVN_BEGINDRAG\n");
1185
1186 if (ShellView_GetSelections(This))
1187 {
1188 IDataObject * pda;
1189 DWORD dwAttributes = SFGAO_CANLINK;
1190 DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
1191
1192 if(GetShellOle())
1193 {
1194 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
1195 {
1196 IDropSource * pds = (IDropSource*)&(This->lpvtblDropSource); /* own DropSource interface */
1197
1198 if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, This->apidl, &dwAttributes)))
1199 {
1200 if (dwAttributes & SFGAO_CANLINK)
1201 {
1202 dwEffect |= DROPEFFECT_LINK;
1203 }
1204 }
1205
1206 if (pds)
1207 {
1208 DWORD dwEffect;
1209 pDoDragDrop(pda, pds, dwEffect, &dwEffect);
1210 }
1211 IDataObject_Release(pda);
1212 }
1213 }
1214 }
1215 break;
1216
1217 case LVN_BEGINLABELEDITA:
1218 {
1219 DWORD dwAttr = SFGAO_CANRENAME;
1220 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1221
1222 TRACE("-- LVN_BEGINLABELEDITA %p\n",This);
1223
1224 IShellFolder_GetAttributesOf(This->pSFParent, 1, &pidl, &dwAttr);
1225 if (SFGAO_CANRENAME & dwAttr)
1226 {
1227 return FALSE;
1228 }
1229 return TRUE;
1230 }
1231 break;
1232
1233 case LVN_ENDLABELEDITA:
1234 {
1235 TRACE("-- LVN_ENDLABELEDITA %p\n",This);
1236 if (lpdi->item.pszText)
1237 {
1238 HRESULT hr;
1239 WCHAR wszNewName[MAX_PATH];
1240 LVITEMA lvItem;
1241
1242 ZeroMemory(&lvItem, sizeof(LVITEMA));
1243 lvItem.iItem = lpdi->item.iItem;
1244 lvItem.mask = LVIF_PARAM;
1245 ListView_GetItemA(This->hWndList, &lvItem);
1246
1247 pidl = (LPITEMIDLIST)lpdi->item.lParam;
1248 if (!MultiByteToWideChar( CP_ACP, 0, lpdi->item.pszText, -1, wszNewName, MAX_PATH ))
1249 wszNewName[MAX_PATH-1] = 0;
1250 hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, wszNewName, SHGDN_INFOLDER, &pidl);
1251
1252 if(SUCCEEDED(hr) && pidl)
1253 {
1254 lvItem.mask = LVIF_PARAM;
1255 lvItem.lParam = (LPARAM)pidl;
1256 ListView_SetItemA(This->hWndList, &lvItem);
1257 return TRUE;
1258 }
1259 }
1260 return FALSE;
1261 }
1262 break;
1263
1264 case LVN_KEYDOWN:
1265 {
1266 /* MSG msg;
1267 msg.hwnd = This->hWnd;
1268 msg.message = WM_KEYDOWN;
1269 msg.wParam = plvKeyDown->wVKey;
1270 msg.lParam = 0;
1271 msg.time = 0;
1272 msg.pt = 0;*/
1273
1274 LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
1275
1276 /* initiate a rename of the selected file or directory */
1277 if(plvKeyDown->wVKey == VK_F2)
1278 {
1279 /* see how many files are selected */
1280 int i = ListView_GetSelectedCount(This->hWndList);
1281
1282 /* get selected item */
1283 if(i == 1)
1284 {
1285 /* get selected item */
1286 i = ListView_GetNextItem(This->hWndList, -1,
1287 LVNI_SELECTED);
1288
1289 ListView_EnsureVisible(This->hWndList, i, 0);
1290 ListView_EditLabelA(This->hWndList, i);
1291 }
1292 }
1293#if 0
1294 TranslateAccelerator(This->hWnd, This->hAccel, &msg)
1295#endif
1296 else if(plvKeyDown->wVKey == VK_DELETE)
1297 {
1298 int i, item_index;
1299 LVITEMA item;
1300 LPITEMIDLIST* pItems;
1301 ISFHelper *psfhlp;
1302
1303 IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper,
1304 (LPVOID*)&psfhlp);
1305
1306 if(!(i = ListView_GetSelectedCount(This->hWndList)))
1307 break;
1308
1309 /* allocate memory for the pidl array */
1310 pItems = HeapAlloc(GetProcessHeap(), 0,
1311 sizeof(LPITEMIDLIST) * i);
1312
1313 /* retrieve all selected items */
1314 i = 0;
1315 item_index = -1;
1316 while(ListView_GetSelectedCount(This->hWndList) > i)
1317 {
1318 /* get selected item */
1319 item_index = ListView_GetNextItem(This->hWndList,
1320 item_index, LVNI_SELECTED);
1321 item.iItem = item_index;
1322 ListView_GetItemA(This->hWndList, &item);
1323
1324 /* get item pidl */
1325 pItems[i] = (LPITEMIDLIST)item.lParam;
1326
1327 i++;
1328 }
1329
1330 /* perform the item deletion */
1331 ISFHelper_DeleteItems(psfhlp, i, pItems);
1332
1333 /* free pidl array memory */
1334 HeapFree(GetProcessHeap(), 0, pItems);
1335 }
1336 else
1337 FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey);
1338 }
1339 break;
1340
1341 default:
1342 TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code);
1343 break;;
1344 }
1345 return 0;
1346}
1347
1348/**********************************************************
1349* ShellView_OnChange()
1350*/
1351
1352static LRESULT ShellView_OnChange(IShellViewImpl * This, LPITEMIDLIST * Pidls, LONG wEventId)
1353{
1354
1355 TRACE("(%p)(%p,%p,0x%08lx)\n", This, Pidls[0], Pidls[1], wEventId);
1356 switch(wEventId)
1357 {
1358 case SHCNE_MKDIR:
1359 case SHCNE_CREATE:
1360 LV_AddItem(This, Pidls[0]);
1361 break;
1362 case SHCNE_RMDIR:
1363 case SHCNE_DELETE:
1364 LV_DeleteItem(This, Pidls[0]);
1365 break;
1366 case SHCNE_RENAMEFOLDER:
1367 case SHCNE_RENAMEITEM:
1368 LV_RenameItem(This, Pidls[0], Pidls[1]);
1369 break;
1370 case SHCNE_UPDATEITEM:
1371 break;
1372 }
1373 return TRUE;
1374}
1375/**********************************************************
1376* ShellView_WndProc
1377*/
1378
1379static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1380{
1381 IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongA(hWnd, GWL_USERDATA);
1382 LPCREATESTRUCTA lpcs;
1383
1384 TRACE("(hwnd=%x msg=%x wparm=%x lparm=%lx)\n",hWnd, uMessage, wParam, lParam);
1385
1386 switch (uMessage)
1387 {
1388 case WM_NCCREATE:
1389 lpcs = (LPCREATESTRUCTA)lParam;
1390 pThis = (IShellViewImpl*)(lpcs->lpCreateParams);
1391 SetWindowLongA(hWnd, GWL_USERDATA, (LONG)pThis);
1392 pThis->hWnd = hWnd; /*set the window handle*/
1393 break;
1394
1395 case WM_SIZE: return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam));
1396 case WM_SETFOCUS: return ShellView_OnSetFocus(pThis);
1397 case WM_KILLFOCUS: return ShellView_OnKillFocus(pThis);
1398 case WM_CREATE: return ShellView_OnCreate(pThis);
1399 case WM_ACTIVATE: return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS);
1400 case WM_NOTIFY: return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam);
1401 case WM_COMMAND: return ShellView_OnCommand(pThis,
1402 GET_WM_COMMAND_ID(wParam, lParam),
1403 GET_WM_COMMAND_CMD(wParam, lParam),
1404 GET_WM_COMMAND_HWND(wParam, lParam));
1405 case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (LPITEMIDLIST*)wParam, (LONG)lParam);
1406
1407 case WM_CONTEXTMENU: ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE);
1408 return 0;
1409
1410 case WM_SHOWWINDOW: UpdateWindow(pThis->hWndList);
1411 break;
1412
1413 case WM_GETDLGCODE: return SendMessageA(pThis->hWndList,uMessage,0,0);
1414
1415 case WM_DESTROY: if(GetShellOle())
1416 {
1417 pRevokeDragDrop(pThis->hWnd);
1418 }
1419 SHChangeNotifyDeregister(pThis->hNotify);
1420 break;
1421 }
1422
1423 return DefWindowProcA (hWnd, uMessage, wParam, lParam);
1424}
1425/**********************************************************
1426*
1427*
1428* The INTERFACE of the IShellView object
1429*
1430*
1431**********************************************************
1432* IShellView_QueryInterface
1433*/
1434static HRESULT WINAPI IShellView_fnQueryInterface(IShellView * iface,REFIID riid, LPVOID *ppvObj)
1435{
1436 ICOM_THIS(IShellViewImpl, iface);
1437
1438 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1439
1440 *ppvObj = NULL;
1441
1442 if(IsEqualIID(riid, &IID_IUnknown))
1443 {
1444 *ppvObj = This;
1445 }
1446 else if(IsEqualIID(riid, &IID_IShellView))
1447 {
1448 *ppvObj = (IShellView*)This;
1449 }
1450 else if(IsEqualIID(riid, &IID_IOleCommandTarget))
1451 {
1452 *ppvObj = (IOleCommandTarget*)&(This->lpvtblOleCommandTarget);
1453 }
1454 else if(IsEqualIID(riid, &IID_IDropTarget))
1455 {
1456 *ppvObj = (IDropTarget*)&(This->lpvtblDropTarget);
1457 }
1458 else if(IsEqualIID(riid, &IID_IDropSource))
1459 {
1460 *ppvObj = (IDropSource*)&(This->lpvtblDropSource);
1461 }
1462 else if(IsEqualIID(riid, &IID_IViewObject))
1463 {
1464 *ppvObj = (IViewObject*)&(This->lpvtblViewObject);
1465 }
1466
1467 if(*ppvObj)
1468 {
1469 IUnknown_AddRef( (IUnknown*)*ppvObj );
1470 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1471 return S_OK;
1472 }
1473 TRACE("-- Interface: E_NOINTERFACE\n");
1474 return E_NOINTERFACE;
1475}
1476
1477/**********************************************************
1478* IShellView_AddRef
1479*/
1480static ULONG WINAPI IShellView_fnAddRef(IShellView * iface)
1481{
1482 ICOM_THIS(IShellViewImpl, iface);
1483
1484 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1485
1486 shell32_ObjCount++;
1487 return ++(This->ref);
1488}
1489/**********************************************************
1490* IShellView_Release
1491*/
1492static ULONG WINAPI IShellView_fnRelease(IShellView * iface)
1493{
1494 ICOM_THIS(IShellViewImpl, iface);
1495
1496 TRACE("(%p)->()\n",This);
1497
1498 shell32_ObjCount--;
1499
1500 if (!--(This->ref))
1501 {
1502 TRACE(" destroying IShellView(%p)\n",This);
1503
1504 if(This->pSFParent)
1505 IShellFolder_Release(This->pSFParent);
1506
1507 if(This->pSF2Parent)
1508 IShellFolder2_Release(This->pSF2Parent);
1509
1510 if (This->apidl)
1511 SHFree(This->apidl);
1512
1513 if (This->pCommDlgBrowser)
1514 ICommDlgBrowser_Release(This->pCommDlgBrowser);
1515
1516 HeapFree(GetProcessHeap(),0,This);
1517 return 0;
1518 }
1519 return This->ref;
1520}
1521
1522/**********************************************************
1523* ShellView_GetWindow
1524*/
1525static HRESULT WINAPI IShellView_fnGetWindow(IShellView * iface,HWND * phWnd)
1526{
1527 ICOM_THIS(IShellViewImpl, iface);
1528
1529 TRACE("(%p)\n",This);
1530
1531 *phWnd = This->hWnd;
1532
1533 return S_OK;
1534}
1535
1536static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView * iface,BOOL fEnterMode)
1537{
1538 ICOM_THIS(IShellViewImpl, iface);
1539
1540 FIXME("(%p) stub\n",This);
1541
1542 return E_NOTIMPL;
1543}
1544
1545/**********************************************************
1546* IShellView_TranslateAccelerator
1547*
1548* FIXME:
1549* use the accel functions
1550*/
1551static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg)
1552{
1553#if 0
1554 ICOM_THIS(IShellViewImpl, iface);
1555
1556 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1557#endif
1558
1559 if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST))
1560 {
1561 TRACE("-- key=0x04%x",lpmsg->wParam) ;
1562 }
1563 return S_FALSE; /* not handled */
1564}
1565
1566static HRESULT WINAPI IShellView_fnEnableModeless(IShellView * iface,BOOL fEnable)
1567{
1568 ICOM_THIS(IShellViewImpl, iface);
1569
1570 FIXME("(%p) stub\n",This);
1571
1572 return E_NOTIMPL;
1573}
1574
1575static HRESULT WINAPI IShellView_fnUIActivate(IShellView * iface,UINT uState)
1576{
1577 ICOM_THIS(IShellViewImpl, iface);
1578
1579/*
1580 CHAR szName[MAX_PATH];
1581*/
1582 LRESULT lResult;
1583 int nPartArray[1] = {-1};
1584
1585 TRACE("(%p)->(state=%x) stub\n",This, uState);
1586
1587 /*don't do anything if the state isn't really changing*/
1588 if(This->uState == uState)
1589 {
1590 return S_OK;
1591 }
1592
1593 /*OnActivate handles the menu merging and internal state*/
1594 ShellView_OnActivate(This, uState);
1595
1596 /*only do This if we are active*/
1597 if(uState != SVUIA_DEACTIVATE)
1598 {
1599
1600/*
1601 GetFolderPath is not a method of IShellFolder
1602 IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1603*/
1604 /* set the number of parts */
1605 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1606 (LPARAM)nPartArray, &lResult);
1607
1608 /* set the text for the parts */
1609/*
1610 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1611 0, (LPARAM)szName, &lResult);
1612*/
1613 }
1614
1615 return S_OK;
1616}
1617
1618static HRESULT WINAPI IShellView_fnRefresh(IShellView * iface)
1619{
1620 ICOM_THIS(IShellViewImpl, iface);
1621
1622 TRACE("(%p)\n",This);
1623
1624 ListView_DeleteAllItems(This->hWndList);
1625 ShellView_FillList(This);
1626
1627 return S_OK;
1628}
1629
1630static HRESULT WINAPI IShellView_fnCreateViewWindow(
1631 IShellView * iface,
1632 IShellView *lpPrevView,
1633 LPCFOLDERSETTINGS lpfs,
1634 IShellBrowser * psb,
1635 RECT * prcView,
1636 HWND *phWnd)
1637{
1638 ICOM_THIS(IShellViewImpl, iface);
1639
1640 WNDCLASSA wc;
1641 *phWnd = 0;
1642
1643
1644 TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This, lpPrevView,lpfs, psb, prcView, phWnd);
1645 TRACE("-- vmode=%x flags=%x left=%i top=%i right=%i bottom=%i\n",lpfs->ViewMode, lpfs->fFlags ,prcView->left,prcView->top, prcView->right, prcView->bottom);
1646
1647 /*set up the member variables*/
1648 This->pShellBrowser = psb;
1649 This->FolderSettings = *lpfs;
1650
1651 /*get our parent window*/
1652 IShellBrowser_AddRef(This->pShellBrowser);
1653 IShellBrowser_GetWindow(This->pShellBrowser, &(This->hWndParent));
1654
1655 /* try to get the ICommDlgBrowserInterface, adds a reference !!! */
1656 This->pCommDlgBrowser=NULL;
1657 if ( SUCCEEDED (IShellBrowser_QueryInterface( This->pShellBrowser,
1658 (REFIID)&IID_ICommDlgBrowser, (LPVOID*) &This->pCommDlgBrowser)))
1659 {
1660 TRACE("-- CommDlgBrowser\n");
1661 }
1662
1663 /*if our window class has not been registered, then do so*/
1664 if(!GetClassInfoA(shell32_hInstance, SV_CLASS_NAME, &wc))
1665 {
1666 ZeroMemory(&wc, sizeof(wc));
1667 wc.style = CS_HREDRAW | CS_VREDRAW;
1668 wc.lpfnWndProc = (WNDPROC) ShellView_WndProc;
1669 wc.cbClsExtra = 0;
1670 wc.cbWndExtra = 0;
1671 wc.hInstance = shell32_hInstance;
1672 wc.hIcon = 0;
1673 wc.hCursor = LoadCursorA (0, IDC_ARROWA);
1674 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
1675 wc.lpszMenuName = NULL;
1676 wc.lpszClassName = SV_CLASS_NAME;
1677
1678 if(!RegisterClassA(&wc))
1679 return E_FAIL;
1680 }
1681
1682 *phWnd = CreateWindowExA(0,
1683 SV_CLASS_NAME,
1684 NULL,
1685 WS_CHILD | WS_VISIBLE | WS_TABSTOP,
1686 prcView->left,
1687 prcView->top,
1688 prcView->right - prcView->left,
1689 prcView->bottom - prcView->top,
1690 This->hWndParent,
1691 0,
1692 shell32_hInstance,
1693 (LPVOID)This);
1694
1695 CheckToolbar(This);
1696
1697 if(!*phWnd) return E_FAIL;
1698
1699 return S_OK;
1700}
1701
1702static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView * iface)
1703{
1704 ICOM_THIS(IShellViewImpl, iface);
1705
1706 TRACE("(%p)\n",This);
1707
1708 /*Make absolutely sure all our UI is cleaned up.*/
1709 IShellView_UIActivate((IShellView*)This, SVUIA_DEACTIVATE);
1710
1711 if(This->hMenu)
1712 {
1713 DestroyMenu(This->hMenu);
1714 }
1715
1716 DestroyWindow(This->hWnd);
1717 IShellBrowser_Release(This->pShellBrowser);
1718
1719 return S_OK;
1720}
1721
1722static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView * iface, LPFOLDERSETTINGS lpfs)
1723{
1724 ICOM_THIS(IShellViewImpl, iface);
1725
1726 TRACE("(%p)->(%p) vmode=%x flags=%x\n",This, lpfs,
1727 This->FolderSettings.ViewMode, This->FolderSettings.fFlags);
1728
1729 if (!lpfs) return E_INVALIDARG;
1730
1731 *lpfs = This->FolderSettings;
1732 return NOERROR;
1733}
1734
1735static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView * iface, DWORD dwReserved,LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
1736{
1737 ICOM_THIS(IShellViewImpl, iface);
1738
1739 FIXME("(%p) stub\n",This);
1740
1741 return E_NOTIMPL;
1742}
1743
1744static HRESULT WINAPI IShellView_fnSaveViewState(IShellView * iface)
1745{
1746 ICOM_THIS(IShellViewImpl, iface);
1747
1748 FIXME("(%p) stub\n",This);
1749
1750 return S_OK;
1751}
1752
1753static HRESULT WINAPI IShellView_fnSelectItem(
1754 IShellView * iface,
1755 LPCITEMIDLIST pidl,
1756 UINT uFlags)
1757{
1758 ICOM_THIS(IShellViewImpl, iface);
1759 int i;
1760
1761 TRACE("(%p)->(pidl=%p, 0x%08x) stub\n",This, pidl, uFlags);
1762
1763 i = LV_FindItemByPidl(This, pidl);
1764
1765 if (i != -1)
1766 {
1767 LVITEMA lvItem;
1768
1769 if(uFlags & SVSI_ENSUREVISIBLE)
1770 ListView_EnsureVisible(This->hWndList, i, 0);
1771
1772 ZeroMemory(&lvItem, sizeof(LVITEMA));
1773 lvItem.mask = LVIF_STATE;
1774 lvItem.iItem = 0;
1775
1776 while(ListView_GetItemA(This->hWndList, &lvItem))
1777 {
1778 if (lvItem.iItem == i)
1779 {
1780 if (uFlags & SVSI_SELECT)
1781 lvItem.state |= LVIS_SELECTED;
1782 else
1783 lvItem.state &= ~LVIS_SELECTED;
1784
1785 if(uFlags & SVSI_FOCUSED)
1786 lvItem.state &= ~LVIS_FOCUSED;
1787 }
1788 else
1789 {
1790 if (uFlags & SVSI_DESELECTOTHERS)
1791 lvItem.state &= ~LVIS_SELECTED;
1792 }
1793 ListView_SetItemA(This->hWndList, &lvItem);
1794 lvItem.iItem++;
1795 }
1796
1797
1798 if(uFlags & SVSI_EDIT)
1799 ListView_EditLabelA(This->hWndList, i);
1800
1801 }
1802 return S_OK;
1803}
1804
1805static HRESULT WINAPI IShellView_fnGetItemObject(IShellView * iface, UINT uItem, REFIID riid, LPVOID *ppvOut)
1806{
1807 ICOM_THIS(IShellViewImpl, iface);
1808
1809 TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This, uItem, debugstr_guid(riid), ppvOut);
1810
1811 *ppvOut = NULL;
1812
1813 switch(uItem)
1814 {
1815 case SVGIO_BACKGROUND:
1816 *ppvOut = ISvBgCm_Constructor(This->pSFParent);
1817 break;
1818
1819 case SVGIO_SELECTION:
1820 ShellView_GetSelections(This);
1821 IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, riid, 0, ppvOut);
1822 break;
1823 }
1824 TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
1825
1826 if(!*ppvOut) return E_OUTOFMEMORY;
1827
1828 return S_OK;
1829}
1830
1831static HRESULT WINAPI IShellView_fnEditItem(
1832 IShellView * iface,
1833 LPITEMIDLIST pidl)
1834{
1835 ICOM_THIS(IShellViewImpl, iface);
1836 int i;
1837
1838 TRACE("(%p)->(pidl=%p)\n",This, pidl);
1839
1840 i = LV_FindItemByPidl(This, pidl);
1841 if (i != -1)
1842 {
1843 SetFocus(This->hWndList);
1844 ListView_EditLabelA(This->hWndList, i);
1845 }
1846 return S_OK;
1847}
1848
1849static struct ICOM_VTABLE(IShellView) svvt =
1850{
1851 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1852 IShellView_fnQueryInterface,
1853 IShellView_fnAddRef,
1854 IShellView_fnRelease,
1855 IShellView_fnGetWindow,
1856 IShellView_fnContextSensitiveHelp,
1857 IShellView_fnTranslateAccelerator,
1858 IShellView_fnEnableModeless,
1859 IShellView_fnUIActivate,
1860 IShellView_fnRefresh,
1861 IShellView_fnCreateViewWindow,
1862 IShellView_fnDestroyViewWindow,
1863 IShellView_fnGetCurrentInfo,
1864 IShellView_fnAddPropertySheetPages,
1865 IShellView_fnSaveViewState,
1866 IShellView_fnSelectItem,
1867 IShellView_fnGetItemObject,
1868 IShellView_fnEditItem
1869};
1870
1871
1872/**********************************************************
1873 * ISVOleCmdTarget_QueryInterface (IUnknown)
1874 */
1875static HRESULT WINAPI ISVOleCmdTarget_QueryInterface(
1876 IOleCommandTarget * iface,
1877 REFIID iid,
1878 LPVOID* ppvObj)
1879{
1880 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1881
1882 return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj);
1883}
1884
1885/**********************************************************
1886 * ISVOleCmdTarget_AddRef (IUnknown)
1887 */
1888static ULONG WINAPI ISVOleCmdTarget_AddRef(
1889 IOleCommandTarget * iface)
1890{
1891 _ICOM_THIS_From_IOleCommandTarget(IShellFolder, iface);
1892
1893 return IShellFolder_AddRef((IShellFolder*)This);
1894}
1895
1896/**********************************************************
1897 * ISVOleCmdTarget_Release (IUnknown)
1898 */
1899static ULONG WINAPI ISVOleCmdTarget_Release(
1900 IOleCommandTarget * iface)
1901{
1902 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1903
1904 return IShellFolder_Release((IShellFolder*)This);
1905}
1906
1907/**********************************************************
1908 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
1909 */
1910static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
1911 IOleCommandTarget *iface,
1912 const GUID* pguidCmdGroup,
1913 ULONG cCmds,
1914 OLECMD * prgCmds,
1915 OLECMDTEXT* pCmdText)
1916{
1917 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1918
1919 FIXME("(%p)->(%p(%s) 0x%08lx %p %p\n",
1920 This, pguidCmdGroup, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
1921 return E_NOTIMPL;
1922}
1923
1924/**********************************************************
1925 * ISVOleCmdTarget_Exec (IOleCommandTarget)
1926 *
1927 * nCmdID is the OLECMDID_* enumeration
1928 */
1929static HRESULT WINAPI ISVOleCmdTarget_Exec(
1930 IOleCommandTarget *iface,
1931 const GUID* pguidCmdGroup,
1932 DWORD nCmdID,
1933 DWORD nCmdexecopt,
1934 VARIANT* pvaIn,
1935 VARIANT* pvaOut)
1936{
1937 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1938
1939 FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08lx Opt:0x%08lx %p %p)\n",
1940 This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, pvaIn, pvaOut);
1941 return E_NOTIMPL;
1942}
1943
1944static ICOM_VTABLE(IOleCommandTarget) ctvt =
1945{
1946 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1947 ISVOleCmdTarget_QueryInterface,
1948 ISVOleCmdTarget_AddRef,
1949 ISVOleCmdTarget_Release,
1950 ISVOleCmdTarget_QueryStatus,
1951 ISVOleCmdTarget_Exec
1952};
1953
1954/**********************************************************
1955 * ISVDropTarget implementation
1956 */
1957
1958static HRESULT WINAPI ISVDropTarget_QueryInterface(
1959 IDropTarget *iface,
1960 REFIID riid,
1961 LPVOID *ppvObj)
1962{
1963 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1964
1965 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1966
1967 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
1968}
1969
1970static ULONG WINAPI ISVDropTarget_AddRef( IDropTarget *iface)
1971{
1972 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1973
1974 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1975
1976 return IShellFolder_AddRef((IShellFolder*)This);
1977}
1978
1979static ULONG WINAPI ISVDropTarget_Release( IDropTarget *iface)
1980{
1981 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1982
1983 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1984
1985 return IShellFolder_Release((IShellFolder*)This);
1986}
1987
1988static HRESULT WINAPI ISVDropTarget_DragEnter(
1989 IDropTarget *iface,
1990 IDataObject *pDataObject,
1991 DWORD grfKeyState,
1992 POINTL pt,
1993 DWORD *pdwEffect)
1994{
1995
1996 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1997
1998 FIXME("Stub: This=%p, DataObject=%p\n",This,pDataObject);
1999
2000 return E_NOTIMPL;
2001}
2002
2003static HRESULT WINAPI ISVDropTarget_DragOver(
2004 IDropTarget *iface,
2005 DWORD grfKeyState,
2006 POINTL pt,
2007 DWORD *pdwEffect)
2008{
2009 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2010
2011 FIXME("Stub: This=%p\n",This);
2012
2013 return E_NOTIMPL;
2014}
2015
2016static HRESULT WINAPI ISVDropTarget_DragLeave(
2017 IDropTarget *iface)
2018{
2019 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2020
2021 FIXME("Stub: This=%p\n",This);
2022
2023 return E_NOTIMPL;
2024}
2025
2026static HRESULT WINAPI ISVDropTarget_Drop(
2027 IDropTarget *iface,
2028 IDataObject* pDataObject,
2029 DWORD grfKeyState,
2030 POINTL pt,
2031 DWORD *pdwEffect)
2032{
2033 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
2034
2035 FIXME("Stub: This=%p\n",This);
2036
2037 return E_NOTIMPL;
2038}
2039
2040static struct ICOM_VTABLE(IDropTarget) dtvt =
2041{
2042 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2043 ISVDropTarget_QueryInterface,
2044 ISVDropTarget_AddRef,
2045 ISVDropTarget_Release,
2046 ISVDropTarget_DragEnter,
2047 ISVDropTarget_DragOver,
2048 ISVDropTarget_DragLeave,
2049 ISVDropTarget_Drop
2050};
2051
2052/**********************************************************
2053 * ISVDropSource implementation
2054 */
2055
2056static HRESULT WINAPI ISVDropSource_QueryInterface(
2057 IDropSource *iface,
2058 REFIID riid,
2059 LPVOID *ppvObj)
2060{
2061 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2062
2063 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2064
2065 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2066}
2067
2068static ULONG WINAPI ISVDropSource_AddRef( IDropSource *iface)
2069{
2070 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2071
2072 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2073
2074 return IShellFolder_AddRef((IShellFolder*)This);
2075}
2076
2077static ULONG WINAPI ISVDropSource_Release( IDropSource *iface)
2078{
2079 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2080
2081 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2082
2083 return IShellFolder_Release((IShellFolder*)This);
2084}
2085static HRESULT WINAPI ISVDropSource_QueryContinueDrag(
2086 IDropSource *iface,
2087 BOOL fEscapePressed,
2088 DWORD grfKeyState)
2089{
2090 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2091 TRACE("(%p)\n",This);
2092
2093 if (fEscapePressed)
2094 return DRAGDROP_S_CANCEL;
2095 else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
2096 return DRAGDROP_S_DROP;
2097 else
2098 return NOERROR;
2099}
2100
2101static HRESULT WINAPI ISVDropSource_GiveFeedback(
2102 IDropSource *iface,
2103 DWORD dwEffect)
2104{
2105 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2106 TRACE("(%p)\n",This);
2107
2108 return DRAGDROP_S_USEDEFAULTCURSORS;
2109}
2110
2111static struct ICOM_VTABLE(IDropSource) dsvt =
2112{
2113 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2114 ISVDropSource_QueryInterface,
2115 ISVDropSource_AddRef,
2116 ISVDropSource_Release,
2117 ISVDropSource_QueryContinueDrag,
2118 ISVDropSource_GiveFeedback
2119};
2120/**********************************************************
2121 * ISVViewObject implementation
2122 */
2123
2124static HRESULT WINAPI ISVViewObject_QueryInterface(
2125 IViewObject *iface,
2126 REFIID riid,
2127 LPVOID *ppvObj)
2128{
2129 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2130
2131 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2132
2133 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2134}
2135
2136static ULONG WINAPI ISVViewObject_AddRef( IViewObject *iface)
2137{
2138 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2139
2140 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2141
2142 return IShellFolder_AddRef((IShellFolder*)This);
2143}
2144
2145static ULONG WINAPI ISVViewObject_Release( IViewObject *iface)
2146{
2147 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2148
2149 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2150
2151 return IShellFolder_Release((IShellFolder*)This);
2152}
2153
2154static HRESULT WINAPI ISVViewObject_Draw(
2155 IViewObject *iface,
2156 DWORD dwDrawAspect,
2157 LONG lindex,
2158 void* pvAspect,
2159 DVTARGETDEVICE* ptd,
2160 HDC hdcTargetDev,
2161 HDC hdcDraw,
2162 LPCRECTL lprcBounds,
2163 LPCRECTL lprcWBounds,
2164 IVO_ContCallback pfnContinue,
2165 DWORD dwContinue)
2166{
2167
2168 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2169
2170 FIXME("Stub: This=%p\n",This);
2171
2172 return E_NOTIMPL;
2173}
2174static HRESULT WINAPI ISVViewObject_GetColorSet(
2175 IViewObject *iface,
2176 DWORD dwDrawAspect,
2177 LONG lindex,
2178 void *pvAspect,
2179 DVTARGETDEVICE* ptd,
2180 HDC hicTargetDevice,
2181 LOGPALETTE** ppColorSet)
2182{
2183
2184 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2185
2186 FIXME("Stub: This=%p\n",This);
2187
2188 return E_NOTIMPL;
2189}
2190static HRESULT WINAPI ISVViewObject_Freeze(
2191 IViewObject *iface,
2192 DWORD dwDrawAspect,
2193 LONG lindex,
2194 void* pvAspect,
2195 DWORD* pdwFreeze)
2196{
2197
2198 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2199
2200 FIXME("Stub: This=%p\n",This);
2201
2202 return E_NOTIMPL;
2203}
2204static HRESULT WINAPI ISVViewObject_Unfreeze(
2205 IViewObject *iface,
2206 DWORD dwFreeze)
2207{
2208
2209 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2210
2211 FIXME("Stub: This=%p\n",This);
2212
2213 return E_NOTIMPL;
2214}
2215static HRESULT WINAPI ISVViewObject_SetAdvise(
2216 IViewObject *iface,
2217 DWORD aspects,
2218 DWORD advf,
2219 IAdviseSink* pAdvSink)
2220{
2221
2222 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2223
2224 FIXME("Stub: This=%p\n",This);
2225
2226 return E_NOTIMPL;
2227}
2228static HRESULT WINAPI ISVViewObject_GetAdvise(
2229 IViewObject *iface,
2230 DWORD* pAspects,
2231 DWORD* pAdvf,
2232 IAdviseSink** ppAdvSink)
2233{
2234
2235 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2236
2237 FIXME("Stub: This=%p\n",This);
2238
2239 return E_NOTIMPL;
2240}
2241
2242
2243static struct ICOM_VTABLE(IViewObject) vovt =
2244{
2245 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2246 ISVViewObject_QueryInterface,
2247 ISVViewObject_AddRef,
2248 ISVViewObject_Release,
2249 ISVViewObject_Draw,
2250 ISVViewObject_GetColorSet,
2251 ISVViewObject_Freeze,
2252 ISVViewObject_Unfreeze,
2253 ISVViewObject_SetAdvise,
2254 ISVViewObject_GetAdvise
2255};
2256
Note: See TracBrowser for help on using the repository browser.