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

Last change on this file since 3792 was 3792, checked in by sandervl, 25 years ago

Put back check for registration of ShellView window class

File size: 61.0 KB
Line 
1/* $Id: shlview.cpp,v 1.14 2000-07-02 15:00:18 sandervl 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 = strcmpi(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 = strcmpi(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 = strcmpi(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 if(IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd) == S_OK)
1203 {
1204 StrRetToStrNA( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1205 TRACE("-- text=%s\n",lpdi->item.pszText);
1206 } else lpdi->item.pszText[0] = 0;
1207 }
1208 else
1209 {
1210 FIXME("no SF2\n");
1211 }
1212 }
1213 if(lpdi->item.mask & LVIF_IMAGE) /* image requested */
1214 {
1215 lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
1216 }
1217#if 0 //CB: experimental (local cache would be better)
1218 lpdi->item.mask |= LVIF_DI_SETITEM;
1219#endif
1220 break;
1221
1222 case LVN_ITEMCHANGED:
1223 if (ListView_GetNextItem(This->hWndList, -1, LVNI_FOCUSED) == lpnmlv->iItem)
1224 {
1225 TRACE("-- LVN_ITEMCHANGED %p\n",This);
1226 OnStateChange(This, CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1227 }
1228 break;
1229
1230 case LVN_BEGINDRAG:
1231 case LVN_BEGINRDRAG:
1232
1233 if (ShellView_GetSelections(This))
1234 {
1235 IDataObject * pda;
1236 DWORD dwAttributes;
1237 DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
1238
1239 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
1240 {
1241 IDropSource * pds = (IDropSource*)&(This->lpvtblDropSource); /* own DropSource interface */
1242
1243 if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, This->apidl, &dwAttributes)))
1244 {
1245 if (dwAttributes & SFGAO_CANLINK)
1246 {
1247 dwEffect |= DROPEFFECT_LINK;
1248 }
1249 }
1250
1251 if (pds)
1252 {
1253 DWORD dwEffect;
1254 pDoDragDrop(pda, pds, dwEffect, &dwEffect);
1255 }
1256
1257 IDataObject_Release(pda);
1258 }
1259 }
1260 break;
1261
1262 case LVN_BEGINLABELEDITA:
1263 return FALSE;
1264
1265 case LVN_ENDLABELEDITA:
1266 {
1267 return ShellView_OnEndLabelEdit(This,lpdi);
1268 }
1269
1270 default:
1271// TRACE("-- %p WM_COMMAND %s unhandled\n", This, SPY_GetMsgName(lpnmh->code));
1272 break;;
1273 }
1274 return 0;
1275}
1276
1277/**********************************************************
1278* ShellView_WndProc
1279*/
1280
1281static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1282{
1283 IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongA(hWnd, GWL_USERDATA);
1284 LPCREATESTRUCTA lpcs;
1285
1286 TRACE("(hwnd=%x msg=%x wparm=%x lparm=%lx)\n",hWnd, uMessage, wParam, lParam);
1287
1288 switch (uMessage)
1289 {
1290 case WM_NCCREATE:
1291 lpcs = (LPCREATESTRUCTA)lParam;
1292 pThis = (IShellViewImpl*)(lpcs->lpCreateParams);
1293 SetWindowLongA(hWnd, GWL_USERDATA, (LONG)pThis);
1294 pThis->hWnd = hWnd; /*set the window handle*/
1295 break;
1296
1297 case WM_SIZE: return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam));
1298 case WM_SETFOCUS: return ShellView_OnSetFocus(pThis);
1299 case WM_KILLFOCUS: return ShellView_OnKillFocus(pThis);
1300 case WM_CREATE: return ShellView_OnCreate(pThis);
1301 case WM_ACTIVATE: return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS);
1302 case WM_NOTIFY: return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam);
1303 case WM_COMMAND: return ShellView_OnCommand(pThis,
1304 GET_WM_COMMAND_ID(wParam, lParam),
1305 GET_WM_COMMAND_CMD(wParam, lParam),
1306 GET_WM_COMMAND_HWND(wParam, lParam));
1307
1308 case WM_CONTEXTMENU: ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE);
1309 return 0;
1310
1311 case WM_SHOWWINDOW: UpdateWindow(pThis->hWndList);
1312 break;
1313
1314 case WM_GETDLGCODE: return SendMessageA(pThis->hWndList,uMessage,0,0);
1315
1316 case WM_DESTROY: pRevokeDragDrop(pThis->hWnd);
1317 break;
1318 }
1319
1320 return DefWindowProcA (hWnd, uMessage, wParam, lParam);
1321}
1322/**********************************************************
1323*
1324*
1325* The INTERFACE of the IShellView object
1326*
1327*
1328**********************************************************
1329* IShellView_QueryInterface
1330*/
1331static HRESULT WINAPI IShellView_fnQueryInterface(IShellView * iface,REFIID riid, LPVOID *ppvObj)
1332{
1333 ICOM_THIS(IShellViewImpl, iface);
1334
1335 char xriid[50];
1336 WINE_StringFromCLSID((LPCLSID)riid,xriid);
1337 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
1338
1339 *ppvObj = NULL;
1340
1341 if(IsEqualIID(riid, &IID_IUnknown))
1342 {
1343 *ppvObj = This;
1344 }
1345 else if(IsEqualIID(riid, &IID_IShellView))
1346 {
1347 *ppvObj = (IShellView*)This;
1348 }
1349 else if(IsEqualIID(riid, &IID_IOleCommandTarget))
1350 {
1351 *ppvObj = (IOleCommandTarget*)&(This->lpvtblOleCommandTarget);
1352 }
1353 else if(IsEqualIID(riid, &IID_IDropTarget))
1354 {
1355 *ppvObj = (IDropTarget*)&(This->lpvtblDropTarget);
1356 }
1357 else if(IsEqualIID(riid, &IID_IDropSource))
1358 {
1359 *ppvObj = (IDropSource*)&(This->lpvtblDropSource);
1360 }
1361 else if(IsEqualIID(riid, &IID_IViewObject))
1362 {
1363 *ppvObj = (IViewObject*)&(This->lpvtblViewObject);
1364 }
1365
1366 if(*ppvObj)
1367 {
1368 IUnknown_AddRef( (IUnknown*)*ppvObj );
1369 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1370 return S_OK;
1371 }
1372 TRACE("-- Interface: E_NOINTERFACE\n");
1373 return E_NOINTERFACE;
1374}
1375
1376/**********************************************************
1377* IShellView_AddRef
1378*/
1379static ULONG WINAPI IShellView_fnAddRef(IShellView * iface)
1380{
1381 ICOM_THIS(IShellViewImpl, iface);
1382
1383 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1384
1385 shell32_ObjCount++;
1386 return ++(This->ref);
1387}
1388/**********************************************************
1389* IShellView_Release
1390*/
1391static ULONG WINAPI IShellView_fnRelease(IShellView * iface)
1392{
1393 ICOM_THIS(IShellViewImpl, iface);
1394
1395 TRACE("(%p)->()\n",This);
1396
1397 shell32_ObjCount--;
1398
1399 if (!--(This->ref))
1400 {
1401 TRACE(" destroying IShellView(%p)\n",This);
1402
1403 if(This->pSFParent)
1404 IShellFolder_Release(This->pSFParent);
1405
1406 if(This->pSF2Parent)
1407 IShellFolder2_Release(This->pSF2Parent);
1408
1409 if (This->apidl)
1410 SHFree(This->apidl);
1411
1412 if (This->pCommDlgBrowser)
1413 ICommDlgBrowser_Release(This->pCommDlgBrowser);
1414
1415 HeapFree(GetProcessHeap(),0,This);
1416 return 0;
1417 }
1418 return This->ref;
1419}
1420
1421/**********************************************************
1422* ShellView_GetWindow
1423*/
1424static HRESULT WINAPI IShellView_fnGetWindow(IShellView * iface,HWND * phWnd)
1425{
1426 ICOM_THIS(IShellViewImpl, iface);
1427
1428 TRACE("(%p)\n",This);
1429
1430 *phWnd = This->hWnd;
1431
1432 return S_OK;
1433}
1434
1435static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView * iface,BOOL fEnterMode)
1436{
1437 ICOM_THIS(IShellViewImpl, iface);
1438
1439 FIXME("(%p) stub\n",This);
1440
1441 return E_NOTIMPL;
1442}
1443
1444/**********************************************************
1445* IShellView_TranslateAccelerator
1446*
1447* FIXME:
1448* use the accel functions
1449*/
1450static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg)
1451{
1452#if 0
1453 ICOM_THIS(IShellViewImpl, iface);
1454
1455 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1456#endif
1457
1458 if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST))
1459 {
1460 TRACE("-- key=0x04%x",lpmsg->wParam) ;
1461 }
1462 return S_FALSE; /* not handled */
1463}
1464
1465static HRESULT WINAPI IShellView_fnEnableModeless(IShellView * iface,BOOL fEnable)
1466{
1467 ICOM_THIS(IShellViewImpl, iface);
1468
1469 FIXME("(%p) stub\n",This);
1470
1471 return E_NOTIMPL;
1472}
1473
1474static HRESULT WINAPI IShellView_fnUIActivate(IShellView * iface,UINT uState)
1475{
1476 ICOM_THIS(IShellViewImpl, iface);
1477
1478/*
1479 CHAR szName[MAX_PATH];
1480*/
1481 LRESULT lResult;
1482 int nPartArray[1] = {-1};
1483
1484 TRACE("(%p)->(state=%x) stub\n",This, uState);
1485
1486 /*don't do anything if the state isn't really changing*/
1487 if(This->uState == uState)
1488 {
1489 return S_OK;
1490 }
1491
1492 /*OnActivate handles the menu merging and internal state*/
1493 ShellView_OnActivate(This, uState);
1494
1495 /*only do This if we are active*/
1496 if(uState != SVUIA_DEACTIVATE)
1497 {
1498
1499/*
1500 GetFolderPath is not a method of IShellFolder
1501 IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1502*/
1503 /* set the number of parts */
1504 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1505 (LPARAM)nPartArray, &lResult);
1506
1507 /* set the text for the parts */
1508/*
1509 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1510 0, (LPARAM)szName, &lResult);
1511*/
1512 }
1513
1514 return S_OK;
1515}
1516
1517static HRESULT WINAPI IShellView_fnRefresh(IShellView * iface)
1518{
1519 ICOM_THIS(IShellViewImpl, iface);
1520
1521 TRACE("(%p)\n",This);
1522
1523 ListView_DeleteAllItems(This->hWndList);
1524 ShellView_FillList(This);
1525
1526 return S_OK;
1527}
1528
1529static HRESULT WINAPI IShellView_fnCreateViewWindow(
1530 IShellView * iface,
1531 IShellView *lpPrevView,
1532 LPCFOLDERSETTINGS lpfs,
1533 IShellBrowser * psb,
1534 RECT * prcView,
1535 HWND *phWnd)
1536{
1537 ICOM_THIS(IShellViewImpl, iface);
1538
1539 WNDCLASSA wc;
1540 *phWnd = 0;
1541
1542
1543 TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This, lpPrevView,lpfs, psb, prcView, phWnd);
1544 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);
1545
1546 /*set up the member variables*/
1547 This->pShellBrowser = psb;
1548 This->FolderSettings = *lpfs;
1549
1550 /*get our parent window*/
1551 IShellBrowser_AddRef(This->pShellBrowser);
1552 IShellBrowser_GetWindow(This->pShellBrowser, &(This->hWndParent));
1553
1554 /* try to get the ICommDlgBrowserInterface, adds a reference !!! */
1555 This->pCommDlgBrowser=NULL;
1556 if ( SUCCEEDED (IShellBrowser_QueryInterface( This->pShellBrowser,
1557 (REFIID)&IID_ICommDlgBrowser, (LPVOID*) &This->pCommDlgBrowser)))
1558 {
1559 TRACE("-- CommDlgBrowser\n");
1560 }
1561
1562 /*if our window class has not been registered, then do so*/
1563 if(!GetClassInfoA(shell32_hInstance, SV_CLASS_NAME, &wc))
1564 {
1565 ZeroMemory(&wc, sizeof(wc));
1566 wc.style = CS_HREDRAW | CS_VREDRAW;
1567 wc.lpfnWndProc = (WNDPROC) ShellView_WndProc;
1568 wc.cbClsExtra = 0;
1569 wc.cbWndExtra = 0;
1570 wc.hInstance = shell32_hInstance;
1571 wc.hIcon = 0;
1572 wc.hCursor = LoadCursorA (0, IDC_ARROWA);
1573 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
1574 wc.lpszMenuName = NULL;
1575 wc.lpszClassName = SV_CLASS_NAME;
1576
1577 if(!RegisterClassA(&wc))
1578 return E_FAIL;
1579 }
1580
1581 *phWnd = CreateWindowExA(0,
1582 SV_CLASS_NAME,
1583 NULL,
1584 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_TABSTOP,
1585 prcView->left,
1586 prcView->top,
1587 prcView->right - prcView->left,
1588 prcView->bottom - prcView->top,
1589 This->hWndParent,
1590 0,
1591 shell32_hInstance,
1592 (LPVOID)This);
1593
1594 CheckToolbar(This);
1595
1596 if(!*phWnd)
1597 return E_FAIL;
1598
1599 return S_OK;
1600}
1601
1602static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView * iface)
1603{
1604 ICOM_THIS(IShellViewImpl, iface);
1605
1606 TRACE("(%p)\n",This);
1607
1608 /*Make absolutely sure all our UI is cleaned up.*/
1609 IShellView_UIActivate((IShellView*)This, SVUIA_DEACTIVATE);
1610
1611 if(This->hMenu)
1612 {
1613 DestroyMenu(This->hMenu);
1614 }
1615
1616 DestroyWindow(This->hWnd);
1617 IShellBrowser_Release(This->pShellBrowser);
1618
1619 return S_OK;
1620}
1621
1622static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView * iface, LPFOLDERSETTINGS lpfs)
1623{
1624 ICOM_THIS(IShellViewImpl, iface);
1625
1626 TRACE("(%p)->(%p) vmode=%x flags=%x\n",This, lpfs,
1627 This->FolderSettings.ViewMode, This->FolderSettings.fFlags);
1628
1629 if (!lpfs) return E_INVALIDARG;
1630
1631 *lpfs = This->FolderSettings;
1632 return NOERROR;
1633}
1634
1635static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView * iface, DWORD dwReserved,LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
1636{
1637 ICOM_THIS(IShellViewImpl, iface);
1638
1639 FIXME("(%p) stub\n",This);
1640
1641 return E_NOTIMPL;
1642}
1643
1644static HRESULT WINAPI IShellView_fnSaveViewState(IShellView * iface)
1645{
1646 ICOM_THIS(IShellViewImpl, iface);
1647
1648 FIXME("(%p) stub\n",This);
1649
1650 return S_OK;
1651}
1652
1653/*************************************************************************
1654 * IShellView_fnSelectItem
1655 *
1656 * Changes the selection state of one or more items within the shell
1657 * view window.
1658 *
1659 * PARAMS
1660 * iFace [I] The IShellView structure
1661 * pidlItem [I] Address of the ITEMIDLIST structure
1662 * uFlags [I] Flag specifying what type of selection to apply.
1663 *
1664 * RETURNS
1665 * Returns NOERROR if successful otherwise S_FALSE
1666 *
1667 * NOTES
1668 * CB: can't use ListView_SetItemState return value: MS's macro doesn't return a value
1669 */
1670static HRESULT WINAPI IShellView_fnSelectItem(IShellView * iface, LPCITEMIDLIST pidlItem, UINT uFlags)
1671{ ICOM_THIS(IShellViewImpl, iface);
1672
1673 LVITEMA lvItem;
1674 int iItem=-1;
1675 BOOL bIsFound = FALSE;
1676 HRESULT hResult = NOERROR;
1677
1678 /* Find the Listview item index */
1679 ZeroMemory(&lvItem, sizeof(lvItem));
1680 lvItem.mask = LVIF_PARAM;
1681 lvItem.iItem = 0;
1682 while(ListView_GetItemA(This->hWndList, &lvItem) && !bIsFound)
1683 {
1684 if(ILIsEqual((LPCITEMIDLIST)lvItem.lParam, pidlItem))
1685 {
1686 iItem = lvItem.iItem;
1687 bIsFound = TRUE;
1688 }
1689 lvItem.iItem++;
1690 }
1691
1692 if(!bIsFound)
1693 {
1694 return S_FALSE;
1695 }
1696
1697 /* Perform flag operations */
1698 if(SVSI_DESELECT & uFlags)
1699 {
1700 ListView_SetItemState(This->hWndList,iItem,0,LVIS_SELECTED);
1701 }
1702
1703 if(SVSI_DESELECTOTHERS & uFlags)
1704 {
1705 int iOtherItems=-1;
1706 iOtherItems = ListView_GetNextItem(This->hWndList, iOtherItems, LVNI_ALL);
1707 while(iOtherItems != -1)
1708 {
1709 if(iOtherItems != iItem)
1710 {
1711 ListView_SetItemState(This->hWndList,iOtherItems,0,LVIS_SELECTED);
1712 }
1713 iOtherItems = ListView_GetNextItem(This->hWndList, iOtherItems, LVNI_ALL);
1714 }
1715 }
1716
1717 if(SVSI_ENSUREVISIBLE & uFlags)
1718 {
1719 if(ListView_EnsureVisible(This->hWndList, iItem, FALSE) != TRUE)
1720 {
1721 hResult = S_FALSE;
1722 }
1723 }
1724
1725 if(SVSI_FOCUSED & uFlags)
1726 {
1727 ListView_SetItemState(This->hWndList,iItem,LVIS_FOCUSED,LVIS_FOCUSED);
1728 }
1729
1730 if(SVSI_SELECT & uFlags)
1731 {
1732 ListView_SetItemState(This->hWndList,iItem,LVIS_FOCUSED,LVIS_FOCUSED);
1733 }
1734
1735 if(SVSI_EDIT & uFlags)
1736 {
1737 if(ListView_EditLabelA(This->hWndList, iItem) != 0)
1738 {
1739 hResult = S_FALSE;
1740 }
1741 }
1742 return NOERROR;
1743}
1744
1745static HRESULT WINAPI IShellView_fnGetItemObject(IShellView * iface, UINT uItem, REFIID riid, LPVOID *ppvOut)
1746{
1747 ICOM_THIS(IShellViewImpl, iface);
1748
1749 char xriid[50];
1750
1751 WINE_StringFromCLSID((LPCLSID)riid,xriid);
1752 TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This, uItem, xriid, ppvOut);
1753
1754 *ppvOut = NULL;
1755
1756 switch(uItem)
1757 {
1758 case SVGIO_BACKGROUND:
1759 *ppvOut = ISvBgCm_Constructor();
1760 break;
1761
1762 case SVGIO_SELECTION:
1763 ShellView_GetSelections(This);
1764 IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, riid, 0, ppvOut);
1765 break;
1766 }
1767 TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
1768
1769 if(!*ppvOut) return E_OUTOFMEMORY;
1770
1771 return S_OK;
1772}
1773
1774struct ICOM_VTABLE(IShellView) svvt =
1775{
1776 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1777 IShellView_fnQueryInterface,
1778 IShellView_fnAddRef,
1779 IShellView_fnRelease,
1780 IShellView_fnGetWindow,
1781 IShellView_fnContextSensitiveHelp,
1782 IShellView_fnTranslateAccelerator,
1783 IShellView_fnEnableModeless,
1784 IShellView_fnUIActivate,
1785 IShellView_fnRefresh,
1786 IShellView_fnCreateViewWindow,
1787 IShellView_fnDestroyViewWindow,
1788 IShellView_fnGetCurrentInfo,
1789 IShellView_fnAddPropertySheetPages,
1790 IShellView_fnSaveViewState,
1791 IShellView_fnSelectItem,
1792 IShellView_fnGetItemObject
1793};
1794
1795
1796/**********************************************************
1797 * ISVOleCmdTarget_QueryInterface (IUnknown)
1798 */
1799static HRESULT WINAPI ISVOleCmdTarget_QueryInterface(
1800 IOleCommandTarget * iface,
1801 REFIID iid,
1802 LPVOID* ppvObj)
1803{
1804 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1805
1806 return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj);
1807}
1808
1809/**********************************************************
1810 * ISVOleCmdTarget_AddRef (IUnknown)
1811 */
1812static ULONG WINAPI ISVOleCmdTarget_AddRef(
1813 IOleCommandTarget * iface)
1814{
1815 _ICOM_THIS_From_IOleCommandTarget(IShellFolder, iface);
1816
1817 return IShellFolder_AddRef((IShellFolder*)This);
1818}
1819
1820/**********************************************************
1821 * ISVOleCmdTarget_Release (IUnknown)
1822 */
1823static ULONG WINAPI ISVOleCmdTarget_Release(
1824 IOleCommandTarget * iface)
1825{
1826 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1827
1828 return IShellFolder_Release((IShellFolder*)This);
1829}
1830
1831/**********************************************************
1832 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
1833 */
1834static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
1835 IOleCommandTarget *iface,
1836 const GUID* pguidCmdGroup,
1837 ULONG cCmds,
1838 OLECMD * prgCmds,
1839 OLECMDTEXT* pCmdText)
1840{
1841 char xguid[50];
1842
1843 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1844
1845 WINE_StringFromCLSID((LPCLSID)pguidCmdGroup,xguid);
1846
1847 FIXME("(%p)->(%p(%s) 0x%08lx %p %p\n", This, pguidCmdGroup, xguid, cCmds, prgCmds, pCmdText);
1848 return E_NOTIMPL;
1849}
1850
1851/**********************************************************
1852 * ISVOleCmdTarget_Exec (IOleCommandTarget)
1853 *
1854 * nCmdID is the OLECMDID_* enumeration
1855 */
1856static HRESULT WINAPI ISVOleCmdTarget_Exec(
1857 IOleCommandTarget *iface,
1858 const GUID* pguidCmdGroup,
1859 DWORD nCmdID,
1860 DWORD nCmdexecopt,
1861 VARIANT* pvaIn,
1862 VARIANT* pvaOut)
1863{
1864 char xguid[50];
1865
1866 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1867
1868 WINE_StringFromCLSID((LPCLSID)pguidCmdGroup,xguid);
1869
1870 FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08lx Opt:0x%08lx %p %p)\n", This, xguid, nCmdID, nCmdexecopt, pvaIn, pvaOut);
1871 return E_NOTIMPL;
1872}
1873
1874ICOM_VTABLE(IOleCommandTarget) ctvt =
1875{
1876 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1877 ISVOleCmdTarget_QueryInterface,
1878 ISVOleCmdTarget_AddRef,
1879 ISVOleCmdTarget_Release,
1880 ISVOleCmdTarget_QueryStatus,
1881 ISVOleCmdTarget_Exec
1882};
1883
1884/**********************************************************
1885 * ISVDropTarget implementation
1886 */
1887
1888static HRESULT WINAPI ISVDropTarget_QueryInterface(
1889 IDropTarget *iface,
1890 REFIID riid,
1891 LPVOID *ppvObj)
1892{
1893 char xriid[50];
1894
1895 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1896
1897 WINE_StringFromCLSID((LPCLSID)riid,xriid);
1898
1899 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
1900
1901 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
1902}
1903
1904static ULONG WINAPI ISVDropTarget_AddRef( IDropTarget *iface)
1905{
1906 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1907
1908 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1909
1910 return IShellFolder_AddRef((IShellFolder*)This);
1911}
1912
1913static ULONG WINAPI ISVDropTarget_Release( IDropTarget *iface)
1914{
1915 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1916
1917 TRACE("(%p)->(count=%lu)\n",This,This->ref);
1918
1919 return IShellFolder_Release((IShellFolder*)This);
1920}
1921
1922static HRESULT WINAPI ISVDropTarget_DragEnter(
1923 IDropTarget *iface,
1924 IDataObject *pDataObject,
1925 DWORD grfKeyState,
1926 POINTL pt,
1927 DWORD *pdwEffect)
1928{
1929
1930 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1931
1932 FIXME("Stub: This=%p, DataObject=%p\n",This,pDataObject);
1933
1934 return E_NOTIMPL;
1935}
1936
1937static HRESULT WINAPI ISVDropTarget_DragOver(
1938 IDropTarget *iface,
1939 DWORD grfKeyState,
1940 POINTL pt,
1941 DWORD *pdwEffect)
1942{
1943 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1944
1945 FIXME("Stub: This=%p\n",This);
1946
1947 return E_NOTIMPL;
1948}
1949
1950static HRESULT WINAPI ISVDropTarget_DragLeave(
1951 IDropTarget *iface)
1952{
1953 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1954
1955 FIXME("Stub: This=%p\n",This);
1956
1957 return E_NOTIMPL;
1958}
1959
1960static HRESULT WINAPI ISVDropTarget_Drop(
1961 IDropTarget *iface,
1962 IDataObject* pDataObject,
1963 DWORD grfKeyState,
1964 POINTL pt,
1965 DWORD *pdwEffect)
1966{
1967 _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1968
1969 FIXME("Stub: This=%p\n",This);
1970
1971 return E_NOTIMPL;
1972}
1973
1974struct ICOM_VTABLE(IDropTarget) dtvt =
1975{
1976 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1977 ISVDropTarget_QueryInterface,
1978 ISVDropTarget_AddRef,
1979 ISVDropTarget_Release,
1980 ISVDropTarget_DragEnter,
1981 ISVDropTarget_DragOver,
1982 ISVDropTarget_DragLeave,
1983 ISVDropTarget_Drop
1984};
1985
1986/**********************************************************
1987 * ISVDropSource implementation
1988 */
1989
1990static HRESULT WINAPI ISVDropSource_QueryInterface(
1991 IDropSource *iface,
1992 REFIID riid,
1993 LPVOID *ppvObj)
1994{
1995 char xriid[50];
1996
1997 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
1998
1999 WINE_StringFromCLSID((LPCLSID)riid,xriid);
2000
2001 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
2002
2003 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2004}
2005
2006static ULONG WINAPI ISVDropSource_AddRef( IDropSource *iface)
2007{
2008 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2009
2010 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2011
2012 return IShellFolder_AddRef((IShellFolder*)This);
2013}
2014
2015static ULONG WINAPI ISVDropSource_Release( IDropSource *iface)
2016{
2017 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2018
2019 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2020
2021 return IShellFolder_Release((IShellFolder*)This);
2022}
2023static HRESULT WINAPI ISVDropSource_QueryContinueDrag(
2024 IDropSource *iface,
2025 BOOL fEscapePressed,
2026 DWORD grfKeyState)
2027{
2028 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2029 TRACE("(%p)\n",This);
2030
2031 if (fEscapePressed)
2032 return DRAGDROP_S_CANCEL;
2033 else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
2034 return DRAGDROP_S_DROP;
2035 else
2036 return NOERROR;
2037}
2038
2039static HRESULT WINAPI ISVDropSource_GiveFeedback(
2040 IDropSource *iface,
2041 DWORD dwEffect)
2042{
2043 _ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
2044 TRACE("(%p)\n",This);
2045
2046 return DRAGDROP_S_USEDEFAULTCURSORS;
2047}
2048
2049struct ICOM_VTABLE(IDropSource) dsvt =
2050{
2051 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2052 ISVDropSource_QueryInterface,
2053 ISVDropSource_AddRef,
2054 ISVDropSource_Release,
2055 ISVDropSource_QueryContinueDrag,
2056 ISVDropSource_GiveFeedback
2057};
2058/**********************************************************
2059 * ISVViewObject implementation
2060 */
2061
2062static HRESULT WINAPI ISVViewObject_QueryInterface(
2063 IViewObject *iface,
2064 REFIID riid,
2065 LPVOID *ppvObj)
2066{
2067 char xriid[50];
2068
2069 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2070
2071 WINE_StringFromCLSID((LPCLSID)riid,xriid);
2072
2073 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
2074
2075 return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
2076}
2077
2078static ULONG WINAPI ISVViewObject_AddRef( IViewObject *iface)
2079{
2080 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2081
2082 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2083
2084 return IShellFolder_AddRef((IShellFolder*)This);
2085}
2086
2087static ULONG WINAPI ISVViewObject_Release( IViewObject *iface)
2088{
2089 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2090
2091 TRACE("(%p)->(count=%lu)\n",This,This->ref);
2092
2093 return IShellFolder_Release((IShellFolder*)This);
2094}
2095
2096static HRESULT WINAPI ISVViewObject_Draw(
2097 IViewObject *iface,
2098 DWORD dwDrawAspect,
2099 LONG lindex,
2100 void* pvAspect,
2101 DVTARGETDEVICE* ptd,
2102 HDC hdcTargetDev,
2103 HDC hdcDraw,
2104 LPCRECTL lprcBounds,
2105 LPCRECTL lprcWBounds,
2106 IVO_ContCallback pfnContinue,
2107 DWORD dwContinue)
2108{
2109
2110 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2111
2112 FIXME("Stub: This=%p\n",This);
2113
2114 return E_NOTIMPL;
2115}
2116static HRESULT WINAPI ISVViewObject_GetColorSet(
2117 IViewObject *iface,
2118 DWORD dwDrawAspect,
2119 LONG lindex,
2120 void *pvAspect,
2121 DVTARGETDEVICE* ptd,
2122 HDC hicTargetDevice,
2123 tagLOGPALETTE** ppColorSet)
2124{
2125
2126 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2127
2128 FIXME("Stub: This=%p\n",This);
2129
2130 return E_NOTIMPL;
2131}
2132static HRESULT WINAPI ISVViewObject_Freeze(
2133 IViewObject *iface,
2134 DWORD dwDrawAspect,
2135 LONG lindex,
2136 void* pvAspect,
2137 DWORD* pdwFreeze)
2138{
2139
2140 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2141
2142 FIXME("Stub: This=%p\n",This);
2143
2144 return E_NOTIMPL;
2145}
2146static HRESULT WINAPI ISVViewObject_Unfreeze(
2147 IViewObject *iface,
2148 DWORD dwFreeze)
2149{
2150
2151 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2152
2153 FIXME("Stub: This=%p\n",This);
2154
2155 return E_NOTIMPL;
2156}
2157static HRESULT WINAPI ISVViewObject_SetAdvise(
2158 IViewObject *iface,
2159 DWORD aspects,
2160 DWORD advf,
2161 IAdviseSink* pAdvSink)
2162{
2163
2164 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2165
2166 FIXME("Stub: This=%p\n",This);
2167
2168 return E_NOTIMPL;
2169}
2170static HRESULT WINAPI ISVViewObject_GetAdvise(
2171 IViewObject *iface,
2172 DWORD* pAspects,
2173 DWORD* pAdvf,
2174 IAdviseSink** ppAdvSink)
2175{
2176
2177 _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
2178
2179 FIXME("Stub: This=%p\n",This);
2180
2181 return E_NOTIMPL;
2182}
2183
2184
2185struct ICOM_VTABLE(IViewObject) vovt =
2186{
2187 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2188 ISVViewObject_QueryInterface,
2189 ISVViewObject_AddRef,
2190 ISVViewObject_Release,
2191 ISVViewObject_Draw,
2192 ISVViewObject_GetColorSet,
2193 ISVViewObject_Freeze,
2194 ISVViewObject_Unfreeze,
2195 ISVViewObject_SetAdvise,
2196 ISVViewObject_GetAdvise
2197};
2198
Note: See TracBrowser for help on using the repository browser.