shlview.c 59.3 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 provied 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 21 22
 * 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
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
23 24
 * FIXME: The order by part of the background context menu should be
 * buily according to the columns shown.
25
 *
26 27 28 29 30 31 32 33 34 35
 * FIXME: Load/Save the view state from/into the stream provied by
 * 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
 */

#include <stdlib.h>
#include <string.h>
41

42
#include "windef.h"
43 44
#include "winerror.h"
#include "winnls.h"
45
#include "servprov.h"
46
#include "shlguid.h"
47
#include "shlobj.h"
48
#include "undocshell.h"
49
#include "shresdef.h"
50
#include "wine/debug.h"
51

52
#include "docobj.h"
53 54
#include "pidl.h"
#include "shell32_main.h"
55
#include "shellfolder.h"
56

57
WINE_DEFAULT_DEBUG_CHANNEL(shell);
58

59 60 61 62 63 64
typedef struct
{   BOOL    bIsAscending;
    INT     nHeaderID;
    INT     nLastHeaderID;
}LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO;

65
typedef struct
66
{	ICOM_VFIELD(IShellView);
67
	DWORD		ref;
68 69
	ICOM_VTABLE(IOleCommandTarget)*	lpvtblOleCommandTarget;
	ICOM_VTABLE(IDropTarget)*	lpvtblDropTarget;
70
	ICOM_VTABLE(IDropSource)*	lpvtblDropSource;
71
	ICOM_VTABLE(IViewObject)*	lpvtblViewObject;
72
	IShellFolder*	pSFParent;
73
	IShellFolder2*	pSF2Parent;
74 75
	IShellBrowser*	pShellBrowser;
	ICommDlgBrowser*	pCommDlgBrowser;
76 77
	HWND		hWnd;		/* SHELLDLL_DefView */
	HWND		hWndList;	/* ListView control */
78 79 80 81
	HWND		hWndParent;
	FOLDERSETTINGS	FolderSettings;
	HMENU		hMenu;
	UINT		uState;
82 83
	UINT		cidl;
	LPITEMIDLIST	*apidl;
84
        LISTVIEW_SORT_INFO ListViewSortInfo;
85 86
	HANDLE		hNotify;	/* change notification handle */
	HANDLE		hAccel;
87 88 89
} IShellViewImpl;

static struct ICOM_VTABLE(IShellView) svvt;
90

91
static struct ICOM_VTABLE(IOleCommandTarget) ctvt;
92 93
#define _IOleCommandTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblOleCommandTarget)))
#define _ICOM_THIS_From_IOleCommandTarget(class, name) class* This = (class*)(((char*)name)-_IOleCommandTarget_Offset);
94 95

static struct ICOM_VTABLE(IDropTarget) dtvt;
96 97
#define _IDropTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropTarget)))
#define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
98

99
static struct ICOM_VTABLE(IDropSource) dsvt;
100 101
#define _IDropSource_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropSource)))
#define _ICOM_THIS_From_IDropSource(class, name) class* This = (class*)(((char*)name)-_IDropSource_Offset);
102

103
static struct ICOM_VTABLE(IViewObject) vovt;
104 105
#define _IViewObject_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblViewObject)))
#define _ICOM_THIS_From_IViewObject(class, name) class* This = (class*)(((char*)name)-_IViewObject_Offset);
106

107 108 109 110 111 112 113
/* ListView Header ID's */
#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

114
/*menu items */
Alexandre Julliard's avatar
Alexandre Julliard committed
115 116 117
#define IDM_VIEW_FILES  (FCIDM_SHVIEWFIRST + 0x500)
#define IDM_VIEW_IDW    (FCIDM_SHVIEWFIRST + 0x501)
#define IDM_MYFILEITEM  (FCIDM_SHVIEWFIRST + 0x502)
118

Alexandre Julliard's avatar
Alexandre Julliard committed
119
#define ID_LISTVIEW     2000
120

121 122
#define SHV_CHANGE_NOTIFY WM_USER + 0x1111

123
/*windowsx.h */
Alexandre Julliard's avatar
Alexandre Julliard committed
124
#define GET_WM_COMMAND_ID(wp, lp)               LOWORD(wp)
125
#define GET_WM_COMMAND_HWND(wp, lp)             (HWND)(lp)
Alexandre Julliard's avatar
Alexandre Julliard committed
126
#define GET_WM_COMMAND_CMD(wp, lp)              HIWORD(wp)
127

128
extern void WINAPI _InsertMenuItem (HMENU hmenu, UINT indexMenu, BOOL fByPosition,
129
			UINT wID, UINT fType, LPSTR dwTypeData, UINT fState);
Alexandre Julliard's avatar
Alexandre Julliard committed
130

131 132 133
/*
  Items merged into the toolbar and and the filemenu
*/
Alexandre Julliard's avatar
Alexandre Julliard committed
134 135 136 137 138 139 140 141 142
typedef struct
{  int   idCommand;
   int   iImage;
   int   idButtonString;
   int   idMenuString;
   BYTE  bState;
   BYTE  bStyle;
} MYTOOLINFO, *LPMYTOOLINFO;

143
MYTOOLINFO Tools[] =
144 145 146 147 148 149
{
{ FCIDM_SHVIEW_BIGICON,    0, 0, IDS_VIEW_LARGE,   TBSTATE_ENABLED, TBSTYLE_BUTTON },
{ FCIDM_SHVIEW_SMALLICON,  0, 0, IDS_VIEW_SMALL,   TBSTATE_ENABLED, TBSTYLE_BUTTON },
{ FCIDM_SHVIEW_LISTVIEW,   0, 0, IDS_VIEW_LIST,    TBSTATE_ENABLED, TBSTYLE_BUTTON },
{ FCIDM_SHVIEW_REPORTVIEW, 0, 0, IDS_VIEW_DETAILS, TBSTATE_ENABLED, TBSTYLE_BUTTON },
{ -1, 0, 0, 0, 0, 0}
Alexandre Julliard's avatar
Alexandre Julliard committed
150
};
151

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

154 155 156 157
/**********************************************************
 *	IShellView_Constructor
 */
IShellView * IShellView_Constructor( IShellFolder * pFolder)
158
{	IShellViewImpl * sv;
159
	sv=(IShellViewImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl));
160
	sv->ref=1;
161
	ICOM_VTBL(sv)=&svvt;
162 163
	sv->lpvtblOleCommandTarget=&ctvt;
	sv->lpvtblDropTarget=&dtvt;
164
	sv->lpvtblDropSource=&dsvt;
165
	sv->lpvtblViewObject=&vovt;
166

167 168 169
	sv->pSFParent = pFolder;
	if(pFolder) IShellFolder_AddRef(pFolder);
	IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (LPVOID*)&sv->pSF2Parent);
170

171
	TRACE("(%p)->(%p)\n",sv, pFolder);
172
	shell32_ObjCount++;
173
	return (IShellView *) sv;
Alexandre Julliard's avatar
Alexandre Julliard committed
174
}
175 176 177 178 179

/**********************************************************
 *
 * ##### helperfunctions for communication with ICommDlgBrowser #####
 */
180 181
static BOOL IsInCommDlg(IShellViewImpl * This)
{	return(This->pCommDlgBrowser != NULL);
Alexandre Julliard's avatar
Alexandre Julliard committed
182
}
183

184 185
static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl)
{
186
	HRESULT ret = S_OK;
187

188
	if ( IsInCommDlg(This) )
189 190 191
	{
	  TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
	  ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView*)This, pidl);
Patrik Stridvall's avatar
Patrik Stridvall committed
192
	  TRACE("--0x%08lx\n", ret);
Alexandre Julliard's avatar
Alexandre Julliard committed
193
	}
194
	return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
195
}
196 197 198

static HRESULT OnDefaultCommand(IShellViewImpl * This)
{
199
	HRESULT ret = S_FALSE;
200

201
	if (IsInCommDlg(This))
202 203 204 205
	{
	  TRACE("ICommDlgBrowser::OnDefaultCommand\n");
	  ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView*)This);
	  TRACE("--\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
206
	}
207
	return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
208
}
209 210 211

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

214
	if (IsInCommDlg(This))
215 216 217 218
	{
	  TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags);
	  ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView*)This, uFlags);
	  TRACE("--\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
219
	}
220
	return ret;
221
}
222
/**********************************************************
223
 *	set the toolbar of the filedialog buttons
224
 *
225
 * - activates the buttons from the shellbrowser according to
226
 *   the view state
227
 */
228
static void CheckToolbar(IShellViewImpl * This)
229 230
{
	LRESULT result;
231

232
	TRACE("\n");
233

234 235 236
	if (IsInCommDlg(This))
	{
	  IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
237
		FCIDM_TB_SMALLICON, (This->FolderSettings.ViewMode==FVM_LIST)? TRUE : FALSE, &result);
238
	  IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
239
		FCIDM_TB_REPORTVIEW, (This->FolderSettings.ViewMode==FVM_DETAILS)? TRUE : FALSE, &result);
240
	  IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
241
		FCIDM_TB_SMALLICON, TRUE, &result);
242
	  IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
243
		FCIDM_TB_REPORTVIEW, TRUE, &result);
244
	}
245 246
}

247 248 249 250
/**********************************************************
 *
 * ##### helperfunctions for initializing the view #####
 */
251 252 253 254 255 256
/**********************************************************
 *	change the style of the listview control
 */
static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove)
{
	DWORD tmpstyle;
257

258
	TRACE("(%p)\n", This);
259

260 261
	tmpstyle = GetWindowLongA(This->hWndList, GWL_STYLE);
	SetWindowLongA(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove));
262
}
Alexandre Julliard's avatar
Alexandre Julliard committed
263

264
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
265 266
* ShellView_CreateList()
*
267
* - creates the list view window
Alexandre Julliard's avatar
Alexandre Julliard committed
268
*/
269
static BOOL ShellView_CreateList (IShellViewImpl * This)
Alexandre Julliard's avatar
Alexandre Julliard committed
270
{	DWORD dwStyle;
Alexandre Julliard's avatar
Alexandre Julliard committed
271

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

274
	dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
275 276
		  LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_AUTOARRANGE;

277
	switch (This->FolderSettings.ViewMode)
278 279
	{
	  case FVM_ICON:	dwStyle |= LVS_ICON;		break;
Juergen Schmied's avatar
Juergen Schmied committed
280
	  case FVM_DETAILS: 	dwStyle |= LVS_REPORT;		break;
Alexandre Julliard's avatar
Alexandre Julliard committed
281 282
	  case FVM_SMALLICON: 	dwStyle |= LVS_SMALLICON;	break;
	  case FVM_LIST: 	dwStyle |= LVS_LIST;		break;
Juergen Schmied's avatar
Juergen Schmied committed
283
	  default:		dwStyle |= LVS_LIST;		break;
Alexandre Julliard's avatar
Alexandre Julliard committed
284
	}
285

286
	if (This->FolderSettings.fFlags & FWF_AUTOARRANGE)	dwStyle |= LVS_AUTOARRANGE;
287
	/*if (This->FolderSettings.fFlags && FWF_DESKTOP); used from explorer*/
288
	if (This->FolderSettings.fFlags & FWF_SINGLESEL)	dwStyle |= LVS_SINGLESEL;
Alexandre Julliard's avatar
Alexandre Julliard committed
289

290
	This->hWndList=CreateWindowExA( WS_EX_CLIENTEDGE,
291 292 293 294 295 296 297 298
					WC_LISTVIEWA,
					NULL,
					dwStyle,
					0,0,0,0,
					This->hWnd,
					(HMENU)ID_LISTVIEW,
					shell32_hInstance,
					NULL);
Alexandre Julliard's avatar
Alexandre Julliard committed
299

300
	if(!This->hWndList)
Alexandre Julliard's avatar
Alexandre Julliard committed
301 302
	  return FALSE;

303 304 305 306 307
        This->ListViewSortInfo.bIsAscending = TRUE;
        This->ListViewSortInfo.nHeaderID = -1;
        This->ListViewSortInfo.nLastHeaderID = -1;

        /*  UpdateShellSettings(); */
Alexandre Julliard's avatar
Alexandre Julliard committed
308
	return TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
309
}
310

311
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
312
* ShellView_InitList()
313
*
314
* - adds all needed columns to the shellview
Alexandre Julliard's avatar
Alexandre Julliard committed
315
*/
316 317
static BOOL ShellView_InitList(IShellViewImpl * This)
{
318 319 320 321
	LVCOLUMNA	lvColumn;
	SHELLDETAILS	sd;
	int	i;
	char	szTemp[50];
Alexandre Julliard's avatar
Alexandre Julliard committed
322

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

325
	ListView_DeleteAllItems(This->hWndList);
Alexandre Julliard's avatar
Alexandre Julliard committed
326

327 328
	lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
	lvColumn.pszText = szTemp;
Alexandre Julliard's avatar
Alexandre Julliard committed
329

330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
	if (This->pSF2Parent)
	{
	  for (i=0; 1; i++)
	  {
	    if (!SUCCEEDED(IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, i, &sd)))
	      break;
	    lvColumn.fmt = sd.fmt;
	    lvColumn.cx = sd.cxChar*8; /* chars->pixel */
	    StrRetToStrNA( szTemp, 50, &sd.str, NULL);
	    ListView_InsertColumnA(This->hWndList, i, &lvColumn);
	  }
	}
	else
	{
	  FIXME("no SF2\n");
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
346

347 348
	ListView_SetImageList(This->hWndList, ShellSmallIconList, LVSIL_SMALL);
	ListView_SetImageList(This->hWndList, ShellBigIconList, LVSIL_NORMAL);
349

350
	return TRUE;
Alexandre Julliard's avatar
Alexandre Julliard committed
351
}
352
/**********************************************************
353
* ShellView_CompareItems()
Alexandre Julliard's avatar
Alexandre Julliard committed
354 355
*
* NOTES
356
*  internal, CALLBACK for DSA_Sort
357
*/
358 359 360
static INT CALLBACK ShellView_CompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
{
	int ret;
361
	TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1, lParam2, (LPVOID) lpData);
Alexandre Julliard's avatar
Alexandre Julliard committed
362

363 364
	if(!lpData) return 0;

365
	ret =  (SHORT) SCODE_CODE(IShellFolder_CompareIDs((LPSHELLFOLDER)lpData, 0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2));
366
	TRACE("ret=%i\n",ret);
367
	return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
368 369
}

370 371 372 373 374 375 376 377 378 379 380
/*************************************************************************
 * 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
381 382
 *     A negative value if the first item should precede the second,
 *     a positive value if the first item should follow the second,
383 384 385
 *     or zero if the two items are equivalent
 *
 * NOTES
386 387 388
 *	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
389
 *	move this code to IShellFolder.
390
 *	make LISTVIEW_SORT_INFO obsolete
391
 *	the way this function works is only usable if we had only
392
 *	filesystemfolders  (25/10/99 jsch)
393 394 395 396 397 398 399 400 401
 */
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;
    LPITEMIDLIST pItemIdList1 = (LPITEMIDLIST) lParam1;
    LPITEMIDLIST pItemIdList2 = (LPITEMIDLIST) lParam2;
402
    LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData;
403 404 405 406 407 408 409 410 411 412 413 414


    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
415
    {
416
        /* Sort by Time: Folders or Files can be sorted */
417

418
        if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)
419 420 421 422 423 424
        {
            _ILGetFileDateTime(pItemIdList1, &fd1);
            _ILGetFileDateTime(pItemIdList2, &fd2);
            nDiff = CompareFileTime(&fd2, &fd1);
        }
        /* Sort by Attribute: Folder or Files can be sorted */
425
        else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB)
426
        {
427 428
            _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH);
            _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH);
429 430 431
            nDiff = strcasecmp(strName1, strName2);
        }
        /* Sort by FileName: Folder or Files can be sorted */
432
        else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder)
433 434 435 436 437 438 439
        {
            /* Sort by Text */
            _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
            _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
            nDiff = strcasecmp(strName1, strName2);
        }
        /* Sort by File Size, Only valid for Files */
440
        else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)
441
        {
442
            nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0));
443 444
        }
        /* Sort by File Type, Only valid for Files */
445
        else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)
446 447 448 449 450 451 452 453
        {
            /* Sort by Type */
            _ILGetFileType(pItemIdList1, strName1, MAX_PATH);
            _ILGetFileType(pItemIdList2, strName2, MAX_PATH);
            nDiff = strcasecmp(strName1, strName2);
        }
    }
    /*  If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
454

455 456 457 458 459 460 461
    if(nDiff == 0)
    {
        _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH);
        _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH);
        nDiff = strcasecmp(strName1, strName2);
    }

462 463 464 465 466
    if(!pSortInfo->bIsAscending)
    {
        nDiff = -nDiff;
    }

467 468 469 470
    return nDiff;

}

471 472
/**********************************************************
*  LV_FindItemByPidl()
473
*/
474 475
static int LV_FindItemByPidl(
	IShellViewImpl * This,
Juergen Schmied's avatar
Juergen Schmied committed
476
	LPCITEMIDLIST pidl)
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
{
	LVITEMA lvItem;
	ZeroMemory(&lvItem, sizeof(LVITEMA));
	lvItem.mask = LVIF_PARAM;
	for(lvItem.iItem = 0; ListView_GetItemA(This->hWndList, &lvItem); lvItem.iItem++)
	{
	  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
496
static BOOLEAN LV_AddItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
497 498 499
{
	LVITEMA	lvItem;

Juergen Schmied's avatar
Juergen Schmied committed
500
	TRACE("(%p)(pidl=%p)\n", This, pidl);
501 502 503 504 505 506 507 508 509 510 511 512 513

	ZeroMemory(&lvItem, sizeof(lvItem));	/* create the listview item*/
	lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;	/*set the mask*/
	lvItem.iItem = ListView_GetItemCount(This->hWndList);	/*add the item to the end of the list*/
	lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidl));				/*set the item's data*/
	lvItem.pszText = LPSTR_TEXTCALLBACKA;			/*get text on a callback basis*/
	lvItem.iImage = I_IMAGECALLBACK;			/*get the image on a callback basis*/
	return (-1==ListView_InsertItemA(This->hWndList, &lvItem))? FALSE: TRUE;
}

/**********************************************************
* LV_DeleteItem()
*/
Juergen Schmied's avatar
Juergen Schmied committed
514
static BOOLEAN LV_DeleteItem(IShellViewImpl * This, LPCITEMIDLIST pidl)
515 516 517
{
	int nIndex;

Juergen Schmied's avatar
Juergen Schmied committed
518
	TRACE("(%p)(pidl=%p)\n", This, pidl);
519 520 521 522 523 524 525 526

	nIndex = LV_FindItemByPidl(This, ILFindLastID(pidl));
	return (-1==ListView_DeleteItem(This->hWndList, nIndex))? FALSE: TRUE;
}

/**********************************************************
* LV_RenameItem()
*/
Juergen Schmied's avatar
Juergen Schmied committed
527
static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew )
528 529 530 531
{
	int nItem;
	LVITEMA lvItem;

Juergen Schmied's avatar
Juergen Schmied committed
532
	TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew);
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547

	nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld));
	if ( -1 != nItem )
	{
	  ZeroMemory(&lvItem, sizeof(lvItem));	/* create the listview item*/
	  lvItem.mask = LVIF_PARAM;		/* only the pidl */
	  lvItem.iItem = nItem;
	  ListView_GetItemA(This->hWndList, &lvItem);

	  SHFree((LPITEMIDLIST)lvItem.lParam);
	  lvItem.mask = LVIF_PARAM;
	  lvItem.iItem = nItem;
	  lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew));	/* set the item's data */
	  ListView_SetItemA(This->hWndList, &lvItem);
	  ListView_Update(This->hWndList, nItem);
548
	  return TRUE;					/* FIXME: better handling */
549 550 551
	}
	return FALSE;
}
552
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
553 554
* ShellView_FillList()
*
555 556 557
* - gets the objectlist from the shellfolder
* - sorts the list
* - fills the list into the view
558
*/
Alexandre Julliard's avatar
Alexandre Julliard committed
559

560
static HRESULT ShellView_FillList(IShellViewImpl * This)
561 562
{
	LPENUMIDLIST	pEnumIDList;
563 564
	LPITEMIDLIST	pidl;
	DWORD		dwFetched;
565
	UINT		i;
566 567
	HRESULT		hRes;
	HDPA		hdpa;
Alexandre Julliard's avatar
Alexandre Julliard committed
568

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

571
	/* get the itemlist from the shfolder*/
572 573
	hRes = IShellFolder_EnumObjects(This->pSFParent,This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList);
	if (hRes != S_OK)
574 575
	{
	  if (hRes==S_FALSE)
576 577
	    return(NOERROR);
	  return(hRes);
578
	}
579

580
	/* create a pointer array */
581
	hdpa = pDPA_Create(16);
582
	if (!hdpa)
583 584
	{
	  return(E_OUTOFMEMORY);
585
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
586

587
	/* copy the items into the array*/
588
	while((S_OK == IEnumIDList_Next(pEnumIDList,1, &pidl, &dwFetched)) && dwFetched)
589 590 591 592
	{
	  if (pDPA_InsertPtr(hdpa, 0x7fff, pidl) == -1)
	  {
	    SHFree(pidl);
593
	  }
594
	}
595

596
	/* sort the array */
597
	pDPA_Sort(hdpa, ShellView_CompareItems, (LPARAM)This->pSFParent);
598 599

	/*turn the listview's redrawing off*/
600
	SendMessageA(This->hWndList, WM_SETREDRAW, FALSE, 0);
601

602
	for (i=0; i < DPA_GetPtrCount(hdpa); ++i) 	/* DPA_GetPtrCount is a macro*/
603
	{
604
	  pidl = (LPITEMIDLIST)pDPA_GetPtr(hdpa, i);
605 606 607

	  /* in a commdlg This works as a filemask*/
	  if ( IncludeObject(This, pidl)==S_OK )
Juergen Schmied's avatar
Juergen Schmied committed
608 609
	    LV_AddItem(This, pidl);
	  SHFree(pidl);
610
	}
611 612

	/*turn the listview's redrawing back on and force it to draw*/
613
	SendMessageA(This->hWndList, WM_SETREDRAW, TRUE, 0);
Alexandre Julliard's avatar
Alexandre Julliard committed
614

615
	IEnumIDList_Release(pEnumIDList); /* destroy the list*/
616
	pDPA_Destroy(hdpa);
617

618
	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
619 620
}

621
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
622
*  ShellView_OnCreate()
623
*/
624 625
static LRESULT ShellView_OnCreate(IShellViewImpl * This)
{
626
	IDropTarget* pdt;
627 628
	NOTIFYREGISTER ntreg;
	IPersistFolder2 * ppf2 = NULL;
629

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

632 633 634 635 636 637
	if(ShellView_CreateList(This))
	{
	  if(ShellView_InitList(This))
	  {
	    ShellView_FillList(This);
	  }
Alexandre Julliard's avatar
Alexandre Julliard committed
638
	}
639

640
	if(GetShellOle())
641
	{
642 643 644 645 646
	  if (SUCCEEDED(IShellFolder_CreateViewObject(This->pSFParent, This->hWnd, &IID_IDropTarget, (LPVOID*)&pdt)))
	  {
	    pRegisterDragDrop(This->hWnd, pdt);
	    IDropTarget_Release(pdt);
	  }
647
	}
648 649 650 651 652 653 654 655 656 657 658 659 660

	/* register for receiving notifications */
	IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2);
	if (ppf2)
	{
	  IPersistFolder2_GetCurFolder(ppf2, &ntreg.pidlPath);
	  ntreg.bWatchSubtree = FALSE;
	  This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNF_IDLIST, SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg);
	  SHFree(ntreg.pidlPath);
	  IPersistFolder2_Release(ppf2);
	}

	This->hAccel = LoadAcceleratorsA(shell32_hInstance, "shv_accel");
661

Alexandre Julliard's avatar
Alexandre Julliard committed
662
	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
663
}
664 665 666 667 668 669

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

/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
670
* ShellView_BuildFileMenu()
671 672
*/
static HMENU ShellView_BuildFileMenu(IShellViewImpl * This)
673
{	CHAR	szText[MAX_PATH];
674
	MENUITEMINFOA	mii;
675
	int	nTools,i;
676
	HMENU	hSubMenu;
Alexandre Julliard's avatar
Alexandre Julliard committed
677

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

680
	hSubMenu = CreatePopupMenu();
Alexandre Julliard's avatar
Alexandre Julliard committed
681 682
	if(hSubMenu)
	{ /*get the number of items in our global array*/
683
	  for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){}
Alexandre Julliard's avatar
Alexandre Julliard committed
684

Alexandre Julliard's avatar
Alexandre Julliard committed
685
	  /*add the menu items*/
Alexandre Julliard's avatar
Alexandre Julliard committed
686
	  for(i = 0; i < nTools; i++)
687
	  {
688 689
	    LoadStringA(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH);

Alexandre Julliard's avatar
Alexandre Julliard committed
690 691 692 693
	    ZeroMemory(&mii, sizeof(mii));
	    mii.cbSize = sizeof(mii);
	    mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;

694 695 696
	    if(TBSTYLE_SEP != Tools[i].bStyle) /* no seperator*/
	    {
	      mii.fType = MFT_STRING;
Alexandre Julliard's avatar
Alexandre Julliard committed
697 698
	      mii.fState = MFS_ENABLED;
	      mii.dwTypeData = szText;
699
	      mii.wID = Tools[i].idCommand;
Alexandre Julliard's avatar
Alexandre Julliard committed
700
	    }
Alexandre Julliard's avatar
Alexandre Julliard committed
701
	    else
702 703
	    {
	      mii.fType = MFT_SEPARATOR;
Alexandre Julliard's avatar
Alexandre Julliard committed
704
	    }
705
	    /* tack This item onto the end of the menu */
706
	    InsertMenuItemA(hSubMenu, (UINT)-1, TRUE, &mii);
Alexandre Julliard's avatar
Alexandre Julliard committed
707
	  }
Alexandre Julliard's avatar
Alexandre Julliard committed
708
	}
709
	TRACE("-- return (menu=0x%x)\n",hSubMenu);
Alexandre Julliard's avatar
Alexandre Julliard committed
710 711
	return hSubMenu;
}
712
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
713
* ShellView_MergeFileMenu()
714 715
*/
static void ShellView_MergeFileMenu(IShellViewImpl * This, HMENU hSubMenu)
716
{	TRACE("(%p)->(submenu=0x%08x) stub\n",This,hSubMenu);
Alexandre Julliard's avatar
Alexandre Julliard committed
717 718

	if(hSubMenu)
719
	{ /*insert This item at the beginning of the menu */
720
	  _InsertMenuItem(hSubMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
721
	  _InsertMenuItem(hSubMenu, 0, TRUE, IDM_MYFILEITEM, MFT_STRING, "dummy45", MFS_ENABLED);
Alexandre Julliard's avatar
Alexandre Julliard committed
722 723

	}
724
	TRACE("--\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
725 726
}

727
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
728
* ShellView_MergeViewMenu()
729
*/
730

731
static void ShellView_MergeViewMenu(IShellViewImpl * This, HMENU hSubMenu)
732
{	MENUITEMINFOA	mii;
733

734
	TRACE("(%p)->(submenu=0x%08x)\n",This,hSubMenu);
735

Alexandre Julliard's avatar
Alexandre Julliard committed
736
	if(hSubMenu)
737 738
	{ /*add a separator at the correct position in the menu*/
	  _InsertMenuItem(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
739 740 741

	  ZeroMemory(&mii, sizeof(mii));
	  mii.cbSize = sizeof(mii);
742
	  mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;
743 744
	  mii.fType = MFT_STRING;
	  mii.dwTypeData = "View";
745
	  mii.hSubMenu = LoadMenuA(shell32_hInstance, "MENU_001");
746
	  InsertMenuItemA(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
Alexandre Julliard's avatar
Alexandre Julliard committed
747 748
	}
}
749

750 751 752
/**********************************************************
*   ShellView_GetSelections()
*
753 754
* - fills the this->apidl list with the selected objects
*
755 756
* RETURNS
*  number of selected items
757
*/
758 759 760 761 762 763 764 765 766 767 768 769 770 771
static UINT ShellView_GetSelections(IShellViewImpl * This)
{
	LVITEMA	lvItem;
	UINT	i = 0;

	if (This->apidl)
	{
	  SHFree(This->apidl);
	}

	This->cidl = ListView_GetSelectedCount(This->hWndList);
	This->apidl = (LPITEMIDLIST*)SHAlloc(This->cidl * sizeof(LPITEMIDLIST));

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

773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806
	if(This->apidl)
	{
	  TRACE("-- Items selected =%u\n", This->cidl);

	  ZeroMemory(&lvItem, sizeof(lvItem));
	  lvItem.mask = LVIF_STATE | LVIF_PARAM;
	  lvItem.stateMask = LVIS_SELECTED;

	  while(ListView_GetItemA(This->hWndList, &lvItem) && (i < This->cidl))
	  {
	    if(lvItem.state & LVIS_SELECTED)
	    {
	      This->apidl[i] = (LPITEMIDLIST)lvItem.lParam;
	      i++;
	      TRACE("-- selected Item found\n");
	    }
	    lvItem.iItem++;
	  }
	}
	return This->cidl;

}
/**********************************************************
 *	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;
	IContextMenu *	pCM = NULL;
	CMINVOKECOMMANDINFO	cmi;
807

808 809 810 811 812
	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) )
	{
813
	  IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, This->apidl,
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 840 841 842 843 844
					(REFIID)&IID_IContextMenu, NULL, (LPVOID *)&pContextMenu);

	  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 )))
	      {
		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);
845
		}
846 847 848 849

		if(uCommand > 0)
		{
		  TRACE("-- uCommand=%u\n", uCommand);
850
		  if (IsInCommDlg(This) && ((uCommand==FCIDM_SHVIEW_EXPLORE) || (uCommand==FCIDM_SHVIEW_OPEN)))
851 852 853 854 855 856 857 858 859
		  {
		    TRACE("-- dlg: OnDefaultCommand\n");
		    OnDefaultCommand(This);
		  }
		  else
		  {
		    TRACE("-- explore -- invoke command\n");
		    ZeroMemory(&cmi, sizeof(cmi));
		    cmi.cbSize = sizeof(cmi);
860
		    cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */
861 862 863 864 865 866 867 868 869
		    cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
		    IContextMenu_InvokeCommand(pContextMenu, &cmi);
		  }
		}
		DestroyMenu(hMenu);
	      }
	    }
	    if (pContextMenu)
	      IContextMenu_Release(pContextMenu);
870 871
	  }
	}
872
	else	/* background context menu */
873
	{
874 875
	  hMenu = CreatePopupMenu();

876
	  pCM = ISvBgCm_Constructor(This->pSFParent);
877 878 879 880 881
	  IContextMenu_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);

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

882
	  TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand);
883 884 885 886 887 888 889 890 891

	  ZeroMemory(&cmi, sizeof(cmi));
	  cmi.cbSize = sizeof(cmi);
	  cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
	  cmi.hwnd = This->hWndParent;
	  IContextMenu_InvokeCommand(pCM, &cmi);

	  IContextMenu_Release(pCM);
	}
892 893
}

894 895 896 897 898 899
/**********************************************************
 *	##### message handling #####
 */

/**********************************************************
*  ShellView_OnSize()
Alexandre Julliard's avatar
Alexandre Julliard committed
900
*/
901 902 903
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
904

905 906 907 908
	/*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
909
	}
910

911
	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
912
}
913
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
914 915 916 917
* ShellView_OnDeactivate()
*
* NOTES
*  internal
918
*/
919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934
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
935 936
}

937
/**********************************************************
938
* ShellView_OnActivate()
939
*/
940
static LRESULT ShellView_OnActivate(IShellViewImpl * This, UINT uState)
941 942
{	OLEMENUGROUPWIDTHS   omw = { {0, 0, 0, 0, 0, 0} };
	MENUITEMINFOA         mii;
Alexandre Julliard's avatar
Alexandre Julliard committed
943
	CHAR                szText[MAX_PATH];
Alexandre Julliard's avatar
Alexandre Julliard committed
944

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

947
	/*don't do anything if the state isn't really changing */
948
	if(This->uState == uState)
949 950
	{
	  return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
951
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
952

953
	ShellView_OnDeactivate(This);
Alexandre Julliard's avatar
Alexandre Julliard committed
954

955
	/*only do This if we are active */
Alexandre Julliard's avatar
Alexandre Julliard committed
956
	if(uState != SVUIA_DEACTIVATE)
957 958
	{
	  /*merge the menus */
959
	  This->hMenu = CreateMenu();
960

961
	  if(This->hMenu)
962 963
	  {
	    IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw);
964
	    TRACE("-- after fnInsertMenusSB\n");
965

Alexandre Julliard's avatar
Alexandre Julliard committed
966 967
	    /*build the top level menu get the menu item's text*/
	    strcpy(szText,"dummy 31");
968

Alexandre Julliard's avatar
Alexandre Julliard committed
969 970 971 972 973 974
	    ZeroMemory(&mii, sizeof(mii));
	    mii.cbSize = sizeof(mii);
	    mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
	    mii.fType = MFT_STRING;
	    mii.fState = MFS_ENABLED;
	    mii.dwTypeData = szText;
975
	    mii.hSubMenu = ShellView_BuildFileMenu(This);
Alexandre Julliard's avatar
Alexandre Julliard committed
976 977 978

	    /*insert our menu into the menu bar*/
	    if(mii.hSubMenu)
979 980
	    {
	      InsertMenuItemA(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii);
Alexandre Julliard's avatar
Alexandre Julliard committed
981 982 983 984 985 986
	    }

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

988
	    if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii))
989 990
	    {
	      ShellView_MergeViewMenu(This, mii.hSubMenu);
Alexandre Julliard's avatar
Alexandre Julliard committed
991
	    }
Alexandre Julliard's avatar
Alexandre Julliard committed
992

Alexandre Julliard's avatar
Alexandre Julliard committed
993 994
	    /*add the items that should only be added if we have the focus*/
	    if(SVUIA_ACTIVATE_FOCUS == uState)
995 996
	    {
	      /*get the file menu so we can merge with it */
Alexandre Julliard's avatar
Alexandre Julliard committed
997
	      ZeroMemory(&mii, sizeof(mii));
Alexandre Julliard's avatar
Alexandre Julliard committed
998
	      mii.cbSize = sizeof(mii);
Alexandre Julliard's avatar
Alexandre Julliard committed
999
	      mii.fMask = MIIM_SUBMENU;
1000

1001
	      if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii))
1002 1003
	      {
	        ShellView_MergeFileMenu(This, mii.hSubMenu);
Alexandre Julliard's avatar
Alexandre Julliard committed
1004 1005
	      }
	    }
1006
	    TRACE("-- before fnSetMenuSB\n");
1007
	    IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd);
Alexandre Julliard's avatar
Alexandre Julliard committed
1008 1009
	  }
	}
1010
	This->uState = uState;
1011
	TRACE("--\n");
1012
	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
1013 1014
}

1015
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1016 1017 1018
*  ShellView_OnSetFocus()
*
*/
1019 1020 1021 1022 1023
static LRESULT ShellView_OnSetFocus(IShellViewImpl * This)
{
	TRACE("%p\n",This);

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

1027 1028
	IShellBrowser_OnViewWindowActive(This->pShellBrowser,(IShellView*) This);
	ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS);
Alexandre Julliard's avatar
Alexandre Julliard committed
1029

1030 1031 1032
	/* Set the focus to the listview */
	SetFocus(This->hWndList);

1033 1034 1035
	/* Notify the ICommDlgBrowser interface */
	OnStateChange(This,CDBOSC_SETFOCUS);

Alexandre Julliard's avatar
Alexandre Julliard committed
1036
	return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
1037 1038
}

1039
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1040
* ShellView_OnKillFocus()
1041
*/
1042 1043 1044
static LRESULT ShellView_OnKillFocus(IShellViewImpl * This)
{
	TRACE("(%p) stub\n",This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1045

1046
	ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS);
1047 1048
	/* Notify the ICommDlgBrowser */
	OnStateChange(This,CDBOSC_KILLFOCUS);
Alexandre Julliard's avatar
Alexandre Julliard committed
1049 1050 1051

	return 0;
}
1052 1053

/**********************************************************
1054
* ShellView_OnCommand()
1055 1056 1057
*
* NOTES
*	the CmdID's are the ones from the context menu
1058
*/
1059 1060 1061
static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd)
{
	TRACE("(%p)->(0x%08lx 0x%08lx 0x%08x) stub\n",This, dwCmdID, dwCmd, hwndCmd);
1062

1063 1064
	switch(dwCmdID)
	{
1065
	  case FCIDM_SHVIEW_SMALLICON:
1066 1067
	    This->FolderSettings.ViewMode = FVM_SMALLICON;
	    SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK);
1068
	    CheckToolbar(This);
1069 1070 1071
	    break;

	  case FCIDM_SHVIEW_BIGICON:
1072 1073
	    This->FolderSettings.ViewMode = FVM_ICON;
	    SetStyle (This, LVS_ICON, LVS_TYPEMASK);
1074
	    CheckToolbar(This);
1075 1076 1077
	    break;

	  case FCIDM_SHVIEW_LISTVIEW:
1078 1079
	    This->FolderSettings.ViewMode = FVM_LIST;
	    SetStyle (This, LVS_LIST, LVS_TYPEMASK);
1080
	    CheckToolbar(This);
1081 1082 1083
	    break;

	  case FCIDM_SHVIEW_REPORTVIEW:
1084 1085
	    This->FolderSettings.ViewMode = FVM_DETAILS;
	    SetStyle (This, LVS_REPORT, LVS_TYPEMASK);
1086
	    CheckToolbar(This);
1087 1088
	    break;

1089 1090 1091 1092 1093
	  /* the menu-ID's for sorting are 0x30... see shrec.rc */
	  case 0x30:
	  case 0x31:
	  case 0x32:
	  case 0x33:
1094 1095 1096 1097
	    This->ListViewSortInfo.nHeaderID = (LPARAM) (dwCmdID - 0x30);
	    This->ListViewSortInfo.bIsAscending = TRUE;
	    This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID;
	    ListView_SortItems(This->hWndList, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1098
	    break;
1099

1100
	  default:
1101
	    TRACE("-- COMMAND 0x%04lx unhandled\n", dwCmdID);
1102 1103 1104 1105
	}
	return 0;
}

1106
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1107 1108
* ShellView_OnNotify()
*/
1109

1110
static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
1111
{	LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh;
1112
	NMLVDISPINFOA *lpdi = (NMLVDISPINFOA *)lpnmh;
Alexandre Julliard's avatar
Alexandre Julliard committed
1113
	LPITEMIDLIST pidl;
1114

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

Alexandre Julliard's avatar
Alexandre Julliard committed
1117
	switch(lpnmh->code)
1118 1119
	{
	  case NM_SETFOCUS:
1120
	    TRACE("-- NM_SETFOCUS %p\n",This);
1121
	    ShellView_OnSetFocus(This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1122 1123 1124
	    break;

	  case NM_KILLFOCUS:
1125
	    TRACE("-- NM_KILLFOCUS %p\n",This);
1126
	    ShellView_OnDeactivate(This);
1127 1128
	    /* Notify the ICommDlgBrowser interface */
	    OnStateChange(This,CDBOSC_KILLFOCUS);
Alexandre Julliard's avatar
Alexandre Julliard committed
1129 1130
	    break;

1131
	  case HDN_ENDTRACKA:
1132
	    TRACE("-- HDN_ENDTRACKA %p\n",This);
1133 1134
	    /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
	    nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
Alexandre Julliard's avatar
Alexandre Julliard committed
1135
	    break;
1136

Alexandre Julliard's avatar
Alexandre Julliard committed
1137
	  case LVN_DELETEITEM:
1138
	    TRACE("-- LVN_DELETEITEM %p\n",This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1139 1140
	    SHFree((LPITEMIDLIST)lpnmlv->lParam);     /*delete the pidl because we made a copy of it*/
	    break;
Alexandre Julliard's avatar
Alexandre Julliard committed
1141 1142

	  case LVN_ITEMACTIVATE:
1143
	    TRACE("-- LVN_ITEMACTIVATE %p\n",This);
1144 1145
	    OnStateChange(This, CDBOSC_SELCHANGE);  /* the browser will get the IDataObject now */
	    ShellView_DoContextMenu(This, 0, 0, TRUE);
Alexandre Julliard's avatar
Alexandre Julliard committed
1146
	    break;
1147

1148
	  case LVN_COLUMNCLICK:
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158
	    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;
1159 1160

	    ListView_SortItems(lpnmlv->hdr.hwndFrom, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo)));
1161
	    break;
1162

1163
	  case LVN_GETDISPINFOA:
1164 1165
          case LVN_GETDISPINFOW:
	    TRACE("-- LVN_GETDISPINFO %p\n",This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1166 1167
	    pidl = (LPITEMIDLIST)lpdi->item.lParam;

1168 1169 1170
	    if(lpdi->item.mask & LVIF_TEXT)	/* text requested */
	    {
	      if (This->pSF2Parent)
1171
	      {
1172 1173
	        SHELLDETAILS sd;
	        IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd);
1174 1175 1176 1177 1178 1179 1180 1181 1182 1183
                if (lpnmh->code == LVN_GETDISPINFOA)
                {
                    StrRetToStrNA( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
                    TRACE("-- text=%s\n",lpdi->item.pszText);
                }
                else /* LVN_GETDISPINFOW */
                {
                    StrRetToStrNW( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
                    TRACE("-- text=%s\n",debugstr_w((WCHAR*)(lpdi->item.pszText)));
                }
Alexandre Julliard's avatar
Alexandre Julliard committed
1184
	      }
1185
	      else
1186
	      {
1187
	        FIXME("no SF2\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
1188 1189
	      }
	    }
1190 1191 1192 1193
	    if(lpdi->item.mask & LVIF_IMAGE)	/* image requested */
	    {
	      lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
	    }
Alexandre Julliard's avatar
Alexandre Julliard committed
1194
	    break;
Alexandre Julliard's avatar
Alexandre Julliard committed
1195

Alexandre Julliard's avatar
Alexandre Julliard committed
1196
	  case LVN_ITEMCHANGED:
1197
	    TRACE("-- LVN_ITEMCHANGED %p\n",This);
1198
	    OnStateChange(This, CDBOSC_SELCHANGE);  /* the browser will get the IDataObject now */
Alexandre Julliard's avatar
Alexandre Julliard committed
1199 1200
	    break;

1201 1202
	  case LVN_BEGINDRAG:
	  case LVN_BEGINRDRAG:
1203
	    TRACE("-- LVN_BEGINDRAG\n");
1204 1205

	    if (ShellView_GetSelections(This))
1206
	    {
1207
	      IDataObject * pda;
Juergen Schmied's avatar
Juergen Schmied committed
1208
	      DWORD dwAttributes = SFGAO_CANLINK;
1209
	      DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE;
1210

1211
	      if(GetShellOle())
1212
	      {
1213 1214 1215
	        if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, &IID_IDataObject,0,(LPVOID *)&pda)))
	        {
	          IDropSource * pds = (IDropSource*)&(This->lpvtblDropSource);	/* own DropSource interface */
1216

1217
	  	  if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, This->apidl, &dwAttributes)))
1218
		  {
1219 1220 1221 1222
		    if (dwAttributes & SFGAO_CANLINK)
		    {
		      dwEffect |= DROPEFFECT_LINK;
		    }
1223
		  }
1224

1225 1226 1227 1228 1229 1230 1231
	          if (pds)
	          {
	            DWORD dwEffect;
		    pDoDragDrop(pda, pds, dwEffect, &dwEffect);
		  }
	          IDataObject_Release(pda);
	        }
1232 1233 1234 1235 1236
	      }
	    }
	    break;

	  case LVN_BEGINLABELEDITA:
1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251
	    {
	      DWORD dwAttr = SFGAO_CANRENAME;
	      pidl = (LPITEMIDLIST)lpdi->item.lParam;

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

	      IShellFolder_GetAttributesOf(This->pSFParent, 1, &pidl, &dwAttr);
	      if (SFGAO_CANRENAME & dwAttr)
	      {
	        return FALSE;
	      }
	      return TRUE;
	    }
	    break;

1252
	  case LVN_ENDLABELEDITA:
1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264
	    {
	      TRACE("-- LVN_ENDLABELEDITA %p\n",This);
	      if (lpdi->item.pszText)
	      {
	        HRESULT hr;
		WCHAR wszNewName[MAX_PATH];
		LVITEMA lvItem;

		ZeroMemory(&lvItem, sizeof(LVITEMA));
		lvItem.iItem = lpdi->item.iItem;
		lvItem.mask = LVIF_PARAM;
		ListView_GetItemA(This->hWndList, &lvItem);
1265

1266
		pidl = (LPITEMIDLIST)lpdi->item.lParam;
1267 1268
                if (!MultiByteToWideChar( CP_ACP, 0, lpdi->item.pszText, -1, wszNewName, MAX_PATH ))
                    wszNewName[MAX_PATH-1] = 0;
1269
	        hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, wszNewName, SHGDN_INFOLDER, &pidl);
1270

1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281
		if(SUCCEEDED(hr) && pidl)
		{
	          lvItem.mask = LVIF_PARAM;
		  lvItem.lParam = (LPARAM)pidl;
		  ListView_SetItemA(This->hWndList, &lvItem);
		  return TRUE;
		}
	      }
	      return FALSE;
	    }
	    break;
1282

1283 1284 1285 1286 1287 1288 1289 1290 1291
	  case LVN_KEYDOWN:
	    {
	    /*  MSG msg;
	      msg.hwnd = This->hWnd;
	      msg.message = WM_KEYDOWN;
	      msg.wParam = plvKeyDown->wVKey;
	      msg.lParam = 0;
	      msg.time = 0;
	      msg.pt = 0;*/
1292

1293
	      LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh;
1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306

              /* initiate a rename of the selected file or directory */
              if(plvKeyDown->wVKey == VK_F2)
              {
                /* see how many files are selected */
                int i = ListView_GetSelectedCount(This->hWndList);

                /* get selected item */
                if(i == 1)
                {
                  /* get selected item */
                  i = ListView_GetNextItem(This->hWndList, -1,
			LVNI_SELECTED);
1307

1308 1309 1310 1311
                  ListView_EnsureVisible(This->hWndList, i, 0);
                  ListView_EditLabelA(This->hWndList, i);
                }
              }
1312 1313 1314
#if 0
	      TranslateAccelerator(This->hWnd, This->hAccel, &msg)
#endif
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326
	      else if(plvKeyDown->wVKey == VK_DELETE)
              {
		int i, item_index;
		LVITEMA item;
		LPITEMIDLIST* pItems;
		ISFHelper *psfhlp;

		IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper,
		 	(LPVOID*)&psfhlp);

		if(!(i = ListView_GetSelectedCount(This->hWndList)))
		  break;
1327

1328
		/* allocate memory for the pidl array */
1329
		pItems = HeapAlloc(GetProcessHeap(), 0,
1330
			sizeof(LPITEMIDLIST) * i);
1331

1332 1333 1334 1335 1336 1337
		/* retrieve all selected items */
		i = 0;
		item_index = -1;
		while(ListView_GetSelectedCount(This->hWndList) > i)
		{
		  /* get selected item */
1338
		  item_index = ListView_GetNextItem(This->hWndList,
1339 1340 1341 1342 1343 1344
			item_index, LVNI_SELECTED);
		  item.iItem = item_index;
		  ListView_GetItemA(This->hWndList, &item);

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

1346 1347 1348 1349 1350 1351 1352 1353 1354
		  i++;
		}

		/* perform the item deletion */
		ISFHelper_DeleteItems(psfhlp, i, pItems);

		/* free pidl array memory */
		HeapFree(GetProcessHeap(), 0, pItems);
              }
1355
              else
1356
		FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey);
1357 1358
	    }
	    break;
1359

Alexandre Julliard's avatar
Alexandre Julliard committed
1360
	  default:
1361
	    TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code);
1362
	    break;
Alexandre Julliard's avatar
Alexandre Julliard committed
1363 1364
	}
	return 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
1365 1366
}

1367 1368 1369 1370 1371 1372 1373 1374 1375
/**********************************************************
* ShellView_OnChange()
*/

static LRESULT ShellView_OnChange(IShellViewImpl * This, LPITEMIDLIST * Pidls, LONG wEventId)
{

	TRACE("(%p)(%p,%p,0x%08lx)\n", This, Pidls[0], Pidls[1], wEventId);
	switch(wEventId)
1376
	{
1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393
	  case SHCNE_MKDIR:
	  case SHCNE_CREATE:
	    LV_AddItem(This, Pidls[0]);
	    break;
	  case SHCNE_RMDIR:
	  case SHCNE_DELETE:
	    LV_DeleteItem(This, Pidls[0]);
	    break;
	  case SHCNE_RENAMEFOLDER:
	  case SHCNE_RENAMEITEM:
	    LV_RenameItem(This, Pidls[0], Pidls[1]);
	    break;
	  case SHCNE_UPDATEITEM:
	    break;
	}
	return TRUE;
}
1394
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1395 1396 1397
*  ShellView_WndProc
*/

1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419
static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
	IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongA(hWnd, GWL_USERDATA);
	LPCREATESTRUCTA lpcs;

	TRACE("(hwnd=%x msg=%x wparm=%x lparm=%lx)\n",hWnd, uMessage, wParam, lParam);

	switch (uMessage)
	{
	  case WM_NCCREATE:
	    lpcs = (LPCREATESTRUCTA)lParam;
	    pThis = (IShellViewImpl*)(lpcs->lpCreateParams);
	    SetWindowLongA(hWnd, GWL_USERDATA, (LONG)pThis);
	    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);
1420 1421 1422
	  case WM_COMMAND:      return ShellView_OnCommand(pThis,
					GET_WM_COMMAND_ID(wParam, lParam),
					GET_WM_COMMAND_CMD(wParam, lParam),
1423
					GET_WM_COMMAND_HWND(wParam, lParam));
1424
	  case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (LPITEMIDLIST*)wParam, (LONG)lParam);
1425

1426 1427 1428
	  case WM_CONTEXTMENU:  ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE);
	                        return 0;

1429 1430 1431
	  case WM_SHOWWINDOW:	UpdateWindow(pThis->hWndList);
				break;

1432 1433
	  case WM_GETDLGCODE:   return SendMessageA(pThis->hWndList,uMessage,0,0);

1434 1435 1436 1437
	  case WM_DESTROY:	if(GetShellOle())
				{
	  			  pRevokeDragDrop(pThis->hWnd);
				}
1438
				SHChangeNotifyDeregister(pThis->hNotify);
1439
	                        break;
1440 1441 1442
	}

	return DefWindowProcA (hWnd, uMessage, wParam, lParam);
Alexandre Julliard's avatar
Alexandre Julliard committed
1443
}
1444
/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1445 1446 1447 1448 1449
*
*
*  The INTERFACE of the IShellView object
*
*
1450
**********************************************************
1451
*  IShellView_QueryInterface
Alexandre Julliard's avatar
Alexandre Julliard committed
1452
*/
1453 1454 1455
static HRESULT WINAPI IShellView_fnQueryInterface(IShellView * iface,REFIID riid, LPVOID *ppvObj)
{
	ICOM_THIS(IShellViewImpl, iface);
Alexandre Julliard's avatar
Alexandre Julliard committed
1456

1457
	TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1458 1459 1460

	*ppvObj = NULL;

1461 1462
	if(IsEqualIID(riid, &IID_IUnknown))
	{
1463
	  *ppvObj = This;
1464 1465 1466 1467 1468 1469 1470 1471
	}
	else if(IsEqualIID(riid, &IID_IShellView))
	{
	  *ppvObj = (IShellView*)This;
	}
	else if(IsEqualIID(riid, &IID_IOleCommandTarget))
	{
	  *ppvObj = (IOleCommandTarget*)&(This->lpvtblOleCommandTarget);
1472
	}
1473 1474 1475 1476
	else if(IsEqualIID(riid, &IID_IDropTarget))
	{
	  *ppvObj = (IDropTarget*)&(This->lpvtblDropTarget);
	}
1477 1478 1479 1480
	else if(IsEqualIID(riid, &IID_IDropSource))
	{
	  *ppvObj = (IDropSource*)&(This->lpvtblDropSource);
	}
1481 1482 1483
	else if(IsEqualIID(riid, &IID_IViewObject))
	{
	  *ppvObj = (IViewObject*)&(This->lpvtblViewObject);
1484 1485 1486
	}

	if(*ppvObj)
1487 1488
	{
	  IUnknown_AddRef( (IUnknown*)*ppvObj );
1489
	  TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1490 1491
	  return S_OK;
	}
1492
	TRACE("-- Interface: E_NOINTERFACE\n");
1493 1494
	return E_NOINTERFACE;
}
Alexandre Julliard's avatar
Alexandre Julliard committed
1495

1496
/**********************************************************
Juergen Schmied's avatar
Juergen Schmied committed
1497
*  IShellView_AddRef
Alexandre Julliard's avatar
Alexandre Julliard committed
1498
*/
1499 1500 1501 1502
static ULONG WINAPI IShellView_fnAddRef(IShellView * iface)
{
	ICOM_THIS(IShellViewImpl, iface);

1503
	TRACE("(%p)->(count=%lu)\n",This,This->ref);
1504 1505

	shell32_ObjCount++;
1506
	return ++(This->ref);
Alexandre Julliard's avatar
Alexandre Julliard committed
1507
}
1508
/**********************************************************
1509
*  IShellView_Release
Alexandre Julliard's avatar
Alexandre Julliard committed
1510
*/
1511 1512 1513 1514
static ULONG WINAPI IShellView_fnRelease(IShellView * iface)
{
	ICOM_THIS(IShellViewImpl, iface);

1515
	TRACE("(%p)->()\n",This);
1516 1517

	shell32_ObjCount--;
1518

1519
	if (!--(This->ref))
1520 1521
	{
	  TRACE(" destroying IShellView(%p)\n",This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1522

1523 1524
	  if(This->pSFParent)
	    IShellFolder_Release(This->pSFParent);
Alexandre Julliard's avatar
Alexandre Julliard committed
1525

1526 1527 1528
	  if(This->pSF2Parent)
	    IShellFolder2_Release(This->pSF2Parent);

1529 1530
	  if (This->apidl)
	    SHFree(This->apidl);
1531

1532 1533
	  if (This->pCommDlgBrowser)
	    ICommDlgBrowser_Release(This->pCommDlgBrowser);
1534

1535
	  HeapFree(GetProcessHeap(),0,This);
1536 1537
	  return 0;
	}
1538
	return This->ref;
Alexandre Julliard's avatar
Alexandre Julliard committed
1539
}
1540 1541

/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1542
*  ShellView_GetWindow
Alexandre Julliard's avatar
Alexandre Julliard committed
1543
*/
1544 1545 1546 1547
static HRESULT WINAPI IShellView_fnGetWindow(IShellView * iface,HWND * phWnd)
{
	ICOM_THIS(IShellViewImpl, iface);

1548
	TRACE("(%p)\n",This);
1549 1550

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

Alexandre Julliard's avatar
Alexandre Julliard committed
1552
	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
1553
}
1554 1555 1556 1557 1558

static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView * iface,BOOL fEnterMode)
{
	ICOM_THIS(IShellViewImpl, iface);

1559
	FIXME("(%p) stub\n",This);
1560 1561

	return E_NOTIMPL;
Alexandre Julliard's avatar
Alexandre Julliard committed
1562
}
1563 1564

/**********************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
1565 1566 1567 1568 1569
* IShellView_TranslateAccelerator
*
* FIXME:
*  use the accel functions
*/
1570 1571
static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg)
{
1572
#if 0
1573 1574
	ICOM_THIS(IShellViewImpl, iface);

1575
	FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1576
#endif
1577

1578 1579
	if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST))
	{
1580
	  TRACE("-- key=0x04%x\n",lpmsg->wParam) ;
1581
	}
1582
	return S_FALSE; /* not handled */
Alexandre Julliard's avatar
Alexandre Julliard committed
1583
}
1584 1585 1586 1587 1588

static HRESULT WINAPI IShellView_fnEnableModeless(IShellView * iface,BOOL fEnable)
{
	ICOM_THIS(IShellViewImpl, iface);

1589
	FIXME("(%p) stub\n",This);
1590 1591

	return E_NOTIMPL;
Alexandre Julliard's avatar
Alexandre Julliard committed
1592
}
1593 1594 1595 1596 1597

static HRESULT WINAPI IShellView_fnUIActivate(IShellView * iface,UINT uState)
{
	ICOM_THIS(IShellViewImpl, iface);

1598
/*
1599
	CHAR	szName[MAX_PATH];
1600
*/
Alexandre Julliard's avatar
Alexandre Julliard committed
1601
	LRESULT	lResult;
1602
	int	nPartArray[1] = {-1};
Alexandre Julliard's avatar
Alexandre Julliard committed
1603

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

Alexandre Julliard's avatar
Alexandre Julliard committed
1606
	/*don't do anything if the state isn't really changing*/
1607
	if(This->uState == uState)
1608 1609
	{
	  return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
1610
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
1611

Alexandre Julliard's avatar
Alexandre Julliard committed
1612
	/*OnActivate handles the menu merging and internal state*/
1613
	ShellView_OnActivate(This, uState);
Alexandre Julliard's avatar
Alexandre Julliard committed
1614

1615
	/*only do This if we are active*/
Alexandre Julliard's avatar
Alexandre Julliard committed
1616
	if(uState != SVUIA_DEACTIVATE)
1617
	{
1618

1619 1620
/*
	  GetFolderPath is not a method of IShellFolder
1621
	  IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1622
*/
Alexandre Julliard's avatar
Alexandre Julliard committed
1623
	  /* set the number of parts */
1624
	  IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1625
	  						(LPARAM)nPartArray, &lResult);
Alexandre Julliard's avatar
Alexandre Julliard committed
1626 1627

	  /* set the text for the parts */
1628
/*
1629
	  IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1630
							0, (LPARAM)szName, &lResult);
1631
*/
Alexandre Julliard's avatar
Alexandre Julliard committed
1632
	}
1633

Alexandre Julliard's avatar
Alexandre Julliard committed
1634 1635
	return S_OK;
}
1636

1637 1638 1639
static HRESULT WINAPI IShellView_fnRefresh(IShellView * iface)
{
	ICOM_THIS(IShellViewImpl, iface);
Alexandre Julliard's avatar
Alexandre Julliard committed
1640

1641
	TRACE("(%p)\n",This);
1642 1643 1644

	ListView_DeleteAllItems(This->hWndList);
	ShellView_FillList(This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1645

Alexandre Julliard's avatar
Alexandre Julliard committed
1646 1647
	return S_OK;
}
1648 1649 1650 1651 1652 1653 1654 1655

static HRESULT WINAPI IShellView_fnCreateViewWindow(
	IShellView * iface,
	IShellView *lpPrevView,
	LPCFOLDERSETTINGS lpfs,
	IShellBrowser * psb,
	RECT * prcView,
	HWND  *phWnd)
1656 1657 1658 1659
{
	ICOM_THIS(IShellViewImpl, iface);

	WNDCLASSA wc;
Alexandre Julliard's avatar
Alexandre Julliard committed
1660 1661
	*phWnd = 0;

1662

1663 1664
	TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This, lpPrevView,lpfs, psb, prcView, phWnd);
	TRACE("-- vmode=%x flags=%x left=%i top=%i right=%i bottom=%i\n",lpfs->ViewMode, lpfs->fFlags ,prcView->left,prcView->top, prcView->right, prcView->bottom);
Alexandre Julliard's avatar
Alexandre Julliard committed
1665 1666

	/*set up the member variables*/
1667 1668
	This->pShellBrowser = psb;
	This->FolderSettings = *lpfs;
Alexandre Julliard's avatar
Alexandre Julliard committed
1669 1670

	/*get our parent window*/
1671 1672
	IShellBrowser_AddRef(This->pShellBrowser);
	IShellBrowser_GetWindow(This->pShellBrowser, &(This->hWndParent));
Alexandre Julliard's avatar
Alexandre Julliard committed
1673

1674
	/* try to get the ICommDlgBrowserInterface, adds a reference !!! */
1675
	This->pCommDlgBrowser=NULL;
1676
	if ( SUCCEEDED (IShellBrowser_QueryInterface( This->pShellBrowser,
1677
			(REFIID)&IID_ICommDlgBrowser, (LPVOID*) &This->pCommDlgBrowser)))
1678 1679
	{
	  TRACE("-- CommDlgBrowser\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
1680
	}
1681

Alexandre Julliard's avatar
Alexandre Julliard committed
1682
	/*if our window class has not been registered, then do so*/
1683
	if(!GetClassInfoA(shell32_hInstance, SV_CLASS_NAME, &wc))
1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695
	{
	  ZeroMemory(&wc, sizeof(wc));
	  wc.style		= CS_HREDRAW | CS_VREDRAW;
	  wc.lpfnWndProc	= (WNDPROC) ShellView_WndProc;
	  wc.cbClsExtra		= 0;
	  wc.cbWndExtra		= 0;
	  wc.hInstance		= shell32_hInstance;
	  wc.hIcon		= 0;
	  wc.hCursor		= LoadCursorA (0, IDC_ARROWA);
	  wc.hbrBackground	= (HBRUSH) (COLOR_WINDOW + 1);
	  wc.lpszMenuName	= NULL;
	  wc.lpszClassName	= SV_CLASS_NAME;
1696

1697
	  if(!RegisterClassA(&wc))
Alexandre Julliard's avatar
Alexandre Julliard committed
1698 1699
	    return E_FAIL;
	}
Alexandre Julliard's avatar
Alexandre Julliard committed
1700

1701 1702 1703
	*phWnd = CreateWindowExA(0,
				SV_CLASS_NAME,
				NULL,
1704
				WS_CHILD | WS_VISIBLE | WS_TABSTOP,
1705 1706 1707 1708 1709 1710 1711 1712 1713 1714
				prcView->left,
				prcView->top,
				prcView->right - prcView->left,
				prcView->bottom - prcView->top,
				This->hWndParent,
				0,
				shell32_hInstance,
				(LPVOID)This);

	CheckToolbar(This);
1715

1716
	if(!*phWnd) return E_FAIL;
Alexandre Julliard's avatar
Alexandre Julliard committed
1717

Alexandre Julliard's avatar
Alexandre Julliard committed
1718
	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
1719 1720
}

1721 1722 1723 1724
static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView * iface)
{
	ICOM_THIS(IShellViewImpl, iface);

1725
	TRACE("(%p)\n",This);
Alexandre Julliard's avatar
Alexandre Julliard committed
1726 1727

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

1730
	if(This->hMenu)
1731 1732
	{
	  DestroyMenu(This->hMenu);
Alexandre Julliard's avatar
Alexandre Julliard committed
1733
	}
1734

1735 1736
	DestroyWindow(This->hWnd);
	IShellBrowser_Release(This->pShellBrowser);
1737

Alexandre Julliard's avatar
Alexandre Julliard committed
1738 1739
	return S_OK;
}
1740 1741 1742 1743 1744

static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView * iface, LPFOLDERSETTINGS lpfs)
{
	ICOM_THIS(IShellViewImpl, iface);

1745
	TRACE("(%p)->(%p) vmode=%x flags=%x\n",This, lpfs,
1746 1747
		This->FolderSettings.ViewMode, This->FolderSettings.fFlags);

1748 1749 1750 1751
	if (!lpfs) return E_INVALIDARG;

	*lpfs = This->FolderSettings;
	return NOERROR;
Alexandre Julliard's avatar
Alexandre Julliard committed
1752
}
1753 1754 1755 1756 1757

static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView * iface, DWORD dwReserved,LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
{
	ICOM_THIS(IShellViewImpl, iface);

1758
	FIXME("(%p) stub\n",This);
1759 1760

	return E_NOTIMPL;
Alexandre Julliard's avatar
Alexandre Julliard committed
1761
}
1762 1763 1764 1765 1766

static HRESULT WINAPI IShellView_fnSaveViewState(IShellView * iface)
{
	ICOM_THIS(IShellViewImpl, iface);

1767
	FIXME("(%p) stub\n",This);
1768 1769

	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
1770
}
1771

1772 1773 1774 1775 1776 1777 1778
static HRESULT WINAPI IShellView_fnSelectItem(
	IShellView * iface,
	LPCITEMIDLIST pidl,
	UINT uFlags)
{
	ICOM_THIS(IShellViewImpl, iface);
	int i;
1779

1780
	TRACE("(%p)->(pidl=%p, 0x%08x) stub\n",This, pidl, uFlags);
1781

1782
	i = LV_FindItemByPidl(This, pidl);
1783

1784 1785 1786
	if (i != -1)
	{
	  LVITEMA lvItem;
1787

1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821
	  if(uFlags & SVSI_ENSUREVISIBLE)
	    ListView_EnsureVisible(This->hWndList, i, 0);

          ZeroMemory(&lvItem, sizeof(LVITEMA));
	  lvItem.mask = LVIF_STATE;
	  lvItem.iItem = 0;

          while(ListView_GetItemA(This->hWndList, &lvItem))
	  {
	    if (lvItem.iItem == i)
	    {
	      if (uFlags & SVSI_SELECT)
	        lvItem.state |= LVIS_SELECTED;
	      else
		lvItem.state &= ~LVIS_SELECTED;

	      if(uFlags & SVSI_FOCUSED)
	        lvItem.state &= ~LVIS_FOCUSED;
	    }
	    else
	    {
	      if (uFlags & SVSI_DESELECTOTHERS)
	        lvItem.state &= ~LVIS_SELECTED;
	    }
	    ListView_SetItemA(This->hWndList, &lvItem);
	    lvItem.iItem++;
	  }


	  if(uFlags & SVSI_EDIT)
	    ListView_EditLabelA(This->hWndList, i);

	}
	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
1822
}
1823 1824 1825 1826 1827

static HRESULT WINAPI IShellView_fnGetItemObject(IShellView * iface, UINT uItem, REFIID riid, LPVOID *ppvOut)
{
	ICOM_THIS(IShellViewImpl, iface);

1828
	TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This, uItem, debugstr_guid(riid), ppvOut);
Alexandre Julliard's avatar
Alexandre Julliard committed
1829

1830
	*ppvOut = NULL;
1831 1832 1833 1834

	switch(uItem)
	{
	  case SVGIO_BACKGROUND:
1835
	    *ppvOut = ISvBgCm_Constructor(This->pSFParent);
1836 1837 1838 1839 1840 1841
	    break;

	  case SVGIO_SELECTION:
	    ShellView_GetSelections(This);
	    IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, riid, 0, ppvOut);
	    break;
1842
	}
1843
	TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut);
Alexandre Julliard's avatar
Alexandre Julliard committed
1844

1845
	if(!*ppvOut) return E_OUTOFMEMORY;
1846

1847
	return S_OK;
Alexandre Julliard's avatar
Alexandre Julliard committed
1848
}
1849

1850 1851 1852 1853 1854 1855
static HRESULT WINAPI IShellView_fnEditItem(
	IShellView * iface,
	LPITEMIDLIST pidl)
{
	ICOM_THIS(IShellViewImpl, iface);
	int i;
1856

1857
	TRACE("(%p)->(pidl=%p)\n",This, pidl);
1858

1859
	i = LV_FindItemByPidl(This, pidl);
1860 1861 1862 1863 1864 1865 1866 1867
	if (i != -1)
	{
	  SetFocus(This->hWndList);
	  ListView_EditLabelA(This->hWndList, i);
	}
	return S_OK;
}

1868 1869
static struct ICOM_VTABLE(IShellView) svvt =
{
1870 1871
	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
	IShellView_fnQueryInterface,
1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885
	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,
1886 1887
	IShellView_fnGetItemObject,
	IShellView_fnEditItem
1888 1889
};

1890

1891
/**********************************************************
1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903
 * ISVOleCmdTarget_QueryInterface (IUnknown)
 */
static HRESULT WINAPI ISVOleCmdTarget_QueryInterface(
	IOleCommandTarget *	iface,
	REFIID			iid,
	LPVOID*			ppvObj)
{
	_ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);

	return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj);
}

1904
/**********************************************************
1905 1906 1907 1908 1909 1910 1911 1912 1913 1914
 * ISVOleCmdTarget_AddRef (IUnknown)
 */
static ULONG WINAPI ISVOleCmdTarget_AddRef(
	IOleCommandTarget *	iface)
{
	_ICOM_THIS_From_IOleCommandTarget(IShellFolder, iface);

	return IShellFolder_AddRef((IShellFolder*)This);
}

1915
/**********************************************************
1916 1917 1918 1919 1920 1921 1922 1923 1924 1925
 * ISVOleCmdTarget_Release (IUnknown)
 */
static ULONG WINAPI ISVOleCmdTarget_Release(
	IOleCommandTarget *	iface)
{
	_ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);

	return IShellFolder_Release((IShellFolder*)This);
}

1926
/**********************************************************
Juergen Schmied's avatar
Juergen Schmied committed
1927
 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
1928 1929 1930 1931
 */
static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
	IOleCommandTarget *iface,
	const GUID* pguidCmdGroup,
1932
	ULONG cCmds,
1933 1934 1935 1936 1937
	OLECMD * prgCmds,
	OLECMDTEXT* pCmdText)
{
	_ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);

1938 1939
	FIXME("(%p)->(%p(%s) 0x%08lx %p %p\n",
              This, pguidCmdGroup, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
1940 1941 1942
	return E_NOTIMPL;
}

1943
/**********************************************************
1944
 * ISVOleCmdTarget_Exec (IOleCommandTarget)
Juergen Schmied's avatar
Juergen Schmied committed
1945 1946
 *
 * nCmdID is the OLECMDID_* enumeration
1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957
 */
static HRESULT WINAPI ISVOleCmdTarget_Exec(
	IOleCommandTarget *iface,
	const GUID* pguidCmdGroup,
	DWORD nCmdID,
	DWORD nCmdexecopt,
	VARIANT* pvaIn,
	VARIANT* pvaOut)
{
	_ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);

1958 1959
	FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08lx Opt:0x%08lx %p %p)\n",
              This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, pvaIn, pvaOut);
1960 1961 1962
	return E_NOTIMPL;
}

1963
static ICOM_VTABLE(IOleCommandTarget) ctvt =
1964
{
1965
	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1966 1967 1968 1969 1970 1971 1972
	ISVOleCmdTarget_QueryInterface,
	ISVOleCmdTarget_AddRef,
	ISVOleCmdTarget_Release,
	ISVOleCmdTarget_QueryStatus,
	ISVOleCmdTarget_Exec
};

1973
/**********************************************************
1974 1975 1976 1977 1978 1979 1980 1981 1982 1983
 * ISVDropTarget implementation
 */

static HRESULT WINAPI ISVDropTarget_QueryInterface(
	IDropTarget *iface,
	REFIID riid,
	LPVOID *ppvObj)
{
	_ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);

1984
	TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1985 1986 1987 1988 1989 1990 1991 1992

	return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
}

static ULONG WINAPI ISVDropTarget_AddRef( IDropTarget *iface)
{
	_ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);

1993
	TRACE("(%p)->(count=%lu)\n",This,This->ref);
1994 1995 1996 1997 1998 1999 2000 2001

	return IShellFolder_AddRef((IShellFolder*)This);
}

static ULONG WINAPI ISVDropTarget_Release( IDropTarget *iface)
{
	_ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);

2002
	TRACE("(%p)->(count=%lu)\n",This,This->ref);
2003 2004 2005 2006 2007 2008 2009 2010 2011 2012

	return IShellFolder_Release((IShellFolder*)This);
}

static HRESULT WINAPI ISVDropTarget_DragEnter(
	IDropTarget 	*iface,
	IDataObject	*pDataObject,
	DWORD		grfKeyState,
	POINTL		pt,
	DWORD		*pdwEffect)
2013
{
2014 2015 2016

	_ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);

2017
	FIXME("Stub: This=%p, DataObject=%p\n",This,pDataObject);
2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029

	return E_NOTIMPL;
}

static HRESULT WINAPI ISVDropTarget_DragOver(
	IDropTarget	*iface,
	DWORD		grfKeyState,
	POINTL		pt,
	DWORD		*pdwEffect)
{
	_ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);

2030
	FIXME("Stub: This=%p\n",This);
2031 2032 2033 2034 2035 2036 2037 2038 2039

	return E_NOTIMPL;
}

static HRESULT WINAPI ISVDropTarget_DragLeave(
	IDropTarget	*iface)
{
	_ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);

2040
	FIXME("Stub: This=%p\n",This);
2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053

	return E_NOTIMPL;
}

static HRESULT WINAPI ISVDropTarget_Drop(
	IDropTarget	*iface,
	IDataObject*	pDataObject,
	DWORD		grfKeyState,
	POINTL		pt,
	DWORD		*pdwEffect)
{
	_ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);

2054
	FIXME("Stub: This=%p\n",This);
2055 2056 2057 2058

	return E_NOTIMPL;
}

2059
static struct ICOM_VTABLE(IDropTarget) dtvt =
2060
{
2061
	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2062 2063 2064 2065 2066 2067 2068 2069 2070
	ISVDropTarget_QueryInterface,
	ISVDropTarget_AddRef,
	ISVDropTarget_Release,
	ISVDropTarget_DragEnter,
	ISVDropTarget_DragOver,
	ISVDropTarget_DragLeave,
	ISVDropTarget_Drop
};

2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081
/**********************************************************
 * ISVDropSource implementation
 */

static HRESULT WINAPI ISVDropSource_QueryInterface(
	IDropSource *iface,
	REFIID riid,
	LPVOID *ppvObj)
{
	_ICOM_THIS_From_IDropSource(IShellViewImpl, iface);

2082
	TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 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 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138

	return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
}

static ULONG WINAPI ISVDropSource_AddRef( IDropSource *iface)
{
	_ICOM_THIS_From_IDropSource(IShellViewImpl, iface);

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

	return IShellFolder_AddRef((IShellFolder*)This);
}

static ULONG WINAPI ISVDropSource_Release( IDropSource *iface)
{
	_ICOM_THIS_From_IDropSource(IShellViewImpl, iface);

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

	return IShellFolder_Release((IShellFolder*)This);
}
static HRESULT WINAPI ISVDropSource_QueryContinueDrag(
	IDropSource *iface,
	BOOL fEscapePressed,
	DWORD grfKeyState)
{
	_ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
	TRACE("(%p)\n",This);

	if (fEscapePressed)
	  return DRAGDROP_S_CANCEL;
	else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
	  return DRAGDROP_S_DROP;
	else
	  return NOERROR;
}

static HRESULT WINAPI ISVDropSource_GiveFeedback(
	IDropSource *iface,
	DWORD dwEffect)
{
	_ICOM_THIS_From_IDropSource(IShellViewImpl, iface);
	TRACE("(%p)\n",This);

	return DRAGDROP_S_USEDEFAULTCURSORS;
}

static struct ICOM_VTABLE(IDropSource) dsvt =
{
	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
	ISVDropSource_QueryInterface,
	ISVDropSource_AddRef,
	ISVDropSource_Release,
	ISVDropSource_QueryContinueDrag,
	ISVDropSource_GiveFeedback
};
2139
/**********************************************************
2140 2141 2142 2143 2144 2145 2146 2147 2148 2149
 * ISVViewObject implementation
 */

static HRESULT WINAPI ISVViewObject_QueryInterface(
	IViewObject *iface,
	REFIID riid,
	LPVOID *ppvObj)
{
	_ICOM_THIS_From_IViewObject(IShellViewImpl, iface);

2150
	TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
2151 2152 2153 2154 2155 2156 2157 2158

	return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
}

static ULONG WINAPI ISVViewObject_AddRef( IViewObject *iface)
{
	_ICOM_THIS_From_IViewObject(IShellViewImpl, iface);

2159
	TRACE("(%p)->(count=%lu)\n",This,This->ref);
2160 2161 2162 2163 2164 2165 2166 2167

	return IShellFolder_AddRef((IShellFolder*)This);
}

static ULONG WINAPI ISVViewObject_Release( IViewObject *iface)
{
	_ICOM_THIS_From_IViewObject(IShellViewImpl, iface);

2168
	TRACE("(%p)->(count=%lu)\n",This,This->ref);
2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181

	return IShellFolder_Release((IShellFolder*)This);
}

static HRESULT WINAPI ISVViewObject_Draw(
	IViewObject 	*iface,
	DWORD dwDrawAspect,
	LONG lindex,
	void* pvAspect,
	DVTARGETDEVICE* ptd,
	HDC hdcTargetDev,
	HDC hdcDraw,
	LPCRECTL lprcBounds,
2182
	LPCRECTL lprcWBounds,
2183
	IVO_ContCallback pfnContinue,
2184
	DWORD dwContinue)
2185
{
2186 2187 2188

	_ICOM_THIS_From_IViewObject(IShellViewImpl, iface);

2189
	FIXME("Stub: This=%p\n",This);
2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200

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

	_ICOM_THIS_From_IViewObject(IShellViewImpl, iface);

2205
	FIXME("Stub: This=%p\n",This);
2206 2207 2208 2209 2210 2211 2212 2213 2214

	return E_NOTIMPL;
}
static HRESULT WINAPI ISVViewObject_Freeze(
	IViewObject 	*iface,
	DWORD dwDrawAspect,
	LONG lindex,
	void* pvAspect,
	DWORD* pdwFreeze)
2215
{
2216 2217 2218

	_ICOM_THIS_From_IViewObject(IShellViewImpl, iface);

2219
	FIXME("Stub: This=%p\n",This);
2220 2221 2222 2223 2224 2225

	return E_NOTIMPL;
}
static HRESULT WINAPI ISVViewObject_Unfreeze(
	IViewObject 	*iface,
	DWORD dwFreeze)
2226
{
2227 2228 2229

	_ICOM_THIS_From_IViewObject(IShellViewImpl, iface);

2230
	FIXME("Stub: This=%p\n",This);
2231 2232 2233 2234 2235 2236 2237 2238

	return E_NOTIMPL;
}
static HRESULT WINAPI ISVViewObject_SetAdvise(
	IViewObject 	*iface,
	DWORD aspects,
	DWORD advf,
	IAdviseSink* pAdvSink)
2239
{
2240 2241 2242

	_ICOM_THIS_From_IViewObject(IShellViewImpl, iface);

2243
	FIXME("Stub: This=%p\n",This);
2244 2245 2246 2247 2248 2249 2250 2251

	return E_NOTIMPL;
}
static HRESULT WINAPI ISVViewObject_GetAdvise(
	IViewObject 	*iface,
	DWORD* pAspects,
	DWORD* pAdvf,
	IAdviseSink** ppAdvSink)
2252
{
2253 2254 2255

	_ICOM_THIS_From_IViewObject(IShellViewImpl, iface);

2256
	FIXME("Stub: This=%p\n",This);
2257 2258 2259 2260 2261

	return E_NOTIMPL;
}


2262
static struct ICOM_VTABLE(IViewObject) vovt =
2263
{
2264
	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275
	ISVViewObject_QueryInterface,
	ISVViewObject_AddRef,
	ISVViewObject_Release,
	ISVViewObject_Draw,
	ISVViewObject_GetColorSet,
	ISVViewObject_Freeze,
	ISVViewObject_Unfreeze,
	ISVViewObject_SetAdvise,
	ISVViewObject_GetAdvise
};