source: trunk/src/shell32/shlview.cpp@ 3257

Last change on this file since 3257 was 3257, checked in by cbratschi, 25 years ago

floppy name resource, release fix (don't use pdump)

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