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

Last change on this file since 6666 was 6650, checked in by bird, 24 years ago

Added $Id:$ keyword.

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