shlview.c 92.9 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2 3
/*
 *	ShellView
 *
4
 *	Copyright 1998,1999	<juergen.schmied@debitel.net>
5
 *
6
 * This is the view visualizing the data provided by the shellfolder.
7 8
 * No direct access to data from pidls should be done from here.
 *
9 10 11 12 13 14 15 16 17 18 19 20
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
21
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22
 *
23
 * FIXME: The order by part of the background context menu should be
24
 * built according to the columns shown.
25
 *
26
 * FIXME: Load/Save the view state from/into the stream provided by
27 28 29 30 31 32 33 34 35
 * the ShellBrowser
 *
 * FIXME: CheckToolbar: handle the "new folder" and "folder up" button
 *
 * FIXME: ShellView_FillList: consider sort orders
 *
 * FIXME: implement the drag and drop in the old (msg-based) way
 *
 * FIXME: when the ShellView_WndProc gets a WM_NCDESTROY should we do a
36
 * Release() ???
Alexandre Julliard's avatar
Alexandre Julliard committed
37 38
 */

39 40 41
#include "config.h"
#include "wine/port.h"

42
#include <stdarg.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
43 44
#include <stdlib.h>
#include <string.h>
45

46
#define COBJMACROS
47 48
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
49

50
#include "windef.h"
51
#include "winerror.h"
52
#include "winbase.h"
53
#include "winnls.h"
54
#include "objbase.h"
55
#include "servprov.h"
56
#include "shlguid.h"
57 58
#include "wingdi.h"
#include "winuser.h"
59
#include "shlobj.h"
60
#include "shobjidl.h"
61
#include "undocshell.h"
62
#include "shresdef.h"
63
#include "wine/debug.h"
64

65
#include "docobj.h"
66 67
#include "pidl.h"
#include "shell32_main.h"
68
#include "shellfolder.h"
69

70
WINE_DEFAULT_DEBUG_CHANNEL(shell);
71

72 73
static const WCHAR SV_CLASS_NAME[] = {'S','H','E','L','L','D','L','L','_','D','e','f','V','i','e','w',0};

74 75 76 77 78 79
typedef struct
{   BOOL    bIsAscending;
    INT     nHeaderID;
    INT     nLastHeaderID;
}LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO;

80
typedef struct
81
{
82
        IShellView2       IShellView2_iface;
83 84 85 86 87 88 89
        IOleCommandTarget IOleCommandTarget_iface;
        IDropTarget       IDropTarget_iface;
        IDropSource       IDropSource_iface;
        IViewObject       IViewObject_iface;
        IFolderView       IFolderView_iface;
        IShellFolderView  IShellFolderView_iface;
        LONG              ref;
90
	IShellFolder*	pSFParent;
91
	IShellFolder2*	pSF2Parent;
92 93
	IShellBrowser*	pShellBrowser;
	ICommDlgBrowser*	pCommDlgBrowser;
94 95
	HWND		hWnd;		/* SHELLDLL_DefView */
	HWND		hWndList;	/* ListView control */
96 97 98 99
	HWND		hWndParent;
	FOLDERSETTINGS	FolderSettings;
	HMENU		hMenu;
	UINT		uState;
100 101
	UINT		cidl;
	LPITEMIDLIST	*apidl;
102
        LISTVIEW_SORT_INFO ListViewSortInfo;
103
	ULONG			hNotify;	/* change notification handle */
104
	HANDLE		hAccel;
105 106 107
	DWORD		dwAspects;
	DWORD		dwAdvf;
	IAdviseSink    *pAdvSink;
108 109 110
        IDropTarget*    pCurDropTarget; /* The sub-item, which is currently dragged over */
        IDataObject*    pCurDataObject; /* The dragged data-object */
        LONG            iDragOverItem;  /* Dragged over item's index, iff pCurDropTarget != NULL */
111 112
        UINT            cScrollDelay;   /* Send a WM_*SCROLL msg every 250 ms during drag-scroll */
        POINT           ptLastMousePos; /* Mouse position at last DragOver call */
113 114
} IShellViewImpl;

115
static const IShellView2Vtbl svvt;
116 117 118 119
static const IOleCommandTargetVtbl ctvt;
static const IDropTargetVtbl dtvt;
static const IDropSourceVtbl dsvt;
static const IViewObjectVtbl vovt;
120
static const IFolderViewVtbl fviewvt;
121
static const IShellFolderViewVtbl shellfolderviewvt;
122

123 124 125 126 127
static inline IShellViewImpl *impl_from_IShellView2(IShellView2 *iface)
{
    return CONTAINING_RECORD(iface, IShellViewImpl, IShellView2_iface);
}

128
static inline IShellViewImpl *impl_from_IOleCommandTarget(IOleCommandTarget *iface)
129
{
130
    return CONTAINING_RECORD(iface, IShellViewImpl, IOleCommandTarget_iface);
131 132
}

133
static inline IShellViewImpl *impl_from_IDropTarget(IDropTarget *iface)
134
{
135
    return CONTAINING_RECORD(iface, IShellViewImpl, IDropTarget_iface);
136 137
}

138
static inline IShellViewImpl *impl_from_IDropSource(IDropSource *iface)
139
{
140
    return CONTAINING_RECORD(iface, IShellViewImpl, IDropSource_iface);
141 142
}

143
static inline IShellViewImpl *impl_from_IViewObject(IViewObject *iface)
144
{
145
    return CONTAINING_RECORD(iface, IShellViewImpl, IViewObject_iface);
146
}
147

148
static inline IShellViewImpl *impl_from_IFolderView(IFolderView *iface)
149
{
150
    return CONTAINING_RECORD(iface, IShellViewImpl, IFolderView_iface);
151 152
}

153
static inline IShellViewImpl *impl_from_IShellFolderView(IShellFolderView *iface)
154
{
155
    return CONTAINING_RECORD(iface, IShellViewImpl, IShellFolderView_iface);
156 157
}

158
/* ListView Header IDs */
159 160 161 162 163 164
#define LISTVIEW_COLUMN_NAME 0
#define LISTVIEW_COLUMN_SIZE 1
#define LISTVIEW_COLUMN_TYPE 2
#define LISTVIEW_COLUMN_TIME 3
#define LISTVIEW_COLUMN_ATTRIB 4

165
/*menu items */
Alexandre Julliard's avatar
Alexandre Julliard committed
166 167 168
#define IDM_VIEW_FILES  (FCIDM_SHVIEWFIRST + 0x500)
#define IDM_VIEW_IDW    (FCIDM_SHVIEWFIRST + 0x501)
#define IDM_MYFILEITEM  (FCIDM_SHVIEWFIRST + 0x502)
169

170
#define ID_LISTVIEW     1
171

172 173
#define SHV_CHANGE_NOTIFY WM_USER + 0x1111

174
/*windowsx.h */
Alexandre Julliard's avatar
Alexandre Julliard committed
175
#define GET_WM_COMMAND_ID(wp, lp)               LOWORD(wp)
176
#define GET_WM_COMMAND_HWND(wp, lp)             (HWND)(lp)
Alexandre Julliard's avatar
Alexandre Julliard committed
177
#define GET_WM_COMMAND_CMD(wp, lp)              HIWORD(wp)
178

179
/*
180
  Items merged into the toolbar and the filemenu
181
*/
Alexandre Julliard's avatar
Alexandre Julliard committed
182 183 184 185 186 187 188 189 190
typedef struct
{  int   idCommand;
   int   iImage;
   int   idButtonString;
   int   idMenuString;
   BYTE  bState;
   BYTE  bStyle;
} MYTOOLINFO, *LPMYTOOLINFO;

191
static const MYTOOLINFO Tools[] =
192
{
193 194 195 196
{ FCIDM_SHVIEW_BIGICON,    0, 0, IDS_VIEW_LARGE,   TBSTATE_ENABLED, BTNS_BUTTON },
{ FCIDM_SHVIEW_SMALLICON,  0, 0, IDS_VIEW_SMALL,   TBSTATE_ENABLED, BTNS_BUTTON },
{ FCIDM_SHVIEW_LISTVIEW,   0, 0, IDS_VIEW_LIST,    TBSTATE_ENABLED, BTNS_BUTTON },
{ FCIDM_SHVIEW_REPORTVIEW, 0, 0, IDS_VIEW_DETAILS, TBSTATE_ENABLED, BTNS_BUTTON },
197
{ -1, 0, 0, 0, 0, 0}
Alexandre Julliard's avatar
Alexandre Julliard committed
198
};
199

200
typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
Alexandre Julliard's avatar
Alexandre Julliard committed
201

202 203 204 205
/**********************************************************
 *	IShellView_Constructor
 */
IShellView * IShellView_Constructor( IShellFolder * pFolder)
206
{	IShellViewImpl * sv;
207
	sv=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl));
208
	sv->ref=1;
209
	sv->IShellView2_iface.lpVtbl = &svvt;
210 211 212 213 214 215
	sv->IOleCommandTarget_iface.lpVtbl = &ctvt;
	sv->IDropTarget_iface.lpVtbl = &dtvt;
	sv->IDropSource_iface.lpVtbl = &dsvt;
	sv->IViewObject_iface.lpVtbl = &vovt;
	sv->IFolderView_iface.lpVtbl = &fviewvt;
	sv->IShellFolderView_iface.lpVtbl = &shellfolderviewvt;
216

217 218 219
	sv->pSFParent = pFolder;
	if(pFolder) IShellFolder_AddRef(pFolder);
	IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (LPVOID*)&sv->pSF2Parent);
220

221 222 223
        sv->pCurDropTarget = NULL;
        sv->pCurDataObject = NULL;
        sv->iDragOverItem = 0;
224 225 226
        sv->cScrollDelay = 0;
        sv->ptLastMousePos.x = 0;
        sv->ptLastMousePos.y = 0;
227

228
	TRACE("(%p)->(%p)\n",sv, pFolder);
229
	return (IShellView *) sv;
Alexandre Julliard's avatar
Alexandre Julliard committed
230
}
231 232 233 234 235

/**********************************************************
 *
 * ##### helperfunctions for communication with ICommDlgBrowser #####
 */
236 237
static BOOL IsInCommDlg(IShellViewImpl * This)
{	return(This->pCommDlgBrowser != NULL);
Alexandre Julliard's avatar
Alexandre Julliard committed
238
}
239

240 241
static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl)
{
242
	HRESULT ret = S_OK;
243

244
	if ( IsInCommDlg(This) )
245 246 247
	{
	  TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
	  ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView*)This, pidl);
248
	  TRACE("--0x%08x\n", ret);
Alexandre Julliard's avatar
Alexandre Julliard committed
249
	}
250
	return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
251
}
252 253 254

static HRESULT OnDefaultCommand(IShellViewImpl * This)
{
255
	HRESULT ret = S_FALSE;
256

257
	if (IsInCommDlg(This))
258 259 260
	{
	  TRACE("ICommDlgBrowser::OnDefaultCommand\n");
	  ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView*)This);
261
	  TRACE("-- returns %08x\n", ret);
Alexandre Julliard's avatar
Alexandre Julliard committed
262
	}
263
	return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
264
}
265 266 267

static HRESULT OnStateChange(IShellViewImpl * This, UINT uFlags)
{
268 269
	HRESULT ret = S_FALSE;

270
	if (IsInCommDlg(This))
271 272 273 274
	{
	  TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags);
	  ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView*)This, uFlags);
	  TRACE("--\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
275
	}
276
	return ret;
277
}
278
/**********************************************************
279
 *	set the toolbar of the filedialog buttons
280
 *
281
 * - activates the buttons from the shellbrowser according to
282
 *   the view state
283
 */
284
static void CheckToolbar(IShellViewImpl * This)
285 286
{
	LRESULT result;
287

288
	TRACE("\n");
289

290 291 292
	if (IsInCommDlg(This))
	{
	  IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
293
                FCIDM_TB_SMALLICON, This->FolderSettings.ViewMode == FVM_LIST, &result);
294
	  IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
295
                FCIDM_TB_REPORTVIEW, This->FolderSettings.ViewMode == FVM_DETAILS, &result);
296
	  IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
297
		FCIDM_TB_SMALLICON, TRUE, &result);
298
	  IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
299
		FCIDM_TB_REPORTVIEW, TRUE, &result);
300
	}
301 302
}

303 304 305 306
/**********************************************************
 *
 * ##### helperfunctions for initializing the view #####
 */
307 308 309 310 311 312
/**********************************************************
 *	change the style of the listview control
 */
static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove)
{
	DWORD tmpstyle;
313

314
	TRACE("(%p)\n", This);
315

316 317
	tmpstyle = GetWindowLongW(This->hWndList, GWL_STYLE);
	SetWindowLongW(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove));
318
}
Alexandre Julliard's avatar
Alexandre Julliard committed
319

320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
static DWORD ViewModeToListStyle(UINT ViewMode)
{
	DWORD dwStyle;

	TRACE("%d\n", ViewMode);

	switch (ViewMode)
	{
	  case FVM_ICON:	dwStyle = LVS_ICON;		break;
	  case FVM_DETAILS:	dwStyle = LVS_REPORT;		break;
	  case FVM_SMALLICON:	dwStyle = LVS_SMALLICON;	break;
	  case FVM_LIST:	dwStyle = LVS_LIST;		break;
	  default:
	  {
		FIXME("ViewMode %d not implemented\n", ViewMode);
		dwStyle = LVS_LIST;
		break;
	  }
	}

	return dwStyle;
}

343
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
344 345
* ShellView_CreateList()
*
346
* - creates the list view window
Alexandre Julliard's avatar
Alexandre Julliard committed
347
*/
348
static BOOL ShellView_CreateList (IShellViewImpl * This)
349
{	DWORD dwStyle, dwExStyle;
Alexandre Julliard's avatar
Alexandre Julliard committed
350

351
	TRACE("%p\n",This);
Alexandre Julliard's avatar
Alexandre Julliard committed
352

353
	dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
354
		  LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_AUTOARRANGE;
355
        dwExStyle = WS_EX_CLIENTEDGE;
356

357
        dwStyle |= ViewModeToListStyle(This->FolderSettings.ViewMode);
358

359
	if (This->FolderSettings.fFlags & FWF_AUTOARRANGE)	dwStyle |= LVS_AUTOARRANGE;
360 361
	if (This->FolderSettings.fFlags & FWF_DESKTOP)
	  This->FolderSettings.fFlags |= FWF_NOCLIENTEDGE | FWF_NOSCROLL;
362
	if (This->FolderSettings.fFlags & FWF_SINGLESEL)	dwStyle |= LVS_SINGLESEL;
363 364
	if (This->FolderSettings.fFlags & FWF_NOCLIENTEDGE)
	  dwExStyle &= ~WS_EX_CLIENTEDGE;
Alexandre Julliard's avatar
Alexandre Julliard committed
365

366 367
	This->hWndList=CreateWindowExW( dwExStyle,
					WC_LISTVIEWW,
368 369 370 371 372 373 374
					NULL,
					dwStyle,
					0,0,0,0,
					This->hWnd,
					(HMENU)ID_LISTVIEW,
					shell32_hInstance,
					NULL);
Alexandre Julliard's avatar
Alexandre Julliard committed
375

376
	if(!This->hWndList)
Alexandre Julliard's avatar
Alexandre Julliard committed
377 378
	  return FALSE;

379 380 381 382
        This->ListViewSortInfo.bIsAscending = TRUE;
        This->ListViewSortInfo.nHeaderID = -1;
        This->ListViewSortInfo.nLastHeaderID = -1;

383
       if (This->FolderSettings.fFlags & FWF_DESKTOP) {
384 385 386 387 388 389 390
         /*
          * FIXME: look at the registry value
          * HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ListviewShadow
          * and activate drop shadows if necessary
          */
         if (0)
           SendMessageW(This->hWndList, LVM_SETTEXTBKCOLOR, 0, CLR_NONE);
391
         else
392
           SendMessageW(This->hWndList, LVM_SETTEXTBKCOLOR, 0, GetSysColor(COLOR_DESKTOP));
393

394
         SendMessageW(This->hWndList, LVM_SETTEXTCOLOR, 0, RGB(255,255,255));
395 396
       }

397
        /*  UpdateShellSettings(); */
Alexandre Julliard's avatar
Alexandre Julliard committed
398
	return TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
399
}
400

401
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
402
* ShellView_InitList()
403
*
404
* - adds all needed columns to the shellview
Alexandre Julliard's avatar
Alexandre Julliard committed
405
*/
406
static void ShellView_InitList(IShellViewImpl *This)
407
{
408
    IShellDetails *details = NULL;
409 410 411
    LVCOLUMNW lvColumn;
    SHELLDETAILS sd;
    WCHAR nameW[50];
412 413
    HRESULT hr;
    INT i;
Alexandre Julliard's avatar
Alexandre Julliard committed
414

415
    TRACE("(%p)\n", This);
Alexandre Julliard's avatar
Alexandre Julliard committed
416

417
    SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0);
418 419
    SendMessageW(This->hWndList, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ShellSmallIconList);
    SendMessageW(This->hWndList, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)ShellBigIconList);
Alexandre Julliard's avatar
Alexandre Julliard committed
420

421 422 423
    lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
    lvColumn.pszText = nameW;

424
    if (!This->pSF2Parent)
425
    {
426 427
        hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IShellDetails, (void**)&details);
        if (hr != S_OK)
428
        {
429 430
            WARN("IShellFolder2/IShellDetails not supported\n");
            return;
431 432
        }
    }
433 434

    for (i = 0; 1; i++)
435
    {
436
        if (This->pSF2Parent)
437 438 439 440 441 442 443 444 445
            hr = IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, i, &sd);
        else
            hr = IShellDetails_GetDetailsOf(details, NULL, i, &sd);
        if (FAILED(hr)) break;

        lvColumn.fmt = sd.fmt;
	lvColumn.cx = sd.cxChar*8; /* chars->pixel */
	StrRetToStrNW(nameW, sizeof(nameW)/sizeof(WCHAR), &sd.str, NULL);
	SendMessageW(This->hWndList, LVM_INSERTCOLUMNW, i, (LPARAM) &lvColumn);
446
    }
447

448
    if (details) IShellDetails_Release(details);
Alexandre Julliard's avatar
Alexandre Julliard committed
449
}
450

451
/**********************************************************
452
* ShellView_CompareItems()
Alexandre Julliard's avatar
Alexandre Julliard committed
453 454
*
* NOTES
455
*  internal, CALLBACK for DSA_Sort
456
*/
457 458 459
static INT CALLBACK ShellView_CompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
{
	int ret;
460
	TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1, lParam2, (LPVOID) lpData);
Alexandre Julliard's avatar
Alexandre Julliard committed
461

462 463
	if(!lpData) return 0;

464
	ret =  (SHORT) SCODE_CODE(IShellFolder_CompareIDs((LPSHELLFOLDER)lpData, 0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2));
465
	TRACE("ret=%i\n",ret);
466
	return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
467 468
}

469 470 471 472 473 474 475 476 477 478 479
/*************************************************************************
 * ShellView_ListViewCompareItems
 *
 * Compare Function for the Listview (FileOpen Dialog)
 *
 * PARAMS
 *     lParam1       [I] the first ItemIdList to compare with
 *     lParam2       [I] the second ItemIdList to compare with
 *     lpData        [I] The column ID for the header Ctrl to process
 *
 * RETURNS
480 481
 *     A negative value if the first item should precede the second,
 *     a positive value if the first item should follow the second,
482 483 484
 *     or zero if the two items are equivalent
 *
 * NOTES
485 486 487
 *	FIXME: function does what ShellView_CompareItems is supposed to do.
 *	unify it and figure out how to use the undocumented first parameter
 *	of IShellFolder_CompareIDs to do the job this function does and
488
 *	move this code to IShellFolder.
489
 *	make LISTVIEW_SORT_INFO obsolete
490
 *	the way this function works is only usable if we had only
491
 *	filesystemfolders  (25/10/99 jsch)
492 493 494 495 496 497 498
 */
static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
{
    INT nDiff=0;
    FILETIME fd1, fd2;
    char strName1[MAX_PATH], strName2[MAX_PATH];
    BOOL bIsFolder1, bIsFolder2,bIsBothFolder;
499 500
    LPITEMIDLIST pItemIdList1 = lParam1;
    LPITEMIDLIST pItemIdList2 = lParam2;
501
    LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData;
502 503 504 505 506 507 508 509 510 511 512 513


    bIsFolder1 = _ILIsFolder(pItemIdList1);
    bIsFolder2 = _ILIsFolder(pItemIdList2);
    bIsBothFolder = bIsFolder1 && bIsFolder2;

    /* When sorting between a File and a Folder, the Folder gets sorted first */
    if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder)
    {
        nDiff = bIsFolder1 ? -1 : 1;
    }
    else
514
    {
515
        /* Sort by Time: Folders or Files can be sorted */
516

517
        if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)
518 519 520 521 522 523
        {
            _ILGetFileDateTime(pItemIdList1, &fd1);
            _ILGetFileDateTime(pItemIdList2, &fd2);
            nDiff = CompareFileTime(&fd2, &fd1);
        }
        /* Sort by Attribute: Folder or Files can be sorted */
524
        else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB)
525
        {
526 527
            _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH);
            _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH);
528
            nDiff = lstrcmpiA(strName1, strName2);
529 530
        }
        /* Sort by FileName: Folder or Files can be sorted */
531
        else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder)
532 533 534 535
        {
            /* Sort by Text */
            _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
            _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
536
            nDiff = lstrcmpiA(strName1, strName2);
537 538
        }
        /* Sort by File Size, Only valid for Files */
539
        else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)
540
        {
541
            nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0));
542 543
        }
        /* Sort by File Type, Only valid for Files */
544
        else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)
545 546 547 548
        {
            /* Sort by Type */
            _ILGetFileType(pItemIdList1, strName1, MAX_PATH);
            _ILGetFileType(pItemIdList2, strName2, MAX_PATH);
549
            nDiff = lstrcmpiA(strName1, strName2);
550 551 552
        }
    }
    /*  If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
553

554 555 556 557
    if(nDiff == 0)
    {
        _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
        _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
558
        nDiff = lstrcmpiA(strName1, strName2);
559 560
    }

561 562 563 564 565
    if(!pSortInfo->bIsAscending)
    {
        nDiff = -nDiff;
    }

566 567 568 569
    return nDiff;

}

570 571
/**********************************************************
*  LV_FindItemByPidl()
572
*/
573 574
static int LV_FindItemByPidl(
	IShellViewImpl * This,
Juergen Schmied's avatar
Juergen Schmied committed
575
	LPCITEMIDLIST pidl)
576
{
577
	LVITEMW lvItem;
578
	lvItem.iSubItem = 0;
579
	lvItem.mask = LVIF_PARAM;
580
	for(lvItem.iItem = 0;
581
		SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
582
		lvItem.iItem++)
583 584 585 586 587 588 589 590 591 592 593 594 595 596
	{
	  LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam;
	  HRESULT hr = IShellFolder_CompareIDs(This->pSFParent, 0, pidl, currentpidl);
	  if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
	  {
	    return lvItem.iItem;
	  }
  	}
	return -1;
}

/**********************************************************
* LV_AddItem()
*/
Juergen Schmied's avatar
Juergen Schmied committed
597
static BOOLEAN LV_AddItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
598
{
599
	LVITEMW	lvItem;
600

Juergen Schmied's avatar
Juergen Schmied committed
601
	TRACE("(%p)(pidl=%p)\n", This, pidl);
602 603

	lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;	/*set the mask*/
604
	lvItem.iItem = SendMessageW(This->hWndList, LVM_GETITEMCOUNT, 0, 0); /*add the item to the end of the list*/
605
	lvItem.iSubItem = 0;
606
	lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidl));				/*set the item's data*/
607
	lvItem.pszText = LPSTR_TEXTCALLBACKW;			/*get text on a callback basis*/
608
	lvItem.iImage = I_IMAGECALLBACK;			/*get the image on a callback basis*/
609
        return ListView_InsertItemW(This->hWndList, &lvItem) != -1;
610 611 612 613 614
}

/**********************************************************
* LV_RenameItem()
*/
Juergen Schmied's avatar
Juergen Schmied committed
615
static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew )
616 617
{
	int nItem;
618
	LVITEMW lvItem;
619

Juergen Schmied's avatar
Juergen Schmied committed
620
	TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew);
621 622 623 624 625 626

	nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld));
	if ( -1 != nItem )
	{
	  lvItem.mask = LVIF_PARAM;		/* only the pidl */
	  lvItem.iItem = nItem;
627
	  SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
628 629 630 631 632

	  SHFree((LPITEMIDLIST)lvItem.lParam);
	  lvItem.mask = LVIF_PARAM;
	  lvItem.iItem = nItem;
	  lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew));	/* set the item's data */
633 634
	  SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem);
	  SendMessageW(This->hWndList, LVM_UPDATE, nItem, 0);
635
	  return TRUE;					/* FIXME: better handling */
636 637 638
	}
	return FALSE;
}
639
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
640 641
* ShellView_FillList()
*
642 643 644
* - gets the objectlist from the shellfolder
* - sorts the list
* - fills the list into the view
645
*/
Alexandre Julliard's avatar
Alexandre Julliard committed
646

647 648 649 650 651 652 653 654 655 656
static INT CALLBACK fill_list( LPVOID ptr, LPVOID arg )
{
    LPITEMIDLIST pidl = ptr;
    IShellViewImpl *This = arg;
    /* in a commdlg This works as a filemask*/
    if ( IncludeObject(This, pidl)==S_OK ) LV_AddItem(This, pidl);
    SHFree(pidl);
    return TRUE;
}

657
static HRESULT ShellView_FillList(IShellViewImpl *This)
658
{
659
    IShellFolderView *folderview = &This->IShellFolderView_iface;
660 661 662 663 664
    LPENUMIDLIST pEnumIDList;
    LPITEMIDLIST pidl;
    DWORD fetched;
    HRESULT hr;
    HDPA hdpa;
Alexandre Julliard's avatar
Alexandre Julliard committed
665

666
    TRACE("(%p)\n", This);
667

668 669 670
    /* get the itemlist from the shfolder*/
    hr = IShellFolder_EnumObjects(This->pSFParent, This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList);
    if (hr != S_OK) return hr;
671

672 673 674 675 676 677 678
    /* create a pointer array */
    hdpa = DPA_Create(16);
    if (!hdpa)
    {
        IEnumIDList_Release(pEnumIDList);
        return E_OUTOFMEMORY;
    }
679

680 681 682 683 684 685 686 687
    /* copy the items into the array*/
    while((S_OK == IEnumIDList_Next(pEnumIDList, 1, &pidl, &fetched)) && fetched)
    {
        if (DPA_InsertPtr(hdpa, DPA_GetPtrCount(hdpa), pidl) == -1)
        {
            SHFree(pidl);
        }
    }
688

689 690
    /* sort the array */
    DPA_Sort(hdpa, ShellView_CompareItems, (LPARAM)This->pSFParent);
691

692
    IShellFolderView_SetRedraw(folderview, FALSE);
693
    DPA_DestroyCallback(hdpa, fill_list, This);
694
    IShellFolderView_SetRedraw(folderview, TRUE);
Alexandre Julliard's avatar
Alexandre Julliard committed
695

696
    IEnumIDList_Release(pEnumIDList);
697

698
    return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
699 700
}

701
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
702
*  ShellView_OnCreate()
703
*/
704
static LRESULT ShellView_OnCreate(IShellViewImpl *This)
705
{
706
    IShellView2 *iface = &This->IShellView2_iface;
707
    static const WCHAR accel_nameW[] = {'s','h','v','_','a','c','c','e','l',0};
708 709 710
    IPersistFolder2 *ppf2;
    IDropTarget* pdt;
    HRESULT hr;
711

712
    TRACE("(%p)\n", This);
Alexandre Julliard's avatar
Alexandre Julliard committed
713

714 715
    if (ShellView_CreateList(This))
    {
716 717
        ShellView_InitList(This);
        ShellView_FillList(This);
718
    }
719

720 721 722 723 724 725
    hr = IShellView2_QueryInterface(iface, &IID_IDropTarget, (LPVOID*)&pdt);
    if (hr == S_OK)
    {
        RegisterDragDrop(This->hWnd, pdt);
        IDropTarget_Release(pdt);
    }
726

727 728 729 730
    /* register for receiving notifications */
    hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2);
    if (hr == S_OK)
    {
731
        LPITEMIDLIST raw_pidl;
732 733
        SHChangeNotifyEntry ntreg;

734
        hr = IPersistFolder2_GetCurFolder(ppf2, &raw_pidl);
735
        if(SUCCEEDED(hr))
736
        {
737 738 739 740 741 742 743 744 745 746 747 748 749 750
            LPITEMIDLIST computer_pidl;
            SHGetFolderLocation(NULL,CSIDL_DRIVES,NULL,0,&computer_pidl);
            if(ILIsParent(computer_pidl,raw_pidl,FALSE))
            {
                /* Normalize the pidl to unixfs to workaround an issue with
                 * sending notifications on dos paths
                 */
                WCHAR path[MAX_PATH];
                SHGetPathFromIDListW(raw_pidl,path);
                SHParseDisplayName(path,NULL,(LPITEMIDLIST*)&ntreg.pidl,0,NULL);
                SHFree(raw_pidl);
            }
            else
                ntreg.pidl = raw_pidl;
751
            ntreg.fRecursive = TRUE;
752
            This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNRF_InterruptLevel, SHCNE_ALLEVENTS,
753 754
                                                   SHV_CHANGE_NOTIFY, 1, &ntreg);
            SHFree((LPITEMIDLIST)ntreg.pidl);
755
            SHFree(computer_pidl);
756 757 758
        }
        IPersistFolder2_Release(ppf2);
    }
759

760
    This->hAccel = LoadAcceleratorsW(shell32_hInstance, accel_nameW);
761

762
    return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
763
}
764 765 766 767 768 769

/**********************************************************
 *	#### Handling of the menus ####
 */

/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
770
* ShellView_BuildFileMenu()
771 772
*/
static HMENU ShellView_BuildFileMenu(IShellViewImpl * This)
773 774
{	WCHAR	szText[MAX_PATH];
	MENUITEMINFOW	mii;
775
	int	nTools,i;
776
	HMENU	hSubMenu;
Alexandre Julliard's avatar
Alexandre Julliard committed
777

778
	TRACE("(%p)\n",This);
Alexandre Julliard's avatar
Alexandre Julliard committed
779

780
	hSubMenu = CreatePopupMenu();
Alexandre Julliard's avatar
Alexandre Julliard committed
781 782
	if(hSubMenu)
	{ /*get the number of items in our global array*/
783
	  for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){}
Alexandre Julliard's avatar
Alexandre Julliard committed
784

Alexandre Julliard's avatar
Alexandre Julliard committed
785
	  /*add the menu items*/
Alexandre Julliard's avatar
Alexandre Julliard committed
786
	  for(i = 0; i < nTools; i++)
787
	  {
788
	    LoadStringW(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH);
789

Alexandre Julliard's avatar
Alexandre Julliard committed
790 791 792 793
	    ZeroMemory(&mii, sizeof(mii));
	    mii.cbSize = sizeof(mii);
	    mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;

794
	    if(BTNS_SEP != Tools[i].bStyle) /* no separator*/
795 796
	    {
	      mii.fType = MFT_STRING;
Alexandre Julliard's avatar
Alexandre Julliard committed
797 798
	      mii.fState = MFS_ENABLED;
	      mii.dwTypeData = szText;
799
	      mii.wID = Tools[i].idCommand;
Alexandre Julliard's avatar
Alexandre Julliard committed
800
	    }
Alexandre Julliard's avatar
Alexandre Julliard committed
801
	    else
802 803
	    {
	      mii.fType = MFT_SEPARATOR;
Alexandre Julliard's avatar
Alexandre Julliard committed
804
	    }
805
	    /* tack This item onto the end of the menu */
806
	    InsertMenuItemW(hSubMenu, (UINT)-1, TRUE, &mii);
Alexandre Julliard's avatar
Alexandre Julliard committed
807
	  }
Alexandre Julliard's avatar
Alexandre Julliard committed
808
	}
809
	TRACE("-- return (menu=%p)\n",hSubMenu);
Alexandre Julliard's avatar
Alexandre Julliard committed
810 811
	return hSubMenu;
}
812
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
813
* ShellView_MergeFileMenu()
814
*/
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839
static void ShellView_MergeFileMenu(IShellViewImpl *This, HMENU hSubMenu)
{
     TRACE("(%p)->(submenu=%p) stub\n",This,hSubMenu);

     if (hSubMenu)
     {
         static const WCHAR dummyW[] = {'d','u','m','m','y','4','5',0};
         MENUITEMINFOW mii;

         /* insert This item at the beginning of the menu */

         mii.cbSize = sizeof(mii);
         mii.fMask = MIIM_ID | MIIM_TYPE;
         mii.wID = 0;
         mii.fType = MFT_SEPARATOR;
         InsertMenuItemW(hSubMenu, 0, TRUE, &mii);

         mii.cbSize = sizeof(mii);
         mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
         mii.dwTypeData = (LPWSTR)dummyW;
         mii.fState = MFS_ENABLED;
         mii.wID = IDM_MYFILEITEM;
         mii.fType = MFT_STRING;
         InsertMenuItemW(hSubMenu, 0, TRUE, &mii);
    }
840

841
    TRACE("--\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
842 843
}

844
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
845
* ShellView_MergeViewMenu()
846
*/
847

848
static void ShellView_MergeViewMenu(IShellViewImpl *This, HMENU hSubMenu)
849
{
850
    TRACE("(%p)->(submenu=%p)\n",This,hSubMenu);
851

852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872
    /* add a separator at the correct position in the menu */
    if (hSubMenu)
    {
        static const WCHAR menuW[] = {'M','E','N','U','_','0','0','1',0};
	static const WCHAR viewW[] = {'V','i','e','w',0};
        MENUITEMINFOW mii;

        memset(&mii, 0, sizeof(mii));
        mii.cbSize = sizeof(mii);
        mii.fMask = MIIM_ID | MIIM_TYPE;
        mii.wID = 0;
        mii.fType = MFT_SEPARATOR;
        InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);

        mii.cbSize = sizeof(mii);
        mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;
        mii.fType = MFT_STRING;
        mii.dwTypeData = (LPWSTR)viewW;
        mii.hSubMenu = LoadMenuW(shell32_hInstance, menuW);
        InsertMenuItemW(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
873
}
874

875 876 877
/**********************************************************
*   ShellView_GetSelections()
*
878 879
* - fills the this->apidl list with the selected objects
*
880 881
* RETURNS
*  number of selected items
882
*/
883 884
static UINT ShellView_GetSelections(IShellViewImpl * This)
{
885
	LVITEMW	lvItem;
886 887
	UINT	i = 0;

888
	SHFree(This->apidl);
889

890
	This->cidl = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0);
891
	This->apidl = SHAlloc(This->cidl * sizeof(LPITEMIDLIST));
892 893

	TRACE("selected=%i\n", This->cidl);
894

895 896 897 898 899 900
	if(This->apidl)
	{
	  TRACE("-- Items selected =%u\n", This->cidl);

	  lvItem.mask = LVIF_STATE | LVIF_PARAM;
	  lvItem.stateMask = LVIS_SELECTED;
901 902
	  lvItem.iItem = 0;
	  lvItem.iSubItem = 0;
903

904
	  while(ListView_GetItemW(This->hWndList, &lvItem) && (i < This->cidl))
905 906 907 908 909 910 911 912 913 914 915 916 917
	  {
	    if(lvItem.state & LVIS_SELECTED)
	    {
	      This->apidl[i] = (LPITEMIDLIST)lvItem.lParam;
	      i++;
	      TRACE("-- selected Item found\n");
	    }
	    lvItem.iItem++;
	  }
	}
	return This->cidl;

}
918 919 920 921 922 923 924 925 926 927 928 929 930

/**********************************************************
 *	ShellView_OpenSelectedItems()
 */
static HRESULT ShellView_OpenSelectedItems(IShellViewImpl * This)
{
	static UINT CF_IDLIST = 0;
	HRESULT hr;
	IDataObject* selection;
	FORMATETC fetc;
	STGMEDIUM stgm;
	LPIDA pIDList;
	LPCITEMIDLIST parent_pidl;
931 932 933
	WCHAR parent_path[MAX_PATH];
	LPCWSTR parent_dir = NULL;
	SFGAOF attribs;
934 935 936 937 938 939 940 941 942 943 944 945 946 947
	int i;

	if (0 == ShellView_GetSelections(This))
	{
	  return S_OK;
	}
	hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl,
	                                (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,
	                                0, (LPVOID *)&selection);
	if (FAILED(hr))
	  return hr;

	if (0 == CF_IDLIST)
	{
948
	  CF_IDLIST = RegisterClipboardFormatW(CFSTR_SHELLIDLISTW);
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966
	}
	fetc.cfFormat = CF_IDLIST;
	fetc.ptd = NULL;
	fetc.dwAspect = DVASPECT_CONTENT;
	fetc.lindex = -1;
	fetc.tymed = TYMED_HGLOBAL;

	hr = IDataObject_QueryGetData(selection, &fetc);
	if (FAILED(hr))
	  return hr;

	hr = IDataObject_GetData(selection, &fetc, &stgm);
	if (FAILED(hr))
	  return hr;

	pIDList = GlobalLock(stgm.u.hGlobal);

	parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pIDList+pIDList->aoffset[0]);
967 968 969 970 971 972 973
	hr = IShellFolder_GetAttributesOf(This->pSFParent, 1, &parent_pidl, &attribs);
	if (SUCCEEDED(hr) && (attribs & SFGAO_FILESYSTEM) &&
	    SHGetPathFromIDListW(parent_pidl, parent_path))
	{
	  parent_dir = parent_path;
	}

974 975 976 977 978 979 980 981 982 983 984
	for (i = pIDList->cidl; i > 0; --i)
	{
	  LPCITEMIDLIST pidl;

	  pidl = (LPCITEMIDLIST)((LPBYTE)pIDList+pIDList->aoffset[i]);

	  attribs = SFGAO_FOLDER;
	  hr = IShellFolder_GetAttributesOf(This->pSFParent, 1, &pidl, &attribs);

	  if (SUCCEEDED(hr) && ! (attribs & SFGAO_FOLDER))
	  {
985
	    SHELLEXECUTEINFOW shexinfo;
986

987
	    shexinfo.cbSize = sizeof(SHELLEXECUTEINFOW);
988 989 990 991 992
	    shexinfo.fMask = SEE_MASK_INVOKEIDLIST;	/* SEE_MASK_IDLIST is also possible. */
	    shexinfo.hwnd = NULL;
	    shexinfo.lpVerb = NULL;
	    shexinfo.lpFile = NULL;
	    shexinfo.lpParameters = NULL;
993
	    shexinfo.lpDirectory = parent_dir;
994 995 996
	    shexinfo.nShow = SW_NORMAL;
	    shexinfo.lpIDList = ILCombine(parent_pidl, pidl);

997
	    ShellExecuteExW(&shexinfo);    /* Discard error/success info */
998

999
            ILFree(shexinfo.lpIDList);
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
	  }
	}

	GlobalUnlock(stgm.u.hGlobal);
	ReleaseStgMedium(&stgm);

	IDataObject_Release(selection);

	return S_OK;
}

1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021
/**********************************************************
 *	ShellView_DoContextMenu()
 */
static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL bDefault)
{	UINT	uCommand;
	DWORD	wFlags;
	HMENU	hMenu;
	BOOL	fExplore = FALSE;
	HWND	hwndTree = 0;
	LPCONTEXTMENU	pContextMenu = NULL;
	CMINVOKECOMMANDINFO	cmi;
1022

1023 1024 1025 1026 1027
	TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, bDefault);

	/* look, what's selected and create a context menu object of it*/
	if( ShellView_GetSelections(This) )
	{
1028
	  IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, (LPCITEMIDLIST*)This->apidl,
1029
                                      &IID_IContextMenu, NULL, (LPVOID *)&pContextMenu);
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050

	  if(pContextMenu)
	  {
	    TRACE("-- pContextMenu\n");
	    hMenu = CreatePopupMenu();

	    if( hMenu )
	    {
	      /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
	      if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree)
	      {
	        TRACE("-- explore mode\n");
	        fExplore = TRUE;
	      }

	      /* build the flags depending on what we can do with the selected item */
	      wFlags = CMF_NORMAL | (This->cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0);

	      /* let the ContextMenu merge its items in */
	      if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags )))
	      {
1051 1052 1053
	        if (This->FolderSettings.fFlags & FWF_DESKTOP)
		  SetMenuDefaultItem(hMenu, FCIDM_SHVIEW_OPEN, MF_BYCOMMAND);

1054 1055 1056 1057 1058 1059 1060 1061 1062
		if( bDefault )
		{
		  TRACE("-- get menu default command\n");
		  uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS);
		}
		else
		{
		  TRACE("-- track popup\n");
		  uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
1063
		}
1064 1065 1066 1067

		if(uCommand > 0)
		{
		  TRACE("-- uCommand=%u\n", uCommand);
1068
		  if (uCommand==FCIDM_SHVIEW_OPEN && IsInCommDlg(This))
1069 1070
		  {
		    TRACE("-- dlg: OnDefaultCommand\n");
1071
		    if (OnDefaultCommand(This) != S_OK)
1072 1073 1074
		    {
		      ShellView_OpenSelectedItems(This);
		    }
1075 1076 1077 1078 1079 1080
		  }
		  else
		  {
		    TRACE("-- explore -- invoke command\n");
		    ZeroMemory(&cmi, sizeof(cmi));
		    cmi.cbSize = sizeof(cmi);
1081
		    cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */
1082
                    cmi.lpVerb = MAKEINTRESOURCEA(uCommand);
1083 1084 1085 1086 1087 1088 1089 1090
		    IContextMenu_InvokeCommand(pContextMenu, &cmi);
		  }
		}
		DestroyMenu(hMenu);
	      }
	    }
	    if (pContextMenu)
	      IContextMenu_Release(pContextMenu);
1091 1092
	  }
	}
1093
	else	/* background context menu */
1094
	{
1095 1096
	  IContextMenu2 *pCM;

1097 1098
	  hMenu = CreatePopupMenu();

1099
	  BackgroundMenu_Constructor(This->pSFParent, FALSE, &IID_IContextMenu2, (void**)&pCM);
1100
	  IContextMenu2_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
1101 1102 1103 1104

	  uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
	  DestroyMenu(hMenu);

1105
	  TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand);
1106 1107 1108

	  ZeroMemory(&cmi, sizeof(cmi));
	  cmi.cbSize = sizeof(cmi);
1109
          cmi.lpVerb = MAKEINTRESOURCEA(uCommand);
1110
	  cmi.hwnd = This->hWndParent;
1111
	  IContextMenu2_InvokeCommand(pCM, &cmi);
1112

1113
	  IContextMenu2_Release(pCM);
1114
	}
1115 1116
}

1117 1118 1119 1120 1121 1122
/**********************************************************
 *	##### message handling #####
 */

/**********************************************************
*  ShellView_OnSize()
Alexandre Julliard's avatar
Alexandre Julliard committed
1123
*/
1124 1125 1126
static LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight)
{
	TRACE("%p width=%u height=%u\n",This, wWidth,wHeight);
Alexandre Julliard's avatar
Alexandre Julliard committed
1127

1128 1129 1130 1131
	/*resize the ListView to fit our window*/
	if(This->hWndList)
	{
	  MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE);
Alexandre Julliard's avatar
Alexandre Julliard committed
1132
	}
1133

1134
	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
1135
}
1136
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1137 1138 1139 1140
* ShellView_OnDeactivate()
*
* NOTES
*  internal
1141
*/
1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
static void ShellView_OnDeactivate(IShellViewImpl * This)
{
	TRACE("%p\n",This);

	if(This->uState != SVUIA_DEACTIVATE)
	{
	  if(This->hMenu)
	  {
	    IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0);
	    IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu);
	    DestroyMenu(This->hMenu);
	    This->hMenu = 0;
	  }

	  This->uState = SVUIA_DEACTIVATE;
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
1158 1159
}

1160
/**********************************************************
1161
* ShellView_OnActivate()
1162
*/
1163 1164 1165 1166
static LRESULT ShellView_OnActivate(IShellViewImpl *This, UINT uState)
{
    OLEMENUGROUPWIDTHS   omw = { {0, 0, 0, 0, 0, 0} };
    MENUITEMINFOW mii;
Alexandre Julliard's avatar
Alexandre Julliard committed
1167

1168
    TRACE("(%p) uState=%x\n",This,uState);
Alexandre Julliard's avatar
Alexandre Julliard committed
1169

1170 1171 1172 1173
    /* don't do anything if the state isn't really changing */
    if (This->uState == uState) return S_OK;

    ShellView_OnDeactivate(This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1174

1175 1176 1177 1178 1179
    /* only do This if we are active */
    if (uState != SVUIA_DEACTIVATE)
    {
        /* merge the menus */
        This->hMenu = CreateMenu();
Alexandre Julliard's avatar
Alexandre Julliard committed
1180

1181
        if (This->hMenu)
1182
	{
1183
            static const WCHAR dummyW[] = {'d','u','m','m','y',' ','3','1',0};
1184

1185
            IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw);
1186
	    TRACE("-- after fnInsertMenusSB\n");
1187

1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209
            mii.cbSize = sizeof(mii);
            mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
            mii.fType = MFT_STRING;
            mii.fState = MFS_ENABLED;
            mii.wID = 0;
            mii.hSubMenu = ShellView_BuildFileMenu(This);
            mii.hbmpChecked = NULL;
            mii.hbmpUnchecked = NULL;
            mii.dwItemData = 0;
            /* build the top level menu get the menu item's text */
            mii.dwTypeData = (LPWSTR)dummyW;
            mii.cch = 0;
            mii.hbmpItem = NULL;

            /* insert our menu into the menu bar */
            if (mii.hSubMenu)
                InsertMenuItemW(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii);

            /* get the view menu so we can merge with it */
            memset(&mii, 0, sizeof(mii));
            mii.cbSize = sizeof(mii);
            mii.fMask = MIIM_SUBMENU;
1210

1211 1212
            if (GetMenuItemInfoW(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii))
                ShellView_MergeViewMenu(This, mii.hSubMenu);
Alexandre Julliard's avatar
Alexandre Julliard committed
1213

1214 1215
            /* add the items that should only be added if we have the focus */
	    if (SVUIA_ACTIVATE_FOCUS == uState)
1216
	    {
1217 1218 1219 1220
                /* get the file menu so we can merge with it */
                memset(&mii, 0, sizeof(mii));
                mii.cbSize = sizeof(mii);
                mii.fMask = MIIM_SUBMENU;
1221

1222 1223
                if (GetMenuItemInfoW(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii))
                    ShellView_MergeFileMenu(This, mii.hSubMenu);
Alexandre Julliard's avatar
Alexandre Julliard committed
1224
	    }
1225 1226 1227

            TRACE("-- before fnSetMenuSB\n");
            IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd);
Alexandre Julliard's avatar
Alexandre Julliard committed
1228
	}
1229 1230 1231 1232
    }
    This->uState = uState;
    TRACE("--\n");
    return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
1233 1234
}

1235
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1236 1237 1238
*  ShellView_OnSetFocus()
*
*/
1239 1240 1241 1242 1243
static LRESULT ShellView_OnSetFocus(IShellViewImpl * This)
{
	TRACE("%p\n",This);

	/* Tell the browser one of our windows has received the focus. This
1244
	should always be done before merging menus (OnActivate merges the
1245 1246
	menus) if one of our windows has the focus.*/

1247 1248
	IShellBrowser_OnViewWindowActive(This->pShellBrowser,(IShellView*) This);
	ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS);
Alexandre Julliard's avatar
Alexandre Julliard committed
1249

1250 1251 1252
	/* Set the focus to the listview */
	SetFocus(This->hWndList);

1253 1254 1255
	/* Notify the ICommDlgBrowser interface */
	OnStateChange(This,CDBOSC_SETFOCUS);

Alexandre Julliard's avatar
Alexandre Julliard committed
1256
	return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
1257 1258
}

1259
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1260
* ShellView_OnKillFocus()
1261
*/
1262 1263 1264
static LRESULT ShellView_OnKillFocus(IShellViewImpl * This)
{
	TRACE("(%p) stub\n",This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1265

1266
	ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS);
1267 1268
	/* Notify the ICommDlgBrowser */
	OnStateChange(This,CDBOSC_KILLFOCUS);
Alexandre Julliard's avatar
Alexandre Julliard committed
1269 1270 1271

	return 0;
}
1272 1273

/**********************************************************
1274
* ShellView_OnCommand()
1275 1276
*
* NOTES
1277
*	the CmdIDs are the ones from the context menu
1278
*/
1279 1280
static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd)
{
1281
	TRACE("(%p)->(0x%08x 0x%08x %p) stub\n",This, dwCmdID, dwCmd, hwndCmd);
1282

1283 1284
	switch(dwCmdID)
	{
1285
	  case FCIDM_SHVIEW_SMALLICON:
1286 1287
	    This->FolderSettings.ViewMode = FVM_SMALLICON;
	    SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK);
1288
	    CheckToolbar(This);
1289 1290 1291
	    break;

	  case FCIDM_SHVIEW_BIGICON:
1292 1293
	    This->FolderSettings.ViewMode = FVM_ICON;
	    SetStyle (This, LVS_ICON, LVS_TYPEMASK);
1294
	    CheckToolbar(This);
1295 1296 1297
	    break;

	  case FCIDM_SHVIEW_LISTVIEW:
1298 1299
	    This->FolderSettings.ViewMode = FVM_LIST;
	    SetStyle (This, LVS_LIST, LVS_TYPEMASK);
1300
	    CheckToolbar(This);
1301 1302 1303
	    break;

	  case FCIDM_SHVIEW_REPORTVIEW:
1304 1305
	    This->FolderSettings.ViewMode = FVM_DETAILS;
	    SetStyle (This, LVS_REPORT, LVS_TYPEMASK);
1306
	    CheckToolbar(This);
1307 1308
	    break;

1309
	  /* the menu IDs for sorting are 0x30... see shell32.rc */
1310 1311 1312 1313
	  case 0x30:
	  case 0x31:
	  case 0x32:
	  case 0x33:
1314
            This->ListViewSortInfo.nHeaderID = dwCmdID - 0x30;
1315 1316
	    This->ListViewSortInfo.bIsAscending = TRUE;
	    This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1317
	    SendMessageW(This->hWndList, LVM_SORTITEMS, (WPARAM) &This->ListViewSortInfo, (LPARAM)ShellView_ListViewCompareItems);
1318
	    break;
1319

1320
	  default:
1321
	    TRACE("-- COMMAND 0x%04x unhandled\n", dwCmdID);
1322 1323 1324 1325
	}
	return 0;
}

1326
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1327 1328
* ShellView_OnNotify()
*/
1329

1330
static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
1331
{	LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
1332
	NMLVDISPINFOW *lpdi = (NMLVDISPINFOW *)lpnmh;
Alexandre Julliard's avatar
Alexandre Julliard committed
1333
	LPITEMIDLIST pidl;
1334

1335
	TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code);
1336

Alexandre Julliard's avatar
Alexandre Julliard committed
1337
	switch(lpnmh->code)
1338 1339
	{
	  case NM_SETFOCUS:
1340
	    TRACE("-- NM_SETFOCUS %p\n",This);
1341
	    ShellView_OnSetFocus(This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1342 1343 1344
	    break;

	  case NM_KILLFOCUS:
1345
	    TRACE("-- NM_KILLFOCUS %p\n",This);
1346
	    ShellView_OnDeactivate(This);
1347 1348
	    /* Notify the ICommDlgBrowser interface */
	    OnStateChange(This,CDBOSC_KILLFOCUS);
Alexandre Julliard's avatar
Alexandre Julliard committed
1349 1350
	    break;

1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366
	  case NM_CUSTOMDRAW:
	    TRACE("-- NM_CUSTOMDRAW %p\n",This);
	    return CDRF_DODEFAULT;

	  case NM_RELEASEDCAPTURE:
	    TRACE("-- NM_RELEASEDCAPTURE %p\n",This);
	    break;

	  case NM_CLICK:
	    TRACE("-- NM_CLICK %p\n",This);
	    break;

	  case NM_RCLICK:
	    TRACE("-- NM_RCLICK %p\n",This);
	    break;	    

1367 1368 1369 1370 1371 1372
          case NM_DBLCLK:
            TRACE("-- NM_DBLCLK %p\n",This);
            if (OnDefaultCommand(This) != S_OK) ShellView_OpenSelectedItems(This);
            break;

          case NM_RETURN:
1373
            TRACE("-- NM_RETURN %p\n",This);
1374 1375 1376
            if (OnDefaultCommand(This) != S_OK) ShellView_OpenSelectedItems(This);
            break;

1377 1378
	  case HDN_ENDTRACKW:
	    TRACE("-- HDN_ENDTRACKW %p\n",This);
1379 1380
	    /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
	    nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
Alexandre Julliard's avatar
Alexandre Julliard committed
1381
	    break;
1382

Alexandre Julliard's avatar
Alexandre Julliard committed
1383
	  case LVN_DELETEITEM:
1384
	    TRACE("-- LVN_DELETEITEM %p\n",This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1385 1386
	    SHFree((LPITEMIDLIST)lpnmlv->lParam);     /*delete the pidl because we made a copy of it*/
	    break;
Alexandre Julliard's avatar
Alexandre Julliard committed
1387

1388 1389 1390 1391
	  case LVN_DELETEALLITEMS:
	    TRACE("-- LVN_DELETEALLITEMS %p\n",This);
	    return FALSE;

1392 1393 1394 1395
	  case LVN_INSERTITEM:
	    TRACE("-- LVN_INSERTITEM (STUB)%p\n",This);
	    break;

Alexandre Julliard's avatar
Alexandre Julliard committed
1396
	  case LVN_ITEMACTIVATE:
1397
	    TRACE("-- LVN_ITEMACTIVATE %p\n",This);
1398
	    OnStateChange(This, CDBOSC_SELCHANGE);  /* the browser will get the IDataObject now */
Alexandre Julliard's avatar
Alexandre Julliard committed
1399
	    break;
1400

1401
	  case LVN_COLUMNCLICK:
1402 1403 1404 1405 1406 1407 1408 1409 1410 1411
	    This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem;
	    if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID)
	    {
	      This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending;
	    }
	    else
	    {
	      This->ListViewSortInfo.bIsAscending = TRUE;
	    }
	    This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
1412

1413
	    SendMessageW(lpnmlv->hdr.hwndFrom, LVM_SORTITEMS, (WPARAM) &This->ListViewSortInfo, (LPARAM)ShellView_ListViewCompareItems);
1414
	    break;
1415

1416
	  case LVN_GETDISPINFOA:
1417 1418
          case LVN_GETDISPINFOW:
	    TRACE("-- LVN_GETDISPINFO %p\n",This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1419 1420
	    pidl = (LPITEMIDLIST)lpdi->item.lParam;

1421 1422
	    if(lpdi->item.mask & LVIF_TEXT)	/* text requested */
	    {
1423 1424 1425 1426
	      static WCHAR emptyW[] = { 0 };
	      SHELLDETAILS sd;
	      HRESULT hr;

1427
	      if (This->pSF2Parent)
1428
	      {
1429
	        hr = IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
Alexandre Julliard's avatar
Alexandre Julliard committed
1430
	      }
1431
	      else
1432
	      {
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449
	        IShellDetails *details;

	        hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IShellDetails, (void**)&details);
	        if (hr == S_OK)
	        {
	          hr = IShellDetails_GetDetailsOf(details, pidl, lpdi->item.iSubItem, &sd);
	          IShellDetails_Release(details);
	        }
	        else
	          WARN("IShellFolder2/IShellDetails not supported\n");
	      }

	      if (hr != S_OK)
	      {
	          /* set to empty on failure */
	          sd.str.uType = STRRET_WSTR;
	          sd.str.u.pOleStr = emptyW;
Alexandre Julliard's avatar
Alexandre Julliard committed
1450
	      }
1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463

              if (lpnmh->code == LVN_GETDISPINFOW)
              {
                  StrRetToStrNW( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
                  TRACE("-- text=%s\n", debugstr_w(lpdi->item.pszText));
              }
              else
              {
                  /* LVN_GETDISPINFOA - shouldn't happen */
                  NMLVDISPINFOA *lpdiA = (NMLVDISPINFOA *)lpnmh;
                  StrRetToStrNA( lpdiA->item.pszText, lpdiA->item.cchTextMax, &sd.str, NULL);
                  TRACE("-- text=%s\n", lpdiA->item.pszText);
              }
Alexandre Julliard's avatar
Alexandre Julliard committed
1464
	    }
1465

1466 1467 1468 1469
	    if(lpdi->item.mask & LVIF_IMAGE)	/* image requested */
	    {
	      lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
	    }
Alexandre Julliard's avatar
Alexandre Julliard committed
1470
	    break;
Alexandre Julliard's avatar
Alexandre Julliard committed
1471

Alexandre Julliard's avatar
Alexandre Julliard committed
1472
	  case LVN_ITEMCHANGED:
1473
	    TRACE("-- LVN_ITEMCHANGED %p\n",This);
1474
	    OnStateChange(This, CDBOSC_SELCHANGE);  /* the browser will get the IDataObject now */
Alexandre Julliard's avatar
Alexandre Julliard committed
1475 1476
	    break;

1477 1478
	  case LVN_BEGINDRAG:
	  case LVN_BEGINRDRAG:
1479
	    TRACE("-- LVN_BEGINDRAG\n");
1480 1481

	    if (ShellView_GetSelections(This))
1482
	    {
1483
	      IDataObject * pda;
Juergen Schmied's avatar
Juergen Schmied committed
1484
	      DWORD dwAttributes = SFGAO_CANLINK;
1485
	      DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
1486

1487
	      if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
1488
	      {
1489
                  IDropSource *pds = &This->IDropSource_iface; /* own DropSource interface */
1490

1491
	  	  if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, (LPCITEMIDLIST*)This->apidl, &dwAttributes)))
1492
		  {
1493 1494 1495 1496
		    if (dwAttributes & SFGAO_CANLINK)
		    {
		      dwEffect |= DROPEFFECT_LINK;
		    }
1497
		  }
1498

1499 1500
	          if (pds)
	          {
1501 1502
	            DWORD dwEffect2;
		    DoDragDrop(pda, pds, dwEffect, &dwEffect2);
1503 1504
		  }
	          IDataObject_Release(pda);
1505 1506 1507 1508
	      }
	    }
	    break;

1509
	  case LVN_BEGINLABELEDITW:
1510 1511 1512 1513
	    {
	      DWORD dwAttr = SFGAO_CANRENAME;
	      pidl = (LPITEMIDLIST)lpdi->item.lParam;

1514
	      TRACE("-- LVN_BEGINLABELEDITW %p\n",This);
1515

1516
	      IShellFolder_GetAttributesOf(This->pSFParent, 1, (LPCITEMIDLIST*)&pidl, &dwAttr);
1517 1518 1519 1520 1521 1522 1523
	      if (SFGAO_CANRENAME & dwAttr)
	      {
	        return FALSE;
	      }
	      return TRUE;
	    }

1524
	  case LVN_ENDLABELEDITW:
1525 1526 1527 1528 1529
	    {
	      TRACE("-- LVN_ENDLABELEDITA %p\n",This);
	      if (lpdi->item.pszText)
	      {
	        HRESULT hr;
1530
		LVITEMW lvItem;
1531 1532

		lvItem.iItem = lpdi->item.iItem;
1533
		lvItem.iSubItem = 0;
1534
		lvItem.mask = LVIF_PARAM;
1535
		SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
1536

1537
		pidl = (LPITEMIDLIST)lpdi->item.lParam;
1538
	        hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, lpdi->item.pszText, SHGDN_INFOLDER, &pidl);
1539

1540 1541 1542 1543
		if(SUCCEEDED(hr) && pidl)
		{
	          lvItem.mask = LVIF_PARAM;
		  lvItem.lParam = (LPARAM)pidl;
1544
		  SendMessageW(This->hWndList, LVM_SETITEMW, 0, (LPARAM) &lvItem);
1545 1546 1547 1548 1549
		  return TRUE;
		}
	      }
	      return FALSE;
	    }
1550

1551 1552 1553
	  case LVN_KEYDOWN:
	    {
	      LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
1554 1555

              /* initiate a rename of the selected file or directory */
1556
              switch (plvKeyDown->wVKey)
1557
              {
1558
              case VK_F2:
1559
                {
1560
                  INT i = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0);
1561

1562 1563 1564 1565 1566 1567 1568 1569
                  if (i == 1)
                  {
                    /* get selected item */
                    i = SendMessageW(This->hWndList, LVM_GETNEXTITEM, -1, MAKELPARAM (LVNI_SELECTED, 0));

                    SendMessageW(This->hWndList, LVM_ENSUREVISIBLE, i, 0);
                    SendMessageW(This->hWndList, LVM_EDITLABELW, i, 0);
                  }
1570
                }
1571 1572 1573 1574 1575 1576 1577 1578 1579
                break;
              case VK_DELETE:
                {
		  UINT i, count;
		  int item_index;
		  LVITEMW item;
		  LPITEMIDLIST* pItems;
		  ISFHelper *psfhlp;
		  HRESULT hr;
1580

1581 1582
		  hr = IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, (void**)&psfhlp);
		  if (hr != S_OK) return 0;
1583

1584 1585 1586 1587 1588
		  if(!(count = SendMessageW(This->hWndList, LVM_GETSELECTEDCOUNT, 0, 0)))
		  {
		    ISFHelper_Release(psfhlp);
		    return 0;
		  }
1589

1590 1591
		  /* allocate memory for the pidl array */
		  pItems = HeapAlloc(GetProcessHeap(), 0, sizeof(LPITEMIDLIST) * count);
1592

1593 1594 1595
		  /* retrieve all selected items */
		  i = 0;
		  item_index = -1;
1596

1597 1598 1599 1600 1601 1602 1603 1604
		  while (count > i)
		  {
		    /* get selected item */
		    item_index = SendMessageW(This->hWndList, LVM_GETNEXTITEM, item_index,
                                              MAKELPARAM (LVNI_SELECTED, 0));
		    item.iItem = item_index;
		    item.mask = LVIF_PARAM;
		    SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM)&item);
1605

1606 1607
		    /* get item pidl */
		    pItems[i] = (LPITEMIDLIST)item.lParam;
1608

1609 1610
		    i++;
		  }
1611

1612 1613 1614
		  /* perform the item deletion */
		  ISFHelper_DeleteItems(psfhlp, i, (LPCITEMIDLIST*)pItems);
		  ISFHelper_Release(psfhlp);
1615

1616 1617 1618 1619
		  /* free pidl array memory */
		  HeapFree(GetProcessHeap(), 0, pItems);
                }
		break;
1620

1621 1622
	      case VK_F5:
                /* Initiate a refresh */
1623
		IShellView_Refresh((IShellView*)This);
1624
		break;
1625

1626
	      case VK_BACK:
1627
		{
1628 1629 1630 1631 1632 1633 1634
		  LPSHELLBROWSER lpSb;
		  if((lpSb = (LPSHELLBROWSER)SendMessageW(This->hWndParent, CWM_GETISHELLBROWSER, 0, 0)))
		  {
		    IShellBrowser_BrowseObject(lpSb, NULL, SBSP_PARENT);
		  }
	        }
		break;
1635

1636 1637 1638
	      default:
		FIXME("LVN_KEYDOWN key=0x%08x\n", plvKeyDown->wVKey);
	      }
1639 1640
	    }
	    break;
1641

Alexandre Julliard's avatar
Alexandre Julliard committed
1642
	  default:
1643
	    TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code);
1644
	    break;
Alexandre Julliard's avatar
Alexandre Julliard committed
1645 1646
	}
	return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
1647 1648
}

1649 1650 1651 1652
/**********************************************************
* ShellView_OnChange()
*/

1653
static LRESULT ShellView_OnChange(IShellViewImpl * This, const LPCITEMIDLIST *pidls, LONG event)
1654
{
1655
    BOOL ret = TRUE;
1656

1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676
    TRACE("(%p)->(%p, %p, 0x%08x)\n", This, pidls[0], pidls[1], event);

    switch (event)
    {
        case SHCNE_MKDIR:
        case SHCNE_CREATE:
            LV_AddItem(This, pidls[0]);
            break;
        case SHCNE_RMDIR:
        case SHCNE_DELETE:
        {
            INT i = LV_FindItemByPidl(This, ILFindLastID(pidls[0]));
            ret = SendMessageW(This->hWndList, LVM_DELETEITEM, i, 0);
            break;
        }
        case SHCNE_RENAMEFOLDER:
        case SHCNE_RENAMEITEM:
            LV_RenameItem(This, pidls[0], pidls[1]);
            break;
        case SHCNE_UPDATEITEM:
1677
	    break;
1678 1679
    }
    return ret;
1680
}
1681
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1682 1683 1684
*  ShellView_WndProc
*/

1685 1686
static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
1687
	IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
1688
	LPCREATESTRUCTW lpcs;
1689

1690
	TRACE("(hwnd=%p msg=%x wparm=%lx lparm=%lx)\n",hWnd, uMessage, wParam, lParam);
1691 1692 1693 1694

	switch (uMessage)
	{
	  case WM_NCCREATE:
1695
	    lpcs = (LPCREATESTRUCTW)lParam;
1696
            pThis = lpcs->lpCreateParams;
1697
	    SetWindowLongPtrW(hWnd, GWLP_USERDATA, (ULONG_PTR)pThis);
1698 1699 1700 1701 1702 1703 1704 1705 1706
	    pThis->hWnd = hWnd;        /*set the window handle*/
	    break;

	  case WM_SIZE:		return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam));
	  case WM_SETFOCUS:	return ShellView_OnSetFocus(pThis);
	  case WM_KILLFOCUS:	return ShellView_OnKillFocus(pThis);
	  case WM_CREATE:	return ShellView_OnCreate(pThis);
	  case WM_ACTIVATE:	return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS);
	  case WM_NOTIFY:	return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam);
1707 1708 1709
	  case WM_COMMAND:      return ShellView_OnCommand(pThis,
					GET_WM_COMMAND_ID(wParam, lParam),
					GET_WM_COMMAND_CMD(wParam, lParam),
1710
					GET_WM_COMMAND_HWND(wParam, lParam));
1711
	  case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (const LPCITEMIDLIST*)wParam, (LONG)lParam);
1712

1713 1714 1715
	  case WM_CONTEXTMENU:  ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE);
	                        return 0;

1716 1717 1718
	  case WM_SHOWWINDOW:	UpdateWindow(pThis->hWndList);
				break;

1719
	  case WM_GETDLGCODE:   return SendMessageW(pThis->hWndList, uMessage, 0, 0);
1720

1721 1722
	  case WM_DESTROY:	
	  			RevokeDragDrop(pThis->hWnd);
1723
				SHChangeNotifyDeregister(pThis->hNotify);
1724
	                        break;
1725 1726 1727 1728 1729 1730

	  case WM_ERASEBKGND:
	    if ((pThis->FolderSettings.fFlags & FWF_DESKTOP) ||
	        (pThis->FolderSettings.fFlags & FWF_TRANSPARENT))
	      return 1;
	    break;
1731 1732
	}

1733
	return DefWindowProcW(hWnd, uMessage, wParam, lParam);
Alexandre Julliard's avatar
Alexandre Julliard committed
1734
}
1735
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1736 1737 1738 1739 1740
*
*
*  The INTERFACE of the IShellView object
*
*
1741
**********************************************************
1742
*  IShellView_QueryInterface
Alexandre Julliard's avatar
Alexandre Julliard committed
1743
*/
1744
static HRESULT WINAPI IShellView_fnQueryInterface(IShellView2 *iface, REFIID riid, void **ppvObj)
1745
{
1746
	IShellViewImpl *This = impl_from_IShellView2(iface);
Alexandre Julliard's avatar
Alexandre Julliard committed
1747

1748
	TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1749 1750 1751

	*ppvObj = NULL;

1752 1753
	if(IsEqualIID(riid, &IID_IUnknown))
	{
1754
	  *ppvObj = This;
1755 1756 1757
	}
	else if(IsEqualIID(riid, &IID_IShellView))
	{
1758
          *ppvObj = This;
1759
	}
1760 1761
	else if(IsEqualIID(riid, &IID_IShellView2))
	{
1762
          *ppvObj = This;
1763
	}
1764 1765
	else if(IsEqualIID(riid, &IID_IShellFolderView))
	{
1766
          *ppvObj = &This->IShellFolderView_iface;
1767
	}
1768 1769
	else if(IsEqualIID(riid, &IID_IFolderView))
	{
1770
          *ppvObj = &This->IFolderView_iface;
1771
	}
1772 1773
	else if(IsEqualIID(riid, &IID_IOleCommandTarget))
	{
1774
          *ppvObj = &This->IOleCommandTarget_iface;
1775
	}
1776 1777
	else if(IsEqualIID(riid, &IID_IDropTarget))
	{
1778
          *ppvObj = &This->IDropTarget_iface;
1779
	}
1780 1781
	else if(IsEqualIID(riid, &IID_IDropSource))
	{
1782
          *ppvObj = &This->IDropSource_iface;
1783
	}
1784 1785
	else if(IsEqualIID(riid, &IID_IViewObject))
	{
1786
          *ppvObj = &This->IViewObject_iface;
1787 1788 1789
	}

	if(*ppvObj)
1790 1791
	{
	  IUnknown_AddRef( (IUnknown*)*ppvObj );
1792
	  TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1793 1794
	  return S_OK;
	}
1795
	TRACE("-- Interface: E_NOINTERFACE\n");
1796 1797
	return E_NOINTERFACE;
}
Alexandre Julliard's avatar
Alexandre Julliard committed
1798

1799
/**********************************************************
Juergen Schmied's avatar
Juergen Schmied committed
1800
*  IShellView_AddRef
Alexandre Julliard's avatar
Alexandre Julliard committed
1801
*/
1802
static ULONG WINAPI IShellView_fnAddRef(IShellView2 *iface)
1803
{
1804
	IShellViewImpl *This = impl_from_IShellView2(iface);
1805
	ULONG refCount = InterlockedIncrement(&This->ref);
1806

1807
	TRACE("(%p)->(count=%u)\n", This, refCount - 1);
1808

1809
	return refCount;
Alexandre Julliard's avatar
Alexandre Julliard committed
1810
}
1811
/**********************************************************
1812
*  IShellView_Release
Alexandre Julliard's avatar
Alexandre Julliard committed
1813
*/
1814
static ULONG WINAPI IShellView_fnRelease(IShellView2 *iface)
1815
{
1816
	IShellViewImpl *This = impl_from_IShellView2(iface);
1817
	ULONG refCount = InterlockedDecrement(&This->ref);
1818

1819
	TRACE("(%p)->(count=%i)\n", This, refCount + 1);
1820

1821
	if (!refCount)
1822 1823
	{
	  TRACE(" destroying IShellView(%p)\n",This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1824

1825 1826
	  DestroyWindow(This->hWndList);

1827 1828
	  if(This->pSFParent)
	    IShellFolder_Release(This->pSFParent);
Alexandre Julliard's avatar
Alexandre Julliard committed
1829

1830 1831 1832
	  if(This->pSF2Parent)
	    IShellFolder2_Release(This->pSF2Parent);

1833
	  SHFree(This->apidl);
1834

1835 1836 1837
	  if(This->pAdvSink)
	    IAdviseSink_Release(This->pAdvSink);

1838
	  HeapFree(GetProcessHeap(),0,This);
1839
	}
1840
	return refCount;
Alexandre Julliard's avatar
Alexandre Julliard committed
1841
}
1842 1843

/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1844
*  ShellView_GetWindow
Alexandre Julliard's avatar
Alexandre Julliard committed
1845
*/
1846
static HRESULT WINAPI IShellView_fnGetWindow(IShellView2 *iface, HWND *phWnd)
1847
{
1848
	IShellViewImpl *This = impl_from_IShellView2(iface);
1849

1850
	TRACE("(%p)\n",This);
1851 1852

	*phWnd = This->hWnd;
Alexandre Julliard's avatar
Alexandre Julliard committed
1853

Alexandre Julliard's avatar
Alexandre Julliard committed
1854
	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
1855
}
1856

1857
static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView2 *iface, BOOL mode)
1858
{
1859
    IShellViewImpl *This = impl_from_IShellView2(iface);
1860 1861
    TRACE("(%p)->(%d)\n", This, mode);
    return E_NOTIMPL;
Alexandre Julliard's avatar
Alexandre Julliard committed
1862
}
1863 1864

/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1865 1866 1867 1868 1869
* IShellView_TranslateAccelerator
*
* FIXME:
*  use the accel functions
*/
1870
static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView2 * iface,LPMSG lpmsg)
1871
{
1872
#if 0
1873
	IShellViewImpl *This = (IShellViewImpl *)iface;
1874

1875
	FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%x wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1876
#endif
1877

1878 1879
	if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST))
	{
1880
	  TRACE("-- key=0x04%lx\n",lpmsg->wParam) ;
1881
	}
1882
	return S_FALSE; /* not handled */
Alexandre Julliard's avatar
Alexandre Julliard committed
1883
}
1884

1885
static HRESULT WINAPI IShellView_fnEnableModeless(IShellView2 *iface, BOOL fEnable)
1886
{
1887
	IShellViewImpl *This = impl_from_IShellView2(iface);
1888

1889
	FIXME("(%p) stub\n",This);
1890 1891

	return E_NOTIMPL;
Alexandre Julliard's avatar
Alexandre Julliard committed
1892
}
1893

1894
static HRESULT WINAPI IShellView_fnUIActivate(IShellView2 *iface, UINT uState)
1895
{
1896
	IShellViewImpl *This = impl_from_IShellView2(iface);
1897

1898
/*
1899
	CHAR	szName[MAX_PATH];
1900
*/
Alexandre Julliard's avatar
Alexandre Julliard committed
1901
	LRESULT	lResult;
1902
	int	nPartArray[1] = {-1};
Alexandre Julliard's avatar
Alexandre Julliard committed
1903

1904
	TRACE("(%p)->(state=%x) stub\n",This, uState);
1905

Alexandre Julliard's avatar
Alexandre Julliard committed
1906
	/*don't do anything if the state isn't really changing*/
1907
	if(This->uState == uState)
1908 1909
	{
	  return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
1910
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
1911

Alexandre Julliard's avatar
Alexandre Julliard committed
1912
	/*OnActivate handles the menu merging and internal state*/
1913
	ShellView_OnActivate(This, uState);
Alexandre Julliard's avatar
Alexandre Julliard committed
1914

1915
	/*only do This if we are active*/
Alexandre Julliard's avatar
Alexandre Julliard committed
1916
	if(uState != SVUIA_DEACTIVATE)
1917
	{
1918

1919 1920
/*
	  GetFolderPath is not a method of IShellFolder
1921
	  IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1922
*/
Alexandre Julliard's avatar
Alexandre Julliard committed
1923
	  /* set the number of parts */
1924
	  IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1925
	  						(LPARAM)nPartArray, &lResult);
Alexandre Julliard's avatar
Alexandre Julliard committed
1926 1927

	  /* set the text for the parts */
1928
/*
1929
	  IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1930
							0, (LPARAM)szName, &lResult);
1931
*/
Alexandre Julliard's avatar
Alexandre Julliard committed
1932
	}
1933

Alexandre Julliard's avatar
Alexandre Julliard committed
1934 1935
	return S_OK;
}
1936

1937
static HRESULT WINAPI IShellView_fnRefresh(IShellView2 *iface)
1938
{
1939
	IShellViewImpl *This = impl_from_IShellView2(iface);
Alexandre Julliard's avatar
Alexandre Julliard committed
1940

1941
	TRACE("(%p)\n", This);
1942

1943
	SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0);
1944
	ShellView_FillList(This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1945

Alexandre Julliard's avatar
Alexandre Julliard committed
1946 1947
	return S_OK;
}
1948

1949 1950
static HRESULT WINAPI IShellView_fnCreateViewWindow(IShellView2 *iface, IShellView *lpPrevView,
        LPCFOLDERSETTINGS lpfs, IShellBrowser *psb, RECT *prcView, HWND *phWnd)
1951
{
1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967
    HRESULT hr;
    SV2CVW2_PARAMS view_params;
    view_params.cbSize = sizeof(view_params);
    view_params.psvPrev = lpPrevView;
    view_params.pfs = lpfs;
    view_params.psbOwner = psb;
    view_params.prcView = prcView;
    view_params.pvid = NULL;
    view_params.hwndView = 0;

    TRACE("(%p) Forwarding to CreateViewWindow2\n", iface);

    hr = IShellView2_CreateViewWindow2(iface, &view_params);
    *phWnd = view_params.hwndView;

    return hr;
Alexandre Julliard's avatar
Alexandre Julliard committed
1968 1969
}

1970
static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView2 *iface)
1971
{
1972
	IShellViewImpl *This = impl_from_IShellView2(iface);
1973

1974
	TRACE("(%p)\n",This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1975 1976

	/*Make absolutely sure all our UI is cleaned up.*/
1977
	IShellView_UIActivate((IShellView*)This, SVUIA_DEACTIVATE);
1978

1979
	if(This->hMenu)
1980 1981
	{
	  DestroyMenu(This->hMenu);
Alexandre Julliard's avatar
Alexandre Julliard committed
1982
	}
1983

1984
	DestroyWindow(This->hWnd);
1985 1986 1987
	if(This->pShellBrowser) IShellBrowser_Release(This->pShellBrowser);
	if(This->pCommDlgBrowser) ICommDlgBrowser_Release(This->pCommDlgBrowser);

1988

Alexandre Julliard's avatar
Alexandre Julliard committed
1989 1990
	return S_OK;
}
1991

1992
static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView2 *iface, LPFOLDERSETTINGS lpfs)
1993
{
1994
	IShellViewImpl *This = impl_from_IShellView2(iface);
1995

1996
	TRACE("(%p)->(%p) vmode=%x flags=%x\n",This, lpfs,
1997 1998
		This->FolderSettings.ViewMode, This->FolderSettings.fFlags);

1999 2000 2001
	if (!lpfs) return E_INVALIDARG;

	*lpfs = This->FolderSettings;
2002
	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
2003
}
2004

2005 2006
static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView2 *iface, DWORD dwReserved,
		LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
2007
{
2008
	IShellViewImpl *This = impl_from_IShellView2(iface);
2009

2010
	FIXME("(%p) stub\n",This);
2011 2012

	return E_NOTIMPL;
Alexandre Julliard's avatar
Alexandre Julliard committed
2013
}
2014

2015
static HRESULT WINAPI IShellView_fnSaveViewState(IShellView2 *iface)
2016
{
2017
	IShellViewImpl *This = impl_from_IShellView2(iface);
2018

2019
	FIXME("(%p) stub\n",This);
2020 2021

	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
2022
}
2023

2024
static HRESULT WINAPI IShellView_fnSelectItem(IShellView2 *iface, LPCITEMIDLIST pidl, UINT flags)
2025
{
2026
    IShellViewImpl *This = impl_from_IShellView2(iface);
2027
    IFolderView *view = &This->IFolderView_iface;
2028
    int i;
2029

2030
    TRACE("(%p)->(pidl=%p, 0x%08x)\n",This, pidl, flags);
2031

2032 2033
    i = LV_FindItemByPidl(This, pidl);
    if (i == -1) return S_OK;
2034

2035
    return IFolderView_SelectItem(view, i, flags);
Alexandre Julliard's avatar
Alexandre Julliard committed
2036
}
2037

2038 2039
static HRESULT WINAPI IShellView_fnGetItemObject(IShellView2 *iface, UINT uItem, REFIID riid,
        void **ppvOut)
2040
{
2041
    IShellViewImpl *This = impl_from_IShellView2(iface);
2042
    HRESULT hr = E_NOINTERFACE;
2043

2044
    TRACE("(%p)->(0x%08x, %s, %p)\n",This, uItem, debugstr_guid(riid), ppvOut);
Alexandre Julliard's avatar
Alexandre Julliard committed
2045

2046
    *ppvOut = NULL;
2047

2048 2049 2050
    switch(uItem)
    {
    case SVGIO_BACKGROUND:
2051

2052
        if (IsEqualIID(&IID_IContextMenu, riid))
2053
            return BackgroundMenu_Constructor(This->pSFParent, FALSE, riid, ppvOut);
2054 2055
        else
            FIXME("unsupported interface requested %s\n", debugstr_guid(riid));
Alexandre Julliard's avatar
Alexandre Julliard committed
2056

2057
        break;
2058

2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069
    case SVGIO_SELECTION:
	ShellView_GetSelections(This);
	hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, (LPCITEMIDLIST*)This->apidl, riid, 0, ppvOut);
	break;

    default:
        FIXME("unimplemented for uItem = 0x%08x\n", uItem);
    }
    TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);

    return hr;
Alexandre Julliard's avatar
Alexandre Julliard committed
2070
}
2071

2072 2073 2074 2075 2076 2077
static HRESULT WINAPI IShellView2_fnGetView(IShellView2* iface, SHELLVIEWID *view_guid, ULONG view_type)
{
    FIXME("(%p)->(view_guid %s, view_type %#x) stub!\n", iface, debugstr_guid(view_guid), view_type);
    return E_NOTIMPL;
}

2078 2079
static HRESULT WINAPI IShellView2_fnCreateViewWindow2(IShellView2 *iface,
        LPSV2CVW2_PARAMS view_params)
2080
{
2081
    IShellViewImpl *This = impl_from_IShellView2(iface);
2082
    WNDCLASSW wc;
2083
    HRESULT hr;
2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095
    HWND wnd;

    TRACE("(%p)->(view_params %p)\n", iface, view_params);

    if (view_params->cbSize != sizeof(*view_params))
    {
        FIXME("Got unexpected cbSize %#x\n", view_params->cbSize);
        return E_FAIL;
    }

    TRACE("-- psvPrev %p, pfs %p, psbOwner %p, prcView %p\n",
            view_params->psvPrev, view_params->pfs, view_params->psbOwner, view_params->prcView);
2096
    TRACE("-- vmode %#x, flags %#x, view %s\n", view_params->pfs->ViewMode, view_params->pfs->fFlags, wine_dbgstr_rect(view_params->prcView));
2097

2098 2099
    if (!view_params->psbOwner) return E_UNEXPECTED;

2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125
    /* Set up the member variables */
    This->pShellBrowser = view_params->psbOwner;
    This->FolderSettings = *view_params->pfs;

    if (view_params->pvid)
    {
        if (IsEqualGUID(view_params->pvid, &VID_LargeIcons))
            This->FolderSettings.ViewMode = FVM_ICON;
        else if (IsEqualGUID(view_params->pvid, &VID_SmallIcons))
            This->FolderSettings.ViewMode = FVM_SMALLICON;
        else if (IsEqualGUID(view_params->pvid, &VID_List))
            This->FolderSettings.ViewMode = FVM_LIST;
        else if (IsEqualGUID(view_params->pvid, &VID_Details))
            This->FolderSettings.ViewMode = FVM_DETAILS;
        else if (IsEqualGUID(view_params->pvid, &VID_Thumbnails))
            This->FolderSettings.ViewMode = FVM_THUMBNAIL;
        else if (IsEqualGUID(view_params->pvid, &VID_Tile))
            This->FolderSettings.ViewMode = FVM_TILE;
        else if (IsEqualGUID(view_params->pvid, &VID_ThumbStrip))
            This->FolderSettings.ViewMode = FVM_THUMBSTRIP;
        else
            FIXME("Ignoring unrecognized VID %s\n", debugstr_guid(view_params->pvid));
    }

    /* Get our parent window */
    IShellBrowser_AddRef(This->pShellBrowser);
2126
    IShellBrowser_GetWindow(This->pShellBrowser, &This->hWndParent);
2127 2128 2129

    /* Try to get the ICommDlgBrowserInterface, adds a reference !!! */
    This->pCommDlgBrowser = NULL;
2130 2131
    hr = IShellBrowser_QueryInterface(This->pShellBrowser, &IID_ICommDlgBrowser, (void **)&This->pCommDlgBrowser);
    if (hr == S_OK)
2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150
        TRACE("-- CommDlgBrowser %p\n", This->pCommDlgBrowser);

    /* If our window class has not been registered, then do so */
    if (!GetClassInfoW(shell32_hInstance, SV_CLASS_NAME, &wc))
    {
        wc.style            = CS_HREDRAW | CS_VREDRAW;
        wc.lpfnWndProc      = ShellView_WndProc;
        wc.cbClsExtra       = 0;
        wc.cbWndExtra       = 0;
        wc.hInstance        = shell32_hInstance;
        wc.hIcon            = 0;
        wc.hCursor          = LoadCursorW(0, (LPWSTR)IDC_ARROW);
        wc.hbrBackground    = (HBRUSH)(COLOR_WINDOW + 1);
        wc.lpszMenuName     = NULL;
        wc.lpszClassName    = SV_CLASS_NAME;

        if (!RegisterClassW(&wc)) return E_FAIL;
    }

2151 2152
    wnd = CreateWindowExW(0, SV_CLASS_NAME, NULL, WS_CHILD | WS_TABSTOP,
            view_params->prcView->left, view_params->prcView->top,
2153 2154
            view_params->prcView->right - view_params->prcView->left,
            view_params->prcView->bottom - view_params->prcView->top,
2155
            This->hWndParent, 0, shell32_hInstance, This);
2156 2157 2158

    CheckToolbar(This);

2159 2160 2161 2162 2163
    if (!wnd)
    {
        IShellBrowser_Release(This->pShellBrowser);
        return E_FAIL;
    }
2164 2165 2166 2167 2168 2169 2170

    SetWindowPos(wnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
    UpdateWindow(wnd);

    view_params->hwndView = wnd;

    return S_OK;
2171 2172 2173 2174 2175 2176 2177 2178
}

static HRESULT WINAPI IShellView2_fnHandleRename(IShellView2* iface, LPCITEMIDLIST new_pidl)
{
    FIXME("(%p)->(new_pidl %p) stub!\n", iface, new_pidl);
    return E_NOTIMPL;
}

2179 2180
static HRESULT WINAPI IShellView2_fnSelectAndPositionItem(IShellView2 *iface, LPCITEMIDLIST item,
        UINT flags, POINT *point)
2181
{
2182
    IShellViewImpl *This = impl_from_IShellView2(iface);
2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195
    IFolderView *view;
    HRESULT hr;

    TRACE("(%p)->(item %p, flags %#x, point %p)\n", This, item, flags, point);

    hr = IShellView2_QueryInterface(iface, &IID_IFolderView, (void**)&view);
    if (hr == S_OK)
    {
        hr = IFolderView_SelectAndPositionItems(view, 1, &item, point, flags);
        IFolderView_Release(view);
    }

    return hr;
2196 2197 2198
}

static const IShellView2Vtbl svvt =
2199
{
2200
	IShellView_fnQueryInterface,
2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214
	IShellView_fnAddRef,
	IShellView_fnRelease,
	IShellView_fnGetWindow,
	IShellView_fnContextSensitiveHelp,
	IShellView_fnTranslateAccelerator,
	IShellView_fnEnableModeless,
	IShellView_fnUIActivate,
	IShellView_fnRefresh,
	IShellView_fnCreateViewWindow,
	IShellView_fnDestroyViewWindow,
	IShellView_fnGetCurrentInfo,
	IShellView_fnAddPropertySheetPages,
	IShellView_fnSaveViewState,
	IShellView_fnSelectItem,
2215 2216 2217 2218 2219
	IShellView_fnGetItemObject,
	IShellView2_fnGetView,
	IShellView2_fnCreateViewWindow2,
	IShellView2_fnHandleRename,
	IShellView2_fnSelectAndPositionItem,
2220 2221
};

2222

2223
/**********************************************************
2224 2225 2226 2227 2228 2229 2230
 * ISVOleCmdTarget_QueryInterface (IUnknown)
 */
static HRESULT WINAPI ISVOleCmdTarget_QueryInterface(
	IOleCommandTarget *	iface,
	REFIID			iid,
	LPVOID*			ppvObj)
{
2231
	IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2232

2233
	return IShellView2_QueryInterface(&This->IShellView2_iface, iid, ppvObj);
2234 2235
}

2236
/**********************************************************
2237 2238 2239 2240 2241
 * ISVOleCmdTarget_AddRef (IUnknown)
 */
static ULONG WINAPI ISVOleCmdTarget_AddRef(
	IOleCommandTarget *	iface)
{
2242
	IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2243

2244
	return IShellView2_AddRef(&This->IShellView2_iface);
2245 2246
}

2247
/**********************************************************
2248 2249 2250 2251 2252
 * ISVOleCmdTarget_Release (IUnknown)
 */
static ULONG WINAPI ISVOleCmdTarget_Release(
	IOleCommandTarget *	iface)
{
2253
	IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2254

2255
	return IShellView2_Release(&This->IShellView2_iface);
2256 2257
}

2258
/**********************************************************
Juergen Schmied's avatar
Juergen Schmied committed
2259
 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
2260 2261 2262
 */
static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
	IOleCommandTarget *iface,
2263
	const GUID *pguidCmdGroup,
2264
	ULONG cCmds,
2265 2266
	OLECMD *prgCmds,
	OLECMDTEXT *pCmdText)
2267
{
2268
    IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2269
    UINT i;
2270

2271 2272
    FIXME("(%p)->(%s %d %p %p)\n",
              This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
2273 2274

    if (!prgCmds)
2275
        return E_INVALIDARG;
2276 2277
    for (i = 0; i < cCmds; i++)
    {
2278
        FIXME("\tprgCmds[%d].cmdID = %d\n", i, prgCmds[i].cmdID);
2279 2280 2281
        prgCmds[i].cmdf = 0;
    }
    return OLECMDERR_E_UNKNOWNGROUP;
2282 2283
}

2284
/**********************************************************
2285
 * ISVOleCmdTarget_Exec (IOleCommandTarget)
Juergen Schmied's avatar
Juergen Schmied committed
2286 2287
 *
 * nCmdID is the OLECMDID_* enumeration
2288 2289 2290 2291 2292 2293 2294 2295 2296
 */
static HRESULT WINAPI ISVOleCmdTarget_Exec(
	IOleCommandTarget *iface,
	const GUID* pguidCmdGroup,
	DWORD nCmdID,
	DWORD nCmdexecopt,
	VARIANT* pvaIn,
	VARIANT* pvaOut)
{
2297
	IShellViewImpl *This = impl_from_IOleCommandTarget(iface);
2298

2299
	FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08x Opt:0x%08x %p %p)\n",
2300
              This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, pvaIn, pvaOut);
2301

2302 2303
	if (!pguidCmdGroup)
	    return OLECMDERR_E_UNKNOWNGROUP;
2304 2305 2306 2307 2308 2309 2310 2311 2312 2313
	if (IsEqualIID(pguidCmdGroup, &CGID_Explorer) &&
	   (nCmdID == 0x29) &&
	   (nCmdexecopt == 4) && pvaOut)
	   return S_OK;
	if (IsEqualIID(pguidCmdGroup, &CGID_ShellDocView) &&
	   (nCmdID == 9) &&
	   (nCmdexecopt == 0))
	   return 1;

	return OLECMDERR_E_UNKNOWNGROUP;
2314 2315
}

2316
static const IOleCommandTargetVtbl ctvt =
2317 2318 2319 2320 2321 2322 2323 2324
{
	ISVOleCmdTarget_QueryInterface,
	ISVOleCmdTarget_AddRef,
	ISVOleCmdTarget_Release,
	ISVOleCmdTarget_QueryStatus,
	ISVOleCmdTarget_Exec
};

2325
/**********************************************************
2326 2327 2328 2329 2330 2331 2332 2333
 * ISVDropTarget implementation
 */

static HRESULT WINAPI ISVDropTarget_QueryInterface(
	IDropTarget *iface,
	REFIID riid,
	LPVOID *ppvObj)
{
2334
	IShellViewImpl *This = impl_from_IDropTarget(iface);
2335

2336
	TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2337

2338
	return IShellView2_QueryInterface(&This->IShellView2_iface, riid, ppvObj);
2339 2340 2341 2342
}

static ULONG WINAPI ISVDropTarget_AddRef( IDropTarget *iface)
{
2343
	IShellViewImpl *This = impl_from_IDropTarget(iface);
2344

2345
	TRACE("(%p)->(count=%u)\n",This,This->ref);
2346

2347
	return IShellView2_AddRef(&This->IShellView2_iface);
2348 2349 2350 2351
}

static ULONG WINAPI ISVDropTarget_Release( IDropTarget *iface)
{
2352
	IShellViewImpl *This = impl_from_IDropTarget(iface);
2353

2354
	TRACE("(%p)->(count=%u)\n",This,This->ref);
2355

2356
	return IShellView2_Release(&This->IShellView2_iface);
2357 2358
}

2359 2360 2361 2362 2363 2364
/******************************************************************************
 * drag_notify_subitem [Internal]
 *
 * Figure out the shellfolder object, which is currently under the mouse cursor
 * and notify it via the IDropTarget interface.
 */
2365 2366 2367

#define SCROLLAREAWIDTH 20

2368 2369 2370 2371
static HRESULT drag_notify_subitem(IShellViewImpl *This, DWORD grfKeyState, POINTL pt,
    DWORD *pdwEffect)
{
    LVHITTESTINFO htinfo;
2372
    LVITEMW lvItem;
2373 2374
    LONG lResult;
    HRESULT hr;
2375
    RECT clientRect;
2376 2377 2378 2379 2380 2381

    /* Map from global to client coordinates and query the index of the listview-item, which is 
     * currently under the mouse cursor. */
    htinfo.pt.x = pt.x;
    htinfo.pt.y = pt.y;
    htinfo.flags = LVHT_ONITEM;
2382
    ScreenToClient(This->hWndList, &htinfo.pt);
2383 2384
    lResult = SendMessageW(This->hWndList, LVM_HITTEST, 0, (LPARAM)&htinfo);

2385
    /* Send WM_*SCROLL messages every 250 ms during drag-scrolling */
2386
    GetClientRect(This->hWndList, &clientRect);
2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406
    if (htinfo.pt.x == This->ptLastMousePos.x && htinfo.pt.y == This->ptLastMousePos.y &&
        (htinfo.pt.x < SCROLLAREAWIDTH || htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH ||
         htinfo.pt.y < SCROLLAREAWIDTH || htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH ))
    {
        This->cScrollDelay = (This->cScrollDelay + 1) % 5; /* DragOver is called every 50 ms */
        if (This->cScrollDelay == 0) { /* Mouse did hover another 250 ms over the scroll-area */
            if (htinfo.pt.x < SCROLLAREAWIDTH) 
                SendMessageW(This->hWndList, WM_HSCROLL, SB_LINEUP, 0);
            if (htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH)
                SendMessageW(This->hWndList, WM_HSCROLL, SB_LINEDOWN, 0);
            if (htinfo.pt.y < SCROLLAREAWIDTH)
                SendMessageW(This->hWndList, WM_VSCROLL, SB_LINEUP, 0);
            if (htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH)
                SendMessageW(This->hWndList, WM_VSCROLL, SB_LINEDOWN, 0);
        }
    } else {
        This->cScrollDelay = 0; /* Reset, if the cursor is not over the listview's scroll-area */
    }
    This->ptLastMousePos = htinfo.pt;
 
2407 2408 2409 2410 2411 2412 2413 2414 2415 2416
    /* If we are still over the previous sub-item, notify it via DragOver and return. */
    if (This->pCurDropTarget && lResult == This->iDragOverItem)
    return IDropTarget_DragOver(This->pCurDropTarget, grfKeyState, pt, pdwEffect);
  
    /* We've left the previous sub-item, notify it via DragLeave and Release it. */
    if (This->pCurDropTarget) {
        IDropTarget_DragLeave(This->pCurDropTarget);
        IDropTarget_Release(This->pCurDropTarget);
        This->pCurDropTarget = NULL;
    }
2417

2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428
    This->iDragOverItem = lResult;
    if (lResult == -1) {
        /* We are not above one of the listview's subitems. Bind to the parent folder's
         * DropTarget interface. */
        hr = IShellFolder_QueryInterface(This->pSFParent, &IID_IDropTarget, 
                                         (LPVOID*)&This->pCurDropTarget);
    } else {
        /* Query the relative PIDL of the shellfolder object represented by the currently
         * dragged over listview-item ... */
        lvItem.mask = LVIF_PARAM;
        lvItem.iItem = lResult;
2429
        lvItem.iSubItem = 0;
2430
        SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM) &lvItem);
2431

2432 2433 2434
        /* ... and bind pCurDropTarget to the IDropTarget interface of an UIObject of this object */
        hr = IShellFolder_GetUIObjectOf(This->pSFParent, This->hWndList, 1,
            (LPCITEMIDLIST*)&lvItem.lParam, &IID_IDropTarget, NULL, (LPVOID*)&This->pCurDropTarget);
2435
    }
2436

2437 2438 2439
    /* If anything failed, pCurDropTarget should be NULL now, which ought to be a save state. */
    if (FAILED(hr)) 
        return hr;
2440

2441 2442
    /* Notify the item just entered via DragEnter. */
    return IDropTarget_DragEnter(This->pCurDropTarget, This->pCurDataObject, grfKeyState, pt, pdwEffect);
2443 2444
}

2445 2446
static HRESULT WINAPI ISVDropTarget_DragEnter(IDropTarget *iface, IDataObject *pDataObject,
    DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2447
{
2448
    IShellViewImpl *This = impl_from_IDropTarget(iface);
2449

2450 2451 2452
    /* Get a hold on the data object for later calls to DragEnter on the sub-folders */
    This->pCurDataObject = pDataObject;
    IDataObject_AddRef(pDataObject);
2453

2454
    return drag_notify_subitem(This, grfKeyState, pt, pdwEffect);
2455 2456
}

2457 2458
static HRESULT WINAPI ISVDropTarget_DragOver(IDropTarget *iface, DWORD grfKeyState, POINTL pt,
    DWORD *pdwEffect)
2459
{
2460 2461 2462
    IShellViewImpl *This = impl_from_IDropTarget(iface);
    return drag_notify_subitem(This, grfKeyState, pt, pdwEffect);
}
2463

2464 2465
static HRESULT WINAPI ISVDropTarget_DragLeave(IDropTarget *iface)
{
2466
    IShellViewImpl *This = impl_from_IDropTarget(iface);
2467

2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479
    if (This->pCurDropTarget)
    {
        IDropTarget_DragLeave(This->pCurDropTarget);
        IDropTarget_Release(This->pCurDropTarget);
        This->pCurDropTarget = NULL;
    }

    if (This->pCurDataObject)
    {
        IDataObject_Release(This->pCurDataObject);
        This->pCurDataObject = NULL;
    }
2480 2481

    This->iDragOverItem = 0;
2482

2483
    return S_OK;
2484 2485
}

2486 2487
static HRESULT WINAPI ISVDropTarget_Drop(IDropTarget *iface, IDataObject* pDataObject, 
    DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
2488
{
2489
    IShellViewImpl *This = impl_from_IDropTarget(iface);
2490

2491
    IDropTarget_Drop(This->pCurDropTarget, pDataObject, grfKeyState, pt, pdwEffect);
2492

2493 2494 2495 2496 2497 2498 2499
    IDropTarget_Release(This->pCurDropTarget);
    IDataObject_Release(This->pCurDataObject);
    This->pCurDataObject = NULL;
    This->pCurDropTarget = NULL;
    This->iDragOverItem = 0;

    return S_OK;
2500 2501
}

2502
static const IDropTargetVtbl dtvt =
2503 2504 2505 2506 2507 2508 2509 2510 2511 2512
{
	ISVDropTarget_QueryInterface,
	ISVDropTarget_AddRef,
	ISVDropTarget_Release,
	ISVDropTarget_DragEnter,
	ISVDropTarget_DragOver,
	ISVDropTarget_DragLeave,
	ISVDropTarget_Drop
};

2513 2514 2515 2516 2517 2518 2519 2520 2521
/**********************************************************
 * ISVDropSource implementation
 */

static HRESULT WINAPI ISVDropSource_QueryInterface(
	IDropSource *iface,
	REFIID riid,
	LPVOID *ppvObj)
{
2522
	IShellViewImpl *This = impl_from_IDropSource(iface);
2523

2524
	TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2525

2526
	return IShellView2_QueryInterface(&This->IShellView2_iface, riid, ppvObj);
2527 2528 2529 2530
}

static ULONG WINAPI ISVDropSource_AddRef( IDropSource *iface)
{
2531
	IShellViewImpl *This = impl_from_IDropSource(iface);
2532

2533
	TRACE("(%p)->(count=%u)\n",This,This->ref);
2534

2535
	return IShellView2_AddRef(&This->IShellView2_iface);
2536 2537 2538 2539
}

static ULONG WINAPI ISVDropSource_Release( IDropSource *iface)
{
2540
	IShellViewImpl *This = impl_from_IDropSource(iface);
2541

2542
	TRACE("(%p)->(count=%u)\n",This,This->ref);
2543

2544
	return IShellView2_Release(&This->IShellView2_iface);
2545
}
2546

2547 2548 2549 2550 2551
static HRESULT WINAPI ISVDropSource_QueryContinueDrag(
	IDropSource *iface,
	BOOL fEscapePressed,
	DWORD grfKeyState)
{
2552
	IShellViewImpl *This = impl_from_IDropSource(iface);
2553 2554 2555 2556 2557 2558 2559
	TRACE("(%p)\n",This);

	if (fEscapePressed)
	  return DRAGDROP_S_CANCEL;
	else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
	  return DRAGDROP_S_DROP;
	else
2560
	  return S_OK;
2561 2562 2563 2564 2565 2566
}

static HRESULT WINAPI ISVDropSource_GiveFeedback(
	IDropSource *iface,
	DWORD dwEffect)
{
2567
	IShellViewImpl *This = impl_from_IDropSource(iface);
2568 2569 2570 2571 2572
	TRACE("(%p)\n",This);

	return DRAGDROP_S_USEDEFAULTCURSORS;
}

2573
static const IDropSourceVtbl dsvt =
2574 2575 2576 2577 2578 2579 2580
{
	ISVDropSource_QueryInterface,
	ISVDropSource_AddRef,
	ISVDropSource_Release,
	ISVDropSource_QueryContinueDrag,
	ISVDropSource_GiveFeedback
};
2581
/**********************************************************
2582 2583 2584 2585 2586 2587 2588 2589
 * ISVViewObject implementation
 */

static HRESULT WINAPI ISVViewObject_QueryInterface(
	IViewObject *iface,
	REFIID riid,
	LPVOID *ppvObj)
{
2590
	IShellViewImpl *This = impl_from_IViewObject(iface);
2591

2592
	TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2593

2594
	return IShellView2_QueryInterface(&This->IShellView2_iface, riid, ppvObj);
2595 2596 2597 2598
}

static ULONG WINAPI ISVViewObject_AddRef( IViewObject *iface)
{
2599
	IShellViewImpl *This = impl_from_IViewObject(iface);
2600

2601
	TRACE("(%p)->(count=%u)\n",This,This->ref);
2602

2603
	return IShellView2_AddRef(&This->IShellView2_iface);
2604 2605 2606 2607
}

static ULONG WINAPI ISVViewObject_Release( IViewObject *iface)
{
2608
	IShellViewImpl *This = impl_from_IViewObject(iface);
2609

2610
	TRACE("(%p)->(count=%u)\n",This,This->ref);
2611

2612
	return IShellView2_Release(&This->IShellView2_iface);
2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623
}

static HRESULT WINAPI ISVViewObject_Draw(
	IViewObject 	*iface,
	DWORD dwDrawAspect,
	LONG lindex,
	void* pvAspect,
	DVTARGETDEVICE* ptd,
	HDC hdcTargetDev,
	HDC hdcDraw,
	LPCRECTL lprcBounds,
2624
	LPCRECTL lprcWBounds,
2625
	BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue),
2626
	ULONG_PTR dwContinue)
2627
{
2628

2629
	IShellViewImpl *This = impl_from_IViewObject(iface);
2630

2631
	FIXME("Stub: This=%p\n",This);
2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642

	return E_NOTIMPL;
}
static HRESULT WINAPI ISVViewObject_GetColorSet(
	IViewObject 	*iface,
	DWORD dwDrawAspect,
	LONG lindex,
	void *pvAspect,
	DVTARGETDEVICE* ptd,
	HDC hicTargetDevice,
	LOGPALETTE** ppColorSet)
2643
{
2644

2645
	IShellViewImpl *This = impl_from_IViewObject(iface);
2646

2647
	FIXME("Stub: This=%p\n",This);
2648 2649 2650 2651 2652 2653 2654 2655 2656

	return E_NOTIMPL;
}
static HRESULT WINAPI ISVViewObject_Freeze(
	IViewObject 	*iface,
	DWORD dwDrawAspect,
	LONG lindex,
	void* pvAspect,
	DWORD* pdwFreeze)
2657
{
2658

2659
	IShellViewImpl *This = impl_from_IViewObject(iface);
2660

2661
	FIXME("Stub: This=%p\n",This);
2662 2663 2664 2665 2666 2667

	return E_NOTIMPL;
}
static HRESULT WINAPI ISVViewObject_Unfreeze(
	IViewObject 	*iface,
	DWORD dwFreeze)
2668
{
2669

2670
	IShellViewImpl *This = impl_from_IViewObject(iface);
2671

2672
	FIXME("Stub: This=%p\n",This);
2673 2674 2675 2676 2677 2678 2679 2680

	return E_NOTIMPL;
}
static HRESULT WINAPI ISVViewObject_SetAdvise(
	IViewObject 	*iface,
	DWORD aspects,
	DWORD advf,
	IAdviseSink* pAdvSink)
2681
{
2682

2683
	IShellViewImpl *This = impl_from_IViewObject(iface);
2684

2685
	FIXME("partial stub: %p %08x %08x %p\n",
2686
              This, aspects, advf, pAdvSink);
2687

2688 2689 2690 2691 2692 2693
	/* FIXME: we set the AdviseSink, but never use it to send any advice */
	This->pAdvSink = pAdvSink;
	This->dwAspects = aspects;
	This->dwAdvf = advf;

	return S_OK;
2694
}
2695

2696 2697 2698 2699 2700
static HRESULT WINAPI ISVViewObject_GetAdvise(
	IViewObject 	*iface,
	DWORD* pAspects,
	DWORD* pAdvf,
	IAdviseSink** ppAdvSink)
2701
{
2702

2703
	IShellViewImpl *This = impl_from_IViewObject(iface);
2704

2705 2706
	TRACE("This=%p pAspects=%p pAdvf=%p ppAdvSink=%p\n",
              This, pAspects, pAdvf, ppAdvSink);
2707

2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718
	if( ppAdvSink )
	{
		IAdviseSink_AddRef( This->pAdvSink );
		*ppAdvSink = This->pAdvSink;
	}
	if( pAspects )
		*pAspects = This->dwAspects;
	if( pAdvf )
		*pAdvf = This->dwAdvf;

	return S_OK;
2719 2720 2721
}


2722
static const IViewObjectVtbl vovt =
2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733
{
	ISVViewObject_QueryInterface,
	ISVViewObject_AddRef,
	ISVViewObject_Release,
	ISVViewObject_Draw,
	ISVViewObject_GetColorSet,
	ISVViewObject_Freeze,
	ISVViewObject_Unfreeze,
	ISVViewObject_SetAdvise,
	ISVViewObject_GetAdvise
};
2734 2735 2736 2737 2738 2739 2740 2741 2742

/* IFolderView */
static HRESULT WINAPI IFView_QueryInterface(
	IFolderView *iface,
	REFIID riid,
	LPVOID *ppvObj)
{
	IShellViewImpl *This = impl_from_IFolderView(iface);
	TRACE("(%p)->(IID:%s,%p)\n", This, debugstr_guid(riid), ppvObj);
2743
	return IShellView2_QueryInterface(&This->IShellView2_iface, riid, ppvObj);
2744 2745 2746 2747 2748 2749
}

static ULONG WINAPI IFView_AddRef( IFolderView *iface)
{
	IShellViewImpl *This = impl_from_IFolderView(iface);
	TRACE("(%p)->(count=%u)\n", This, This->ref);
2750
	return IShellView2_AddRef(&This->IShellView2_iface);
2751 2752 2753 2754 2755 2756
}

static ULONG WINAPI IFView_Release( IFolderView *iface)
{
	IShellViewImpl *This = impl_from_IFolderView(iface);
	TRACE("(%p)->(count=%u)\n", This, This->ref);
2757
	return IShellView2_Release(&This->IShellView2_iface);
2758 2759 2760 2761
}

static HRESULT WINAPI IFView_GetCurrentViewMode(IFolderView *iface, UINT *mode)
{
2762 2763 2764 2765 2766 2767 2768 2769
    IShellViewImpl *This = impl_from_IFolderView(iface);
    TRACE("(%p)->(%p), stub\n", This, mode);

    if(!mode)
        return E_INVALIDARG;

    *mode = This->FolderSettings.ViewMode;
    return S_OK;
2770 2771 2772 2773
}

static HRESULT WINAPI IFView_SetCurrentViewMode(IFolderView *iface, UINT mode)
{
2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793
    IShellViewImpl *This = impl_from_IFolderView(iface);
    DWORD dwStyle;
    TRACE("(%p)->(%u), stub\n", This, mode);

    if((mode < FVM_FIRST || mode > FVM_LAST) &&
       (mode != FVM_AUTO))
        return E_INVALIDARG;

    /* Windows before Vista uses LVM_SETVIEW and possibly
       LVM_SETEXTENDEDLISTVIEWSTYLE to set the style of the listview,
       while later versions seem to accomplish this through other
       means. */
    dwStyle = ViewModeToListStyle(mode);
    SetStyle(This, dwStyle, LVS_TYPEMASK);

    /* This will not necessarily be the actual mode set above.
       This mimics the behavior of Windows XP. */
    This->FolderSettings.ViewMode = mode;

    return S_OK;
2794 2795 2796 2797
}

static HRESULT WINAPI IFView_GetFolder(IFolderView *iface, REFIID riid, void **ppv)
{
2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810
    IShellViewImpl *This = impl_from_IFolderView(iface);

    TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);

    if (!ppv) return E_POINTER;

    if (IsEqualIID(riid, &IID_IShellFolder))
    {
        *ppv = This->pSFParent;
        return S_OK;
    }

    return E_NOINTERFACE;
2811 2812 2813 2814
}

static HRESULT WINAPI IFView_Item(IFolderView *iface, int index, PITEMID_CHILD *ppidl)
{
2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832
    IShellViewImpl *This = impl_from_IFolderView(iface);
    LVITEMW item;

    TRACE("(%p)->(%d %p)\n", This, index, ppidl);

    item.mask = LVIF_PARAM;
    item.iItem = index;

    if (SendMessageW(This->hWndList, LVM_GETITEMW, 0, (LPARAM)&item))
    {
        *ppidl = ILClone((PITEMID_CHILD)item.lParam);
        return S_OK;
    }
    else
    {
        *ppidl = 0;
        return E_INVALIDARG;
    }
2833 2834 2835 2836
}

static HRESULT WINAPI IFView_ItemCount(IFolderView *iface, UINT flags, int *items)
{
2837 2838 2839 2840 2841 2842 2843 2844 2845 2846
    IShellViewImpl *This = impl_from_IFolderView(iface);

    TRACE("(%p)->(%u %p)\n", This, flags, items);

    if (flags != SVGIO_ALLVIEW)
        FIXME("some flags unsupported, %x\n", flags & ~SVGIO_ALLVIEW);

    *items = SendMessageW(This->hWndList, LVM_GETITEMCOUNT, 0, 0);

    return S_OK;
2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857
}

static HRESULT WINAPI IFView_Items(IFolderView *iface, UINT flags, REFIID riid, void **ppv)
{
	IShellViewImpl *This = impl_from_IFolderView(iface);
	FIXME("(%p)->(%u %s %p), stub\n", This, flags, debugstr_guid(riid), ppv);
	return E_NOTIMPL;
}

static HRESULT WINAPI IFView_GetSelectionMarkedItem(IFolderView *iface, int *item)
{
2858 2859 2860 2861 2862 2863 2864
    IShellViewImpl *This = impl_from_IFolderView(iface);

    TRACE("(%p)->(%p)\n", This, item);

    *item = SendMessageW(This->hWndList, LVM_GETSELECTIONMARK, 0, 0);

    return S_OK;
2865 2866 2867 2868
}

static HRESULT WINAPI IFView_GetFocusedItem(IFolderView *iface, int *item)
{
2869 2870 2871 2872 2873 2874 2875
    IShellViewImpl *This = impl_from_IFolderView(iface);

    TRACE("(%p)->(%p)\n", This, item);

    *item = SendMessageW(This->hWndList, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);

    return S_OK;
2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886
}

static HRESULT WINAPI IFView_GetItemPosition(IFolderView *iface, PCUITEMID_CHILD pidl, POINT *ppt)
{
	IShellViewImpl *This = impl_from_IFolderView(iface);
	FIXME("(%p)->(%p %p), stub\n", This, pidl, ppt);
	return E_NOTIMPL;
}

static HRESULT WINAPI IFView_GetSpacing(IFolderView *iface, POINT *pt)
{
2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902
    IShellViewImpl *This = impl_from_IFolderView(iface);

    TRACE("(%p)->(%p)\n", This, pt);

    if (!This->hWndList) return S_FALSE;

    if (pt)
    {
        DWORD ret;
        ret = SendMessageW(This->hWndList, LVM_GETITEMSPACING, 0, 0);

        pt->x = LOWORD(ret);
        pt->y = HIWORD(ret);
    }

    return S_OK;
2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920
}

static HRESULT WINAPI IFView_GetDefaultSpacing(IFolderView *iface, POINT *pt)
{
	IShellViewImpl *This = impl_from_IFolderView(iface);
	FIXME("(%p)->(%p), stub\n", This, pt);
	return E_NOTIMPL;
}

static HRESULT WINAPI IFView_GetAutoArrange(IFolderView *iface)
{
	IShellViewImpl *This = impl_from_IFolderView(iface);
	FIXME("(%p), stub\n", This);
	return E_NOTIMPL;
}

static HRESULT WINAPI IFView_SelectItem(IFolderView *iface, int item, DWORD flags)
{
2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948
    IShellViewImpl *This = impl_from_IFolderView(iface);
    LVITEMW lvItem;

    TRACE("(%p)->(%d, %x)\n", This, item, flags);

    lvItem.state = 0;
    lvItem.stateMask = LVIS_SELECTED;

    if (flags & SVSI_ENSUREVISIBLE)
        SendMessageW(This->hWndList, LVM_ENSUREVISIBLE, item, 0);

    /* all items */
    if (flags & SVSI_DESELECTOTHERS)
        SendMessageW(This->hWndList, LVM_SETITEMSTATE, -1, (LPARAM)&lvItem);

    /* this item */
    if (flags & SVSI_SELECT)
        lvItem.state |= LVIS_SELECTED;

    if (flags & SVSI_FOCUSED)
        lvItem.stateMask |= LVIS_FOCUSED;

    SendMessageW(This->hWndList, LVM_SETITEMSTATE, item, (LPARAM)&lvItem);

    if (flags & SVSI_EDIT)
        SendMessageW(This->hWndList, LVM_EDITLABELW, item, 0);

    return S_OK;
2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978
}

static HRESULT WINAPI IFView_SelectAndPositionItems(IFolderView *iface, UINT cidl,
                                     PCUITEMID_CHILD_ARRAY apidl, POINT *apt, DWORD flags)
{
	IShellViewImpl *This = impl_from_IFolderView(iface);
	FIXME("(%p)->(%u %p %p %x), stub\n", This, cidl, apidl, apt, flags);
	return E_NOTIMPL;
}

static const IFolderViewVtbl fviewvt =
{
	IFView_QueryInterface,
	IFView_AddRef,
	IFView_Release,
	IFView_GetCurrentViewMode,
	IFView_SetCurrentViewMode,
	IFView_GetFolder,
	IFView_Item,
	IFView_ItemCount,
	IFView_Items,
	IFView_GetSelectionMarkedItem,
	IFView_GetFocusedItem,
	IFView_GetItemPosition,
	IFView_GetSpacing,
	IFView_GetDefaultSpacing,
	IFView_GetAutoArrange,
	IFView_SelectItem,
	IFView_SelectAndPositionItems
};
2979 2980 2981 2982 2983 2984 2985 2986 2987

/* IShellFolderView */
static HRESULT WINAPI IShellFolderView_fnQueryInterface(
    IShellFolderView *iface,
    REFIID riid,
    LPVOID *ppvObj)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    TRACE("(%p)->(IID:%s,%p)\n", This, debugstr_guid(riid), ppvObj);
2988
    return IShellView2_QueryInterface(&This->IShellView2_iface, riid, ppvObj);
2989 2990 2991 2992 2993 2994
}

static ULONG WINAPI IShellFolderView_fnAddRef(IShellFolderView *iface)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    TRACE("(%p)->(count=%u)\n", This, This->ref);
2995
    return IShellView2_AddRef(&This->IShellView2_iface);
2996 2997 2998 2999 3000 3001
}

static ULONG WINAPI IShellFolderView_fnRelease(IShellFolderView *iface)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    TRACE("(%p)->(count=%u)\n", This, This->ref);
3002
    return IShellView2_Release(&This->IShellView2_iface);
3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035
}

static HRESULT WINAPI IShellFolderView_fnRearrange(IShellFolderView *iface, LPARAM sort)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%ld) stub\n", This, sort);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnGetArrangeParam(IShellFolderView *iface, LPARAM *sort)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p) stub\n", This, sort);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnArrangeGrid(IShellFolderView *iface)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p) stub\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnAutoArrange(IShellFolderView *iface)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p) stub\n", This);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnGetAutoArrange(IShellFolderView *iface)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
3036
    IFolderView *view = &This->IFolderView_iface;
3037 3038 3039

    TRACE("(%p)\n", This);
    return IFolderView_GetAutoArrange(view);
3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057
}

static HRESULT WINAPI IShellFolderView_fnAddObject(
    IShellFolderView *iface,
    PITEMID_CHILD pidl,
    UINT *item)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p %p) stub\n", This, pidl, item);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnGetObject(
    IShellFolderView *iface,
    PITEMID_CHILD *pidl,
    UINT item)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
3058
    IFolderView *view = &This->IFolderView_iface;
3059 3060 3061

    TRACE("(%p)->(%p %d)\n", This, pidl, item);
    return IFolderView_Item(view, item, pidl);
3062 3063 3064 3065 3066 3067 3068 3069
}

static HRESULT WINAPI IShellFolderView_fnRemoveObject(
    IShellFolderView *iface,
    PITEMID_CHILD pidl,
    UINT *item)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084

    TRACE("(%p)->(%p %p)\n", This, pidl, item);

    if (pidl)
    {
        *item = LV_FindItemByPidl(This, ILFindLastID(pidl));
        SendMessageW(This->hWndList, LVM_DELETEITEM, *item, 0);
    }
    else
    {
        *item = 0;
        SendMessageW(This->hWndList, LVM_DELETEALLITEMS, 0, 0);
    }

    return S_OK;
3085 3086 3087 3088 3089 3090 3091
}

static HRESULT WINAPI IShellFolderView_fnGetObjectCount(
    IShellFolderView *iface,
    UINT *count)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
3092
    IFolderView *view = &This->IFolderView_iface;
3093 3094 3095

    TRACE("(%p)->(%p)\n", This, count);
    return IFolderView_ItemCount(view, SVGIO_ALLVIEW, (INT*)count);
3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133
}

static HRESULT WINAPI IShellFolderView_fnSetObjectCount(
    IShellFolderView *iface,
    UINT count,
    UINT flags)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%d %x) stub\n", This, count, flags);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnUpdateObject(
    IShellFolderView *iface,
    PITEMID_CHILD pidl_old,
    PITEMID_CHILD pidl_new,
    UINT *item)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p %p %p) stub\n", This, pidl_old, pidl_new, item);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnRefreshObject(
    IShellFolderView *iface,
    PITEMID_CHILD pidl,
    UINT *item)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p %p) stub\n", This, pidl, item);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnSetRedraw(
    IShellFolderView *iface,
    BOOL redraw)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
3134 3135 3136 3137 3138
    TRACE("(%p)->(%d)\n", This, redraw);

    SendMessageW(This->hWndList, WM_SETREDRAW, redraw, 0);

    return S_OK;
3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155
}

static HRESULT WINAPI IShellFolderView_fnGetSelectedCount(
    IShellFolderView *iface,
    UINT *count)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p) stub\n", This, count);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnGetSelectedObjects(
    IShellFolderView *iface,
    PCITEMID_CHILD **pidl,
    UINT *items)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
3156 3157 3158 3159 3160 3161 3162 3163 3164 3165

    TRACE("(%p)->(%p %p)\n", This, pidl, items);

    *items = ShellView_GetSelections( This );

    if (*items)
    {
        *pidl = LocalAlloc(0, *items*sizeof(LPITEMIDLIST));
        if (!*pidl) return E_OUTOFMEMORY;

3166
        /* it's documented that caller shouldn't free PIDLs, only array itself */
3167 3168 3169 3170
        memcpy((PITEMID_CHILD*)*pidl, This->apidl, *items*sizeof(LPITEMIDLIST));
    }

    return S_OK;
3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204
}

static HRESULT WINAPI IShellFolderView_fnIsDropOnSource(
    IShellFolderView *iface,
    IDropTarget *drop_target)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p) stub\n", This, drop_target);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnGetDragPoint(
    IShellFolderView *iface,
    POINT *pt)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p) stub\n", This, pt);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnGetDropPoint(
    IShellFolderView *iface,
    POINT *pt)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p) stub\n", This, pt);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnMoveIcons(
    IShellFolderView *iface,
    IDataObject *obj)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
3205
    TRACE("(%p)->(%p)\n", This, obj);
3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnSetItemPos(
    IShellFolderView *iface,
    PCUITEMID_CHILD pidl,
    POINT *pt)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p %p) stub\n", This, pidl, pt);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnIsBkDropTarget(
    IShellFolderView *iface,
    IDropTarget *drop_target)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p) stub\n", This, drop_target);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnSetClipboard(
    IShellFolderView *iface,
    BOOL move)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%d) stub\n", This, move);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnSetPoints(
    IShellFolderView *iface,
    IDataObject *obj)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p) stub\n", This, obj);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnGetItemSpacing(
    IShellFolderView *iface,
    ITEMSPACING *spacing)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p) stub\n", This, spacing);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnSetCallback(
    IShellFolderView    *iface,
    IShellFolderViewCB  *new_cb,
    IShellFolderViewCB **old_cb)

{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p %p) stub\n", This, new_cb, old_cb);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnSelect(
    IShellFolderView *iface,
    UINT flags)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%d) stub\n", This, flags);
    return E_NOTIMPL;
}

static HRESULT WINAPI IShellFolderView_fnQuerySupport(
    IShellFolderView *iface,
    UINT *support)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
3280 3281
    TRACE("(%p)->(%p)\n", This, support);
    return S_OK;
3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326
}

static HRESULT WINAPI IShellFolderView_fnSetAutomationObject(
    IShellFolderView *iface,
    IDispatch *disp)
{
    IShellViewImpl *This = impl_from_IShellFolderView(iface);
    FIXME("(%p)->(%p) stub\n", This, disp);
    return E_NOTIMPL;
}

static const IShellFolderViewVtbl shellfolderviewvt =
{
    IShellFolderView_fnQueryInterface,
    IShellFolderView_fnAddRef,
    IShellFolderView_fnRelease,
    IShellFolderView_fnRearrange,
    IShellFolderView_fnGetArrangeParam,
    IShellFolderView_fnArrangeGrid,
    IShellFolderView_fnAutoArrange,
    IShellFolderView_fnGetAutoArrange,
    IShellFolderView_fnAddObject,
    IShellFolderView_fnGetObject,
    IShellFolderView_fnRemoveObject,
    IShellFolderView_fnGetObjectCount,
    IShellFolderView_fnSetObjectCount,
    IShellFolderView_fnUpdateObject,
    IShellFolderView_fnRefreshObject,
    IShellFolderView_fnSetRedraw,
    IShellFolderView_fnGetSelectedCount,
    IShellFolderView_fnGetSelectedObjects,
    IShellFolderView_fnIsDropOnSource,
    IShellFolderView_fnGetDragPoint,
    IShellFolderView_fnGetDropPoint,
    IShellFolderView_fnMoveIcons,
    IShellFolderView_fnSetItemPos,
    IShellFolderView_fnIsBkDropTarget,
    IShellFolderView_fnSetClipboard,
    IShellFolderView_fnSetPoints,
    IShellFolderView_fnGetItemSpacing,
    IShellFolderView_fnSetCallback,
    IShellFolderView_fnSelect,
    IShellFolderView_fnQuerySupport,
    IShellFolderView_fnSetAutomationObject
};