- more checks for valid pidl formats
[wine] / dlls / shell32 / shlview.c
1 /*
2  *      ShellView
3  *
4  *      Copyright 1998  <juergen.schmied@metronet.de>
5  *
6  *  FIXME: when the ShellView_WndProc gets a WM_NCDESTROY should we do a
7  *  Release() ??? 
8  *
9  */
10
11 #include <stdlib.h>
12 #include <string.h>
13
14 #include "servprov.h"
15 #include "wine/obj_base.h"
16 #include "wine/obj_shellfolder.h"
17 #include "wine/obj_shellview.h"
18 #include "wine/obj_commdlgbrowser.h"
19 #include "wine/obj_shellbrowser.h"
20 #include "wine/obj_dockingwindowframe.h"
21 #include "wine/obj_extracticon.h"
22
23 #include "shresdef.h"
24 #include "spy.h"
25 #include "debug.h"
26 #include "winerror.h"
27
28 #include "docobj.h"
29 #include "pidl.h"
30 #include "shell32_main.h"
31
32 DEFAULT_DEBUG_CHANNEL(shell)
33
34 typedef struct 
35 {       ICOM_VTABLE(IShellView)* lpvtbl;
36         DWORD           ref;
37         ICOM_VTABLE(IOleCommandTarget)* lpvtblOleCommandTarget;
38         ICOM_VTABLE(IDropTarget)*       lpvtblDropTarget;
39         ICOM_VTABLE(IViewObject)*       lpvtblViewObject;
40         IShellFolder*   pSFParent;
41         IShellBrowser*  pShellBrowser;
42         ICommDlgBrowser*        pCommDlgBrowser;
43         HWND            hWnd;
44         HWND            hWndList;
45         HWND            hWndParent;
46         FOLDERSETTINGS  FolderSettings;
47         HMENU           hMenu;
48         UINT            uState;
49         UINT            uSelected;
50         LPITEMIDLIST    *aSelectedItems;
51 } IShellViewImpl;
52
53 static struct ICOM_VTABLE(IShellView) svvt;
54
55 static struct ICOM_VTABLE(IOleCommandTarget) ctvt;
56 #define _IOleCommandTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblOleCommandTarget))) 
57 #define _ICOM_THIS_From_IOleCommandTarget(class, name) class* This = (class*)(((void*)name)-_IOleCommandTarget_Offset); 
58
59 static struct ICOM_VTABLE(IDropTarget) dtvt;
60 #define _IDropTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropTarget))) 
61 #define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((void*)name)-_IDropTarget_Offset); 
62
63 static struct ICOM_VTABLE(IViewObject) vovt;
64 #define _IViewObject_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblViewObject))) 
65 #define _ICOM_THIS_From_IViewObject(class, name) class* This = (class*)(((void*)name)-_IViewObject_Offset); 
66
67 /*menu items */
68 #define IDM_VIEW_FILES  (FCIDM_SHVIEWFIRST + 0x500)
69 #define IDM_VIEW_IDW    (FCIDM_SHVIEWFIRST + 0x501)
70 #define IDM_MYFILEITEM  (FCIDM_SHVIEWFIRST + 0x502)
71
72 #define ID_LISTVIEW     2000
73
74 #define MENU_OFFSET  1
75 #define MENU_MAX     100
76
77 #define TOOLBAR_ID   (L"SHELLDLL_DefView")
78 /*windowsx.h */
79 #define GET_WM_COMMAND_ID(wp, lp)               LOWORD(wp)
80 #define GET_WM_COMMAND_HWND(wp, lp)             (HWND)(lp)
81 #define GET_WM_COMMAND_CMD(wp, lp)              HIWORD(wp)
82 /* winuser.h */
83 #define WM_SETTINGCHANGE                WM_WININICHANGE
84 extern void WINAPI _InsertMenuItem (HMENU hmenu, UINT indexMenu, BOOL fByPosition, 
85                         UINT wID, UINT fType, LPSTR dwTypeData, UINT fState);
86
87 typedef struct
88 {  int   idCommand;
89    int   iImage;
90    int   idButtonString;
91    int   idMenuString;
92    int   nStringOffset;
93    BYTE  bState;
94    BYTE  bStyle;
95 } MYTOOLINFO, *LPMYTOOLINFO;
96
97 extern  LPCVOID _Resource_Men_MENU_001_0_data;
98 extern  LPCVOID _Resource_Men_MENU_002_0_data;
99
100 MYTOOLINFO g_Tools[] = 
101 { {IDM_VIEW_FILES, 0, IDS_TB_VIEW_FILES, IDS_MI_VIEW_FILES, 0, TBSTATE_ENABLED, TBSTYLE_BUTTON},
102   {-1, 0, 0, 0, 0, 0, 0}   
103 };
104 BOOL g_bViewKeys;
105 BOOL g_bShowIDW;
106
107 typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
108
109 /**************************************************************************
110 *  IShellView_Constructor
111 */
112 IShellView * IShellView_Constructor( IShellFolder * pFolder, LPCITEMIDLIST pidl)
113 {       IShellViewImpl * sv;
114         sv=(IShellViewImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IShellViewImpl));
115         sv->ref=1;
116         sv->lpvtbl=&svvt;
117         sv->lpvtblOleCommandTarget=&ctvt;
118         sv->lpvtblDropTarget=&dtvt;
119         sv->lpvtblViewObject=&vovt;
120
121         sv->hMenu       = 0;
122         sv->pSFParent   = pFolder;
123         sv->uSelected = 0;
124         sv->aSelectedItems = NULL;
125
126         if(pFolder)
127           IShellFolder_AddRef(pFolder);
128
129         TRACE(shell,"(%p)->(%p pidl=%p)\n",sv, pFolder, pidl);
130         shell32_ObjCount++;
131         return (IShellView *) sv;
132 }
133 /**************************************************************************
134 *  helperfunctions for communication with ICommDlgBrowser
135 *
136 */
137 static BOOL IsInCommDlg(IShellViewImpl * This)
138 {       return(This->pCommDlgBrowser != NULL);
139 }
140 static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl)
141 {
142         if ( IsInCommDlg(This) )
143         { TRACE(shell,"ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
144           return (ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView*)This, pidl));
145         }
146         return S_OK;
147 }
148
149 static HRESULT OnDefaultCommand(IShellViewImpl * This)
150 {
151         if (IsInCommDlg(This))
152         { TRACE(shell,"ICommDlgBrowser::OnDefaultCommand\n");
153           return (ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView*)This));
154         }
155         return S_FALSE;
156 }
157
158 static HRESULT OnStateChange(IShellViewImpl * This, UINT uFlags)
159 {
160         if (IsInCommDlg(This))
161         { TRACE(shell,"ICommDlgBrowser::OnStateChange flags=%x\n", uFlags);
162           return (ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView*)This, uFlags));
163         }
164         return S_FALSE;
165 }
166 static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove)
167 {       DWORD tmpstyle;
168
169         TRACE(shell,"(%p)\n", This);
170
171         tmpstyle = GetWindowLongA(This->hWndList, GWL_STYLE);
172         SetWindowLongA(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove));
173 }
174
175 static void CheckToolbar(IShellViewImpl * This)
176 {       LRESULT result;
177
178         TRACE(shell,"\n");
179         
180         IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
181                 FCIDM_TB_SMALLICON, (This->FolderSettings.ViewMode==FVM_LIST)? TRUE : FALSE, &result);
182         IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON,
183                 FCIDM_TB_REPORTVIEW, (This->FolderSettings.ViewMode==FVM_DETAILS)? TRUE : FALSE, &result);
184         IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
185                 FCIDM_TB_SMALLICON, TRUE, &result);
186         IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON,
187                 FCIDM_TB_REPORTVIEW, TRUE, &result);
188         TRACE(shell,"--\n");
189 }
190
191 static void MergeToolBar(IShellViewImpl * This)
192 {       LRESULT iStdBMOffset;
193         LRESULT iViewBMOffset;
194         TBADDBITMAP ab;
195         TBBUTTON tbActual[6];
196         int i;
197         enum
198         { IN_STD_BMP = 0x4000,
199           IN_VIEW_BMP = 0x8000,
200         } ;
201         static const TBBUTTON c_tbDefault[] =
202         { { STD_COPY | IN_STD_BMP, FCIDM_SHVIEW_COPY, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, -1},
203           { 0,  0,      TBSTATE_ENABLED, TBSTYLE_SEP, {0,0}, 0, -1 },
204           { VIEW_LARGEICONS | IN_VIEW_BMP, FCIDM_SHVIEW_BIGICON,        TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0L, -1 },
205           { VIEW_SMALLICONS | IN_VIEW_BMP, FCIDM_SHVIEW_SMALLICON,      TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0L, -1 },
206           { VIEW_LIST       | IN_VIEW_BMP, FCIDM_SHVIEW_LISTVIEW,       TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0L, -1 },
207           { VIEW_DETAILS    | IN_VIEW_BMP, FCIDM_SHVIEW_REPORTVIEW,     TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0L, -1 },
208         } ;
209
210         TRACE(shell,"\n");
211
212         ab.hInst = HINST_COMMCTRL;              /* hinstCommctrl */
213         ab.nID   = IDB_STD_SMALL_COLOR; /* std bitmaps */
214         IShellBrowser_SendControlMsg(This->pShellBrowser,FCW_TOOLBAR,
215                                  TB_ADDBITMAP, 8, (LPARAM)&ab, &iStdBMOffset);
216
217         TRACE(shell,"TB_ADDBITMAP returns %lx\n", iStdBMOffset);
218
219         ab.nID   = IDB_VIEW_SMALL_COLOR;        /* std view bitmaps */
220         IShellBrowser_SendControlMsg(This->pShellBrowser,FCW_TOOLBAR,
221                                  TB_ADDBITMAP, 8, (LPARAM)&ab, &iViewBMOffset);
222
223         TRACE(shell,"TB_ADDBITMAP returns %lx\n", iViewBMOffset);
224
225         for (i=0; i<6; ++i)
226         { tbActual[i] = c_tbDefault[i];
227           if (!(tbActual[i].fsStyle & TBSTYLE_SEP))
228           { if (tbActual[i].iBitmap & IN_VIEW_BMP)
229             { tbActual[i].iBitmap = (tbActual[i].iBitmap & ~IN_VIEW_BMP) + iViewBMOffset;
230             }
231             else if (tbActual[i].iBitmap & IN_STD_BMP)
232             { tbActual[i].iBitmap = (tbActual[i].iBitmap & ~IN_STD_BMP) + iStdBMOffset;
233             }
234           }
235         }
236
237         IShellBrowser_SetToolbarItems(This->pShellBrowser,tbActual, 6, FCT_MERGE);
238
239         CheckToolbar(This);
240         TRACE(shell,"--\n");
241
242 }
243
244 /**************************************************************************
245 * ShellView_CreateList()
246 *
247 */
248
249 BOOL ShellView_CreateList (IShellViewImpl * This)
250 {       DWORD dwStyle;
251
252         TRACE(shell,"%p\n",This);
253
254         dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILD | WS_BORDER |
255                   LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT;
256         switch (This->FolderSettings.ViewMode)
257         { case FVM_ICON:        dwStyle |= LVS_ICON;            break;
258           case FVM_DETAILS:     dwStyle |= LVS_REPORT;          break;
259           case FVM_SMALLICON:   dwStyle |= LVS_SMALLICON;       break;
260           case FVM_LIST:        dwStyle |= LVS_LIST;            break;
261           default:              dwStyle |= LVS_LIST;            break;
262         }
263         if (This->FolderSettings.fFlags && FWF_AUTOARRANGE)     dwStyle |= LVS_AUTOARRANGE;
264         /*if (This->FolderSettings.fFlags && FWF_DESKTOP); used from explorer*/
265         if (This->FolderSettings.fFlags && FWF_SINGLESEL)       dwStyle |= LVS_SINGLESEL;
266
267         This->hWndList=CreateWindowExA( WS_EX_CLIENTEDGE,
268                                           WC_LISTVIEWA,
269                                           NULL,
270                                           dwStyle,
271                                           0,0,0,0,
272                                           This->hWnd,
273                                           (HMENU)ID_LISTVIEW,
274                                           shell32_hInstance,
275                                           NULL);
276
277         if(!This->hWndList)
278           return FALSE;
279
280         /*  UpdateShellSettings(); */
281         return TRUE;
282 }
283 /**************************************************************************
284 * ShellView_InitList()
285 *
286 * NOTES
287 *  internal
288 */
289 int  nColumn1=120; /* width of column */
290 int  nColumn2=80;
291 int  nColumn3=170;
292 int  nColumn4=60;
293
294 BOOL ShellView_InitList(IShellViewImpl * This)
295 {       LVCOLUMNA lvColumn;
296         CHAR        szString[50];
297
298         TRACE(shell,"%p\n",This);
299
300         ListView_DeleteAllItems(This->hWndList);
301
302         /*initialize the columns */
303         lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;      /*  |  LVCF_SUBITEM;*/
304         lvColumn.fmt = LVCFMT_LEFT;
305         lvColumn.pszText = szString;
306
307         lvColumn.cx = nColumn1;
308         strcpy(szString,"File");
309         /*LoadStringA(shell32_hInstance, IDS_COLUMN1, szString, sizeof(szString));*/
310         ListView_InsertColumnA(This->hWndList, 0, &lvColumn);
311
312         lvColumn.cx = nColumn2;
313         strcpy(szString,"Size");
314         ListView_InsertColumnA(This->hWndList, 1, &lvColumn);
315
316         lvColumn.cx = nColumn3;
317         strcpy(szString,"Type");
318         ListView_InsertColumnA(This->hWndList, 2, &lvColumn);
319
320         lvColumn.cx = nColumn4;
321         strcpy(szString,"Modified");
322         ListView_InsertColumnA(This->hWndList, 3, &lvColumn);
323
324         ListView_SetImageList(This->hWndList, ShellSmallIconList, LVSIL_SMALL);
325         ListView_SetImageList(This->hWndList, ShellBigIconList, LVSIL_NORMAL);
326   
327         return TRUE;
328 }
329 /**************************************************************************
330 * ShellView_CompareItems() 
331 *
332 * NOTES
333 *  internal, CALLBACK for DSA_Sort
334 */   
335 INT CALLBACK ShellView_CompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData)
336 {       int ret;
337         TRACE(shell,"pidl1=%p pidl2=%p lpsf=%p\n", lParam1, lParam2, (LPVOID) lpData);
338
339         if(!lpData)
340           return 0;
341           
342         ret =  (int)((LPSHELLFOLDER)lpData)->lpvtbl->fnCompareIDs((LPSHELLFOLDER)lpData, 0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2);  
343         TRACE(shell,"ret=%i\n",ret);
344         return ret;
345 }
346
347 /**************************************************************************
348 * ShellView_FillList()
349 *
350 * NOTES
351 *  internal
352 */   
353
354 static HRESULT ShellView_FillList(IShellViewImpl * This)
355 {       LPENUMIDLIST    pEnumIDList;
356         LPITEMIDLIST    pidl;
357         DWORD           dwFetched;
358         UINT            i;
359         LVITEMA lvItem;
360         HRESULT         hRes;
361         HDPA            hdpa;
362
363         TRACE(shell,"%p\n",This);
364
365         /* get the itemlist from the shfolder*/  
366         hRes = IShellFolder_EnumObjects(This->pSFParent,This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList);
367         if (hRes != S_OK)
368         { if (hRes==S_FALSE)
369             return(NOERROR);
370           return(hRes);
371         }
372
373         /* create a pointer array */    
374         hdpa = pDPA_Create(16);
375         if (!hdpa)
376         { return(E_OUTOFMEMORY);
377         }
378
379         /* copy the items into the array*/
380         while((S_OK == IEnumIDList_Next(pEnumIDList,1, &pidl, &dwFetched)) && dwFetched)
381         { if (pDPA_InsertPtr(hdpa, 0x7fff, pidl) == -1)
382           { SHFree(pidl);
383           } 
384         }
385
386         /*sort the array*/
387         pDPA_Sort(hdpa, ShellView_CompareItems, (LPARAM)This->pSFParent);
388
389         /*turn the listview's redrawing off*/
390         SendMessageA(This->hWndList, WM_SETREDRAW, FALSE, 0); 
391
392         for (i=0; i < DPA_GetPtrCount(hdpa); ++i)       /* DPA_GetPtrCount is a macro*/
393         { pidl = (LPITEMIDLIST)DPA_GetPtr(hdpa, i);
394           if (IncludeObject(This, pidl) == S_OK)        /* in a commdlg This works as a filemask*/
395           { ZeroMemory(&lvItem, sizeof(lvItem));        /* create the listviewitem*/
396             lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;          /*set the mask*/
397             lvItem.iItem = ListView_GetItemCount(This->hWndList);       /*add the item to the end of the list*/
398             lvItem.lParam = (LPARAM) pidl;                              /*set the item's data*/
399             lvItem.pszText = LPSTR_TEXTCALLBACKA;                       /*get text on a callback basis*/
400             lvItem.iImage = I_IMAGECALLBACK;                            /*get the image on a callback basis*/
401             ListView_InsertItemA(This->hWndList, &lvItem);
402           }
403           else
404             SHFree(pidl);       /* the listview has the COPY*/
405         }
406
407         /*turn the listview's redrawing back on and force it to draw*/
408         SendMessageA(This->hWndList, WM_SETREDRAW, TRUE, 0);
409         InvalidateRect(This->hWndList, NULL, TRUE);
410         UpdateWindow(This->hWndList);
411
412         IEnumIDList_Release(pEnumIDList); /* destroy the list*/
413         pDPA_Destroy(hdpa);
414         
415         return S_OK;
416 }
417
418 /**************************************************************************
419 *  ShellView_OnCreate()
420 *
421 * NOTES
422 *  internal
423 */   
424 LRESULT ShellView_OnCreate(IShellViewImpl * This)
425 { TRACE(shell,"%p\n",This);
426
427   if(ShellView_CreateList(This))
428   {  if(ShellView_InitList(This))
429      { ShellView_FillList(This);
430      }
431   }
432
433   return S_OK;
434 }
435 /**************************************************************************
436 *  ShellView_OnSize()
437 */   
438 LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight)
439 {       TRACE(shell,"%p width=%u height=%u\n",This, wWidth,wHeight);
440
441         /*resize the ListView to fit our window*/
442         if(This->hWndList)
443         { MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE);
444         }
445
446         return S_OK;
447 }
448 /**************************************************************************
449 * ShellView_BuildFileMenu()
450 */   
451 HMENU ShellView_BuildFileMenu(IShellViewImpl * This)
452 {       CHAR    szText[MAX_PATH];
453         MENUITEMINFOA   mii;
454         int     nTools,i;
455         HMENU   hSubMenu;
456
457         TRACE(shell,"(%p) semi-stub\n",This);
458
459         hSubMenu = CreatePopupMenu();
460         if(hSubMenu)
461         { /*get the number of items in our global array*/
462           for(nTools = 0; g_Tools[nTools].idCommand != -1; nTools++){}
463
464           /*add the menu items*/
465           for(i = 0; i < nTools; i++)
466           { strcpy(szText, "dummy BuildFileMenu");
467       
468             ZeroMemory(&mii, sizeof(mii));
469             mii.cbSize = sizeof(mii);
470             mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
471
472             if(TBSTYLE_SEP != g_Tools[i].bStyle) /* no seperator*/
473             { mii.fType = MFT_STRING;
474               mii.fState = MFS_ENABLED;
475               mii.dwTypeData = szText;
476               mii.wID = g_Tools[i].idCommand;
477             }
478             else
479             { mii.fType = MFT_SEPARATOR;
480             }
481             /* tack This item onto the end of the menu */
482             InsertMenuItemA(hSubMenu, (UINT)-1, TRUE, &mii);
483           }
484         }
485         TRACE(shell,"-- return (menu=0x%x)\n",hSubMenu);
486         return hSubMenu;
487 }
488 /**************************************************************************
489 * ShellView_MergeFileMenu()
490 */   
491 void ShellView_MergeFileMenu(IShellViewImpl * This, HMENU hSubMenu)
492 {       TRACE(shell,"(%p)->(submenu=0x%08x) stub\n",This,hSubMenu);
493
494         if(hSubMenu)
495         { /*insert This item at the beginning of the menu */
496           _InsertMenuItem(hSubMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
497           _InsertMenuItem(hSubMenu, 0, TRUE, IDM_MYFILEITEM, MFT_STRING, "dummy45", MFS_ENABLED);
498
499         }
500         TRACE(shell,"--\n");    
501 }
502
503 /**************************************************************************
504 * ShellView_MergeViewMenu()
505 */   
506
507 void ShellView_MergeViewMenu(IShellViewImpl * This, HMENU hSubMenu)
508 {       MENUITEMINFOA   mii;
509
510         TRACE(shell,"(%p)->(submenu=0x%08x)\n",This,hSubMenu);
511
512         if(hSubMenu)
513         { /*add a separator at the correct position in the menu*/
514           _InsertMenuItem(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED);
515
516           ZeroMemory(&mii, sizeof(mii));
517           mii.cbSize = sizeof(mii);
518           mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;;
519           mii.fType = MFT_STRING;
520           mii.dwTypeData = "View";
521           mii.hSubMenu = LoadMenuIndirectA(&_Resource_Men_MENU_001_0_data);
522           InsertMenuItemA(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii);
523         }
524 }
525
526 /**************************************************************************
527 * ShellView_CanDoIDockingWindow()
528 */   
529 BOOL ShellView_CanDoIDockingWindow(IShellViewImpl * This)
530 {       BOOL bReturn = FALSE;
531         HRESULT hr;
532         LPSERVICEPROVIDER pSP;
533         LPDOCKINGWINDOWFRAME pFrame;
534         
535         FIXME(shell,"(%p) stub\n",This);
536         
537         /*get the browser's IServiceProvider*/
538         hr = IShellBrowser_QueryInterface(This->pShellBrowser, (REFIID)&IID_IServiceProvider, (LPVOID*)&pSP);
539         if(hr==S_OK)
540         { hr = IServiceProvider_QueryService(pSP, (REFGUID)&SID_SShellBrowser, (REFIID)&IID_IDockingWindowFrame, (LPVOID*)&pFrame);
541           if(SUCCEEDED(hr))
542           { bReturn = TRUE;
543             pFrame->lpvtbl->fnRelease(pFrame);
544           }
545           IServiceProvider_Release(pSP);
546         }
547         return bReturn;
548 }
549
550 /**************************************************************************
551 * ShellView_UpdateMenu()
552 */
553 LRESULT ShellView_UpdateMenu(IShellViewImpl * This, HMENU hMenu)
554 {       TRACE(shell,"(%p)->(menu=0x%08x)\n",This,hMenu);
555         CheckMenuItem(hMenu, IDM_VIEW_FILES, MF_BYCOMMAND | (g_bViewKeys ? MF_CHECKED: MF_UNCHECKED));
556
557         if(ShellView_CanDoIDockingWindow(This))
558         { EnableMenuItem(hMenu, IDM_VIEW_IDW, MF_BYCOMMAND | MF_ENABLED);
559           CheckMenuItem(hMenu, IDM_VIEW_IDW, MF_BYCOMMAND | (g_bShowIDW ? MF_CHECKED: MF_UNCHECKED));
560         }
561         else
562         { EnableMenuItem(hMenu, IDM_VIEW_IDW, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
563           CheckMenuItem(hMenu, IDM_VIEW_IDW, MF_BYCOMMAND | MF_UNCHECKED);
564         }
565         return S_OK;
566 }
567
568 /**************************************************************************
569 * ShellView_OnDeactivate()
570 *
571 * NOTES
572 *  internal
573 */   
574 void ShellView_OnDeactivate(IShellViewImpl * This)
575 { TRACE(shell,"%p\n",This);
576   if(This->uState != SVUIA_DEACTIVATE)
577   { if(This->hMenu)
578     { IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0);
579       IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu);
580       DestroyMenu(This->hMenu);
581       This->hMenu = 0;
582       }
583
584    This->uState = SVUIA_DEACTIVATE;
585    }
586 }
587
588 /**************************************************************************
589 * ShellView_OnActivate()
590 */   
591 LRESULT ShellView_OnActivate(IShellViewImpl * This, UINT uState)
592 {       OLEMENUGROUPWIDTHS   omw = { {0, 0, 0, 0, 0, 0} };
593         MENUITEMINFOA         mii;
594         CHAR                szText[MAX_PATH];
595
596         TRACE(shell,"%p uState=%x\n",This,uState);    
597
598         /*don't do anything if the state isn't really changing */
599         if(This->uState == uState)
600         { return S_OK;
601         }
602
603         ShellView_OnDeactivate(This);
604
605         /*only do This if we are active */
606         if(uState != SVUIA_DEACTIVATE)
607         { /*merge the menus */
608           This->hMenu = CreateMenu();
609    
610           if(This->hMenu)
611           { IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw);
612             TRACE(shell,"-- after fnInsertMenusSB\n");    
613             /*build the top level menu get the menu item's text*/
614             strcpy(szText,"dummy 31");
615       
616             ZeroMemory(&mii, sizeof(mii));
617             mii.cbSize = sizeof(mii);
618             mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE;
619             mii.fType = MFT_STRING;
620             mii.fState = MFS_ENABLED;
621             mii.dwTypeData = szText;
622             mii.hSubMenu = ShellView_BuildFileMenu(This);
623
624             /*insert our menu into the menu bar*/
625             if(mii.hSubMenu)
626             { InsertMenuItemA(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii);
627             }
628
629             /*get the view menu so we can merge with it*/
630             ZeroMemory(&mii, sizeof(mii));
631             mii.cbSize = sizeof(mii);
632             mii.fMask = MIIM_SUBMENU;
633       
634             if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii))
635             { ShellView_MergeViewMenu(This, mii.hSubMenu);
636             }
637
638             /*add the items that should only be added if we have the focus*/
639             if(SVUIA_ACTIVATE_FOCUS == uState)
640             { /*get the file menu so we can merge with it */
641               ZeroMemory(&mii, sizeof(mii));
642               mii.cbSize = sizeof(mii);
643               mii.fMask = MIIM_SUBMENU;
644       
645               if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii))
646               { ShellView_MergeFileMenu(This, mii.hSubMenu);
647               }
648             }
649           TRACE(shell,"-- before fnSetMenuSB\n");      
650           IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd);
651           }
652         }
653         This->uState = uState;
654         TRACE(shell,"--\n");    
655         return S_OK;
656 }
657
658 /**************************************************************************
659 *  ShellView_OnSetFocus()
660 *
661 * NOTES
662 *  internal
663 */
664 LRESULT ShellView_OnSetFocus(IShellViewImpl * This)
665 {       TRACE(shell,"%p\n",This);
666         /* Tell the browser one of our windows has received the focus. This should always 
667         be done before merging menus (OnActivate merges the menus) if one of our 
668         windows has the focus.*/
669         IShellBrowser_OnViewWindowActive(This->pShellBrowser,(IShellView*) This);
670         ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS);
671
672         return 0;
673 }
674
675 /**************************************************************************
676 * ShellView_OnKillFocus()
677 */   
678 LRESULT ShellView_OnKillFocus(IShellViewImpl * This)
679 {       TRACE(shell,"(%p) stub\n",This);
680         ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS);
681         return 0;
682 }
683
684 /**************************************************************************
685 * ShellView_AddRemoveDockingWindow()
686 */   
687 BOOL ShellView_AddRemoveDockingWindow(IShellViewImpl * This, BOOL bAdd)
688 {       BOOL    bReturn = FALSE;
689         HRESULT hr;
690         LPSERVICEPROVIDER       pSP;
691         LPDOCKINGWINDOWFRAME    pFrame;
692         
693         WARN(shell,"(%p)->(badd=0x%08x) semi-stub\n",This,bAdd);
694
695         /* get the browser's IServiceProvider */
696         hr = IShellBrowser_QueryInterface(This->pShellBrowser, (REFIID)&IID_IServiceProvider, (LPVOID*)&pSP);
697         if(SUCCEEDED(hr))
698         { /*get the IDockingWindowFrame pointer*/
699           hr = IServiceProvider_QueryService(pSP, (REFGUID)&SID_SShellBrowser, (REFIID)&IID_IDockingWindowFrame, (LPVOID*)&pFrame);
700           if(SUCCEEDED(hr))
701           { if(bAdd)
702             { hr = S_OK;
703               FIXME(shell,"no docking implemented\n");
704 #if 0
705               if(!This->pDockingWindow)
706               { /* create the toolbar object */
707                 This->pDockingWindow = DockingWindow_Constructor(This, This->hWnd);
708               }
709
710               if(This->pDockingWindow)
711               { /*add the toolbar object */
712                 hr = pFrame->lpvtbl->fnAddToolbar(pFrame, (IDockingWindow*)This->pDockingWindow, TOOLBAR_ID, 0);
713
714                 if(SUCCEEDED(hr))
715                 { bReturn = TRUE;
716                 }
717               }
718 #endif
719             }
720             else
721             { FIXME(shell,"no docking implemented\n");
722 #if 0
723               if(This->pDockingWindow)
724               { hr = pFrame->lpvtbl->fnRemoveToolbar(pFrame, (IDockingWindow*)This->pDockingWindow, DWFRF_NORMAL);
725
726                 if(SUCCEEDED(hr))
727                 { /* RemoveToolbar should release the toolbar object which will cause  */
728                   /*it to destroy itself. Our toolbar object is no longer valid at  */
729                   /*This point. */
730             
731                   This->pDockingWindow = NULL;
732                   bReturn = TRUE;
733                 }
734               }
735 #endif
736             }
737             pFrame->lpvtbl->fnRelease(pFrame);
738           }
739           IServiceProvider_Release(pSP);
740         }
741         return bReturn;
742 }
743
744 /**************************************************************************
745 *  ShellView_UpdateShellSettings()
746 */
747 void ShellView_UpdateShellSettings(IShellViewImpl * This)
748 {       FIXME(shell,"(%p) stub\n",This);
749         return ;
750 /*
751         SHELLFLAGSTATE       sfs;
752         HINSTANCE            hinstShell32;
753 */
754         /* Since SHGetSettings is not implemented in all versions of the shell, get the 
755         function address manually at run time. This allows the code to run on all 
756         platforms.*/
757 /*
758         ZeroMemory(&sfs, sizeof(sfs));
759 */
760         /* The default, in case any of the following steps fails, is classic Windows 95 
761         style.*/
762 /*
763         sfs.fWin95Classic = TRUE;
764
765         hinstShell32 = LoadLibrary("shell32.dll");
766         if(hinstShell32)
767         { PFNSHGETSETTINGSPROC pfnSHGetSettings;
768
769       pfnSHGetSettings = (PFNSHGETSETTINGSPROC)GetProcAddress(hinstShell32, "SHGetSettings");
770           if(pfnSHGetSettings)
771       { (*pfnSHGetSettings)(&sfs, SSF_DOUBLECLICKINWEBVIEW | SSF_WIN95CLASSIC);
772       }
773           FreeLibrary(hinstShell32);
774         }
775
776         DWORD dwExStyles = 0;
777
778         if(!sfs.fWin95Classic && !sfs.fDoubleClickInWebView)
779           dwExStyles |= LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT | LVS_EX_UNDERLINEHOT;
780
781         ListView_SetExtendedListViewStyle(This->hWndList, dwExStyles);
782 */
783 }
784
785 /**************************************************************************
786 *   ShellView_OnSettingChange()
787 */   
788 LRESULT ShellView_OnSettingChange(IShellViewImpl * This, LPCSTR lpszSection)
789 {       TRACE(shell,"(%p) stub\n",This);
790 /*if(0 == lstrcmpi(lpszSection, "ShellState"))*/
791         { ShellView_UpdateShellSettings(This);
792           return 0;
793         }
794         return 0;
795 }
796 /**************************************************************************
797 * ShellView_OnCommand()
798 */   
799 LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd)
800 {       TRACE(shell,"(%p)->(0x%08lx 0x%08lx 0x%08x) stub\n",This, dwCmdID, dwCmd, hwndCmd);
801         switch(dwCmdID)
802         { case IDM_VIEW_FILES:
803             g_bViewKeys = ! g_bViewKeys;
804             IShellView_Refresh((IShellView*) This);
805             break;
806
807           case IDM_VIEW_IDW:
808             g_bShowIDW = ! g_bShowIDW;
809             ShellView_AddRemoveDockingWindow(This, g_bShowIDW);
810             break;
811    
812           case IDM_MYFILEITEM:
813             MessageBeep(MB_OK);
814             break;
815
816           case FCIDM_SHVIEW_SMALLICON:
817             This->FolderSettings.ViewMode = FVM_SMALLICON;
818             SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK);
819             break;
820
821           case FCIDM_SHVIEW_BIGICON:
822             This->FolderSettings.ViewMode = FVM_ICON;
823             SetStyle (This, LVS_ICON, LVS_TYPEMASK);
824             break;
825
826           case FCIDM_SHVIEW_LISTVIEW:
827             This->FolderSettings.ViewMode = FVM_LIST;
828             SetStyle (This, LVS_LIST, LVS_TYPEMASK);
829             break;
830
831           case FCIDM_SHVIEW_REPORTVIEW:
832             This->FolderSettings.ViewMode = FVM_DETAILS;
833             SetStyle (This, LVS_REPORT, LVS_TYPEMASK);
834             break;
835
836           default:
837             TRACE(shell,"-- COMMAND 0x%04lx unhandled\n", dwCmdID);
838         }
839         return 0;
840 }
841
842 /**************************************************************************
843 *   ShellView_GetSelections()
844 *
845 * RETURNS
846 *  number of selected items
847 */   
848 UINT ShellView_GetSelections(IShellViewImpl * This)
849 {       LVITEMA lvItem;
850         UINT    i;
851
852
853         if (This->aSelectedItems)
854         { SHFree(This->aSelectedItems);
855         }
856
857         This->uSelected = ListView_GetSelectedCount(This->hWndList);
858         This->aSelectedItems = (LPITEMIDLIST*)SHAlloc(This->uSelected * sizeof(LPITEMIDLIST));
859
860         TRACE(shell,"selected=%i\n", This->uSelected);
861         
862         if(This->aSelectedItems)
863         { TRACE(shell,"-- Items selected =%u\n", This->uSelected);
864           ZeroMemory(&lvItem, sizeof(lvItem));
865           lvItem.mask = LVIF_STATE | LVIF_PARAM;
866           lvItem.stateMask = LVIS_SELECTED;
867           lvItem.iItem = 0;
868
869           i = 0;
870    
871           while(ListView_GetItemA(This->hWndList, &lvItem) && (i < This->uSelected))
872           { if(lvItem.state & LVIS_SELECTED)
873             { This->aSelectedItems[i] = (LPITEMIDLIST)lvItem.lParam;
874               i++;
875               TRACE(shell,"-- selected Item found\n");
876             }
877             lvItem.iItem++;
878           }
879         }
880         return This->uSelected;
881
882 }
883 /**************************************************************************
884 *   ShellView_DoContextMenu()
885 */   
886 void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL fDefault)
887 {       UINT    uCommand;
888         DWORD   wFlags;
889         HMENU hMenu;
890         BOOL  fExplore = FALSE;
891         HWND  hwndTree = 0;
892         INT             nMenuIndex;
893         MENUITEMINFOA   mii;
894         LPCONTEXTMENU   pContextMenu = NULL;
895         CMINVOKECOMMANDINFO  cmi;
896         
897         TRACE(shell,"(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, fDefault);
898
899         /* look, what's selected and create a context menu object of it*/
900         if(ShellView_GetSelections(This))
901         { This->pSFParent->lpvtbl->fnGetUIObjectOf( This->pSFParent, This->hWndParent, This->uSelected,
902                                                     This->aSelectedItems, (REFIID)&IID_IContextMenu,
903                                                     NULL, (LPVOID *)&pContextMenu);
904    
905           if(pContextMenu)
906           { TRACE(shell,"-- pContextMenu\n");
907             hMenu = CreatePopupMenu();
908
909             if( hMenu )
910             { /* See if we are in Explore or Open mode. If the browser's tree
911                  is present, then we are in Explore mode.*/
912         
913               if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree)
914               { TRACE(shell,"-- explore mode\n");
915                 fExplore = TRUE;
916               }
917
918               wFlags = CMF_NORMAL | (This->uSelected != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0);
919
920               if (SUCCEEDED(pContextMenu->lpvtbl->fnQueryContextMenu( pContextMenu, hMenu, 0, MENU_OFFSET, MENU_MAX, wFlags )))
921               { if( fDefault )
922                 { TRACE(shell,"-- get menu default command\n");
923
924                   uCommand = nMenuIndex = 0;
925                   ZeroMemory(&mii, sizeof(mii));
926                   mii.cbSize = sizeof(mii);
927                   mii.fMask = MIIM_STATE | MIIM_ID;
928
929                   while(GetMenuItemInfoA(hMenu, nMenuIndex, TRUE, &mii))        /*find the default item in the menu*/
930                   { if(mii.fState & MFS_DEFAULT)
931                     { uCommand = mii.wID;
932                       break;
933                     }
934                     nMenuIndex++;
935                   }
936                 }
937                 else
938                 { TRACE(shell,"-- track popup\n");
939                   uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
940                 }               
941          
942                 if(uCommand > 0)
943                 { TRACE(shell,"-- uCommand=%u\n", uCommand);
944                   if (IsInCommDlg(This) && (((uCommand-MENU_OFFSET)==IDM_EXPLORE) || ((uCommand-MENU_OFFSET)==IDM_OPEN)))
945                   { TRACE(shell,"-- dlg: OnDefaultCommand\n");
946                     OnDefaultCommand(This);
947                   }
948                   else
949                   { TRACE(shell,"-- explore -- invoke command\n");
950                       ZeroMemory(&cmi, sizeof(cmi));
951                       cmi.cbSize = sizeof(cmi);
952                       cmi.hwnd = This->hWndParent;
953                       cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand - MENU_OFFSET);
954                       pContextMenu->lpvtbl->fnInvokeCommand(pContextMenu, &cmi);
955                   }
956                 }
957                 DestroyMenu(hMenu);
958               }
959             }
960             if (pContextMenu)
961               pContextMenu->lpvtbl->fnRelease(pContextMenu);
962           }
963         }
964         else    /* background context menu */
965         { hMenu = LoadMenuIndirectA(&_Resource_Men_MENU_002_0_data);
966           uCommand = TrackPopupMenu( GetSubMenu(hMenu,0),TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL);
967           ShellView_OnCommand(This, uCommand, 0,0);
968           DestroyMenu(hMenu);
969         }
970 }
971
972 /**************************************************************************
973 * ShellView_OnNotify()
974 */
975    
976 LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh)
977 {       NM_LISTVIEW *lpnmlv = (NM_LISTVIEW*)lpnmh;
978         NMLVDISPINFOA *lpdi = (NMLVDISPINFOA *)lpnmh;
979         LPITEMIDLIST pidl;
980         DWORD dwCursor; 
981         STRRET   str;  
982
983         TRACE(shell,"%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code);
984
985         switch(lpnmh->code)
986         { case NM_SETFOCUS:
987             TRACE(shell,"-- NM_SETFOCUS %p\n",This);
988             ShellView_OnSetFocus(This);
989             break;
990
991           case NM_KILLFOCUS:
992             TRACE(shell,"-- NM_KILLFOCUS %p\n",This);
993             ShellView_OnDeactivate(This);
994             break;
995
996           case HDN_ENDTRACKA:
997             TRACE(shell,"-- HDN_ENDTRACKA %p\n",This);
998             /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
999             nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
1000             break;
1001
1002           case LVN_DELETEITEM:
1003             TRACE(shell,"-- LVN_DELETEITEM %p\n",This);
1004             SHFree((LPITEMIDLIST)lpnmlv->lParam);     /*delete the pidl because we made a copy of it*/
1005             break;
1006
1007           case LVN_ITEMACTIVATE:
1008             TRACE(shell,"-- LVN_ITEMACTIVATE %p\n",This);
1009             OnStateChange(This, CDBOSC_SELCHANGE);  /* the browser will get the IDataObject now */
1010             ShellView_DoContextMenu(This, 0, 0, TRUE);
1011             break;
1012
1013           case NM_RCLICK:
1014             TRACE(shell,"-- NM_RCLICK %p\n",This);
1015             dwCursor = GetMessagePos();
1016             ShellView_DoContextMenu(This, LOWORD(dwCursor), HIWORD(dwCursor), FALSE);
1017             break;
1018
1019           case LVN_GETDISPINFOA:
1020             TRACE(shell,"-- LVN_GETDISPINFOA %p\n",This);
1021             pidl = (LPITEMIDLIST)lpdi->item.lParam;
1022
1023
1024             if(lpdi->item.iSubItem)               /*is the sub-item information being requested?*/
1025             { if(lpdi->item.mask & LVIF_TEXT)    /*is the text being requested?*/
1026               { if(_ILIsValue(pidl))    /*is This a value or a folder?*/
1027                 { switch (lpdi->item.iSubItem)
1028                   { case 1:     /* size */
1029                       _ILGetFileSize (pidl, lpdi->item.pszText, lpdi->item.cchTextMax);
1030                       break;
1031                     case 2:     /* extension */
1032                       { char sTemp[64];
1033                         if (_ILGetExtension (pidl, sTemp, 64))
1034                         { if (!( HCR_MapTypeToValue(sTemp, sTemp, 64)
1035                                  && HCR_MapTypeToValue(sTemp, lpdi->item.pszText, lpdi->item.cchTextMax )))
1036                           { strncpy (lpdi->item.pszText, sTemp, lpdi->item.cchTextMax);
1037                             strncat (lpdi->item.pszText, "-file", lpdi->item.cchTextMax);
1038                           }
1039                         }
1040                         else    /* no extension found */
1041                         { lpdi->item.pszText[0]=0x00;
1042                         }    
1043                       }
1044                       break;
1045                     case 3:     /* date */
1046                       _ILGetFileDate (pidl, lpdi->item.pszText, lpdi->item.cchTextMax);
1047                       break;
1048                   }
1049                 }
1050                 else  /*its a folder*/
1051                 { switch (lpdi->item.iSubItem)
1052                   { case 1:
1053                       strcpy(lpdi->item.pszText, "");
1054                       break;
1055                     case 2:
1056                       strncpy (lpdi->item.pszText, "Folder", lpdi->item.cchTextMax);
1057                       break;
1058                     case 3:  
1059                       _ILGetFileDate (pidl, lpdi->item.pszText, lpdi->item.cchTextMax);
1060                       break;
1061                   }
1062                 }
1063                 TRACE(shell,"-- text=%s\n",lpdi->item.pszText);         
1064               }
1065             }
1066             else           /*the item text is being requested*/
1067             { if(lpdi->item.mask & LVIF_TEXT)      /*is the text being requested?*/
1068               { if(SUCCEEDED(IShellFolder_GetDisplayNameOf(This->pSFParent,pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &str)))
1069                 { if(STRRET_WSTR == str.uType)
1070                   { WideCharToLocal(lpdi->item.pszText, str.u.pOleStr, lpdi->item.cchTextMax);
1071                     SHFree(str.u.pOleStr);
1072                   }
1073                   else if(STRRET_CSTRA == str.uType)
1074                   { strncpy(lpdi->item.pszText, str.u.cStr, lpdi->item.cchTextMax);
1075                   }
1076                   else
1077                   { FIXME(shell,"type wrong\n");
1078                   }
1079                 }
1080                 TRACE(shell,"-- text=%s\n",lpdi->item.pszText);
1081               }
1082
1083               if(lpdi->item.mask & LVIF_IMAGE)          /*is the image being requested?*/
1084               { lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0);
1085               }
1086             }
1087             break;
1088
1089           case LVN_ITEMCHANGED:
1090             TRACE(shell,"-- LVN_ITEMCHANGED %p\n",This);
1091             ShellView_GetSelections(This);
1092             OnStateChange(This, CDBOSC_SELCHANGE);  /* the browser will get the IDataObject now */
1093             break;
1094
1095           default:
1096             TRACE (shell,"-- %p WM_COMMAND %s unhandled\n", This, SPY_GetMsgName(lpnmh->code));
1097             break;;
1098         }
1099         return 0;
1100 }
1101
1102 /**************************************************************************
1103 *  ShellView_WndProc
1104 */
1105
1106 LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
1107 { IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongA(hWnd, GWL_USERDATA);
1108   LPCREATESTRUCTA lpcs;
1109   DWORD dwCursor;
1110   
1111   TRACE(shell,"(hwnd=%x msg=%x wparm=%x lparm=%lx)\n",hWnd, uMessage, wParam, lParam);
1112     
1113   switch (uMessage)
1114   { case WM_NCCREATE:
1115       { TRACE(shell,"-- WM_NCCREATE\n");
1116         lpcs = (LPCREATESTRUCTA)lParam;
1117         pThis = (IShellViewImpl*)(lpcs->lpCreateParams);
1118         SetWindowLongA(hWnd, GWL_USERDATA, (LONG)pThis);
1119         pThis->hWnd = hWnd;        /*set the window handle*/
1120       }
1121       break;
1122    
1123    case WM_SIZE:
1124       TRACE(shell,"-- WM_SIZE\n");
1125       return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam));
1126    
1127    case WM_SETFOCUS:
1128       TRACE(shell,"-- WM_SETFOCUS\n");   
1129       return ShellView_OnSetFocus(pThis);
1130  
1131    case WM_KILLFOCUS:
1132       TRACE(shell,"-- WM_KILLFOCUS\n");
1133           return ShellView_OnKillFocus(pThis);
1134
1135    case WM_CREATE:
1136       TRACE(shell,"-- WM_CREATE\n");
1137       return ShellView_OnCreate(pThis);
1138
1139    case WM_SHOWWINDOW:
1140       TRACE(shell,"-- WM_SHOWWINDOW\n");
1141       UpdateWindow(pThis->hWndList);
1142       break;
1143
1144    case WM_ACTIVATE:
1145       TRACE(shell,"-- WM_ACTIVATE\n");
1146       return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS);
1147    
1148    case WM_COMMAND:
1149       TRACE(shell,"-- WM_COMMAND\n");
1150       return ShellView_OnCommand(pThis, GET_WM_COMMAND_ID(wParam, lParam), 
1151                                   GET_WM_COMMAND_CMD(wParam, lParam), 
1152                                   GET_WM_COMMAND_HWND(wParam, lParam));
1153    
1154    case WM_INITMENUPOPUP:
1155       TRACE(shell,"-- WM_INITMENUPOPUP\n");
1156       return ShellView_UpdateMenu(pThis, (HMENU)wParam);
1157    
1158    case WM_NOTIFY:
1159       TRACE(shell,"-- WM_NOTIFY\n");
1160       return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam);
1161
1162    case WM_SETTINGCHANGE:
1163       TRACE(shell,"-- WM_SETTINGCHANGE\n");
1164       return ShellView_OnSettingChange(pThis,(LPCSTR)lParam);
1165
1166    case WM_PARENTNOTIFY:
1167       TRACE(shell,"-- WM_PARENTNOTIFY\n");
1168       if ( LOWORD(wParam) == WM_RBUTTONDOWN ) /* fixme: should not be handled here*/
1169       { dwCursor = GetMessagePos();
1170         ShellView_DoContextMenu(pThis, LOWORD(dwCursor), HIWORD(dwCursor), FALSE);
1171         return TRUE;
1172       }
1173       break;
1174
1175    default:
1176       TRACE(shell,"-- message %s unhandled\n", SPY_GetMsgName(uMessage));
1177       break;
1178   }
1179   return DefWindowProcA (hWnd, uMessage, wParam, lParam);
1180 }
1181 /**************************************************************************
1182 *
1183 *
1184 *  The INTERFACE of the IShellView object
1185 *
1186 *
1187 ***************************************************************************
1188 *  IShellView_QueryInterface
1189 */
1190 static HRESULT WINAPI IShellView_fnQueryInterface(IShellView * iface,REFIID riid, LPVOID *ppvObj)
1191 {
1192         ICOM_THIS(IShellViewImpl, iface);
1193
1194         char    xriid[50];
1195         WINE_StringFromCLSID((LPCLSID)riid,xriid);
1196         TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
1197
1198         *ppvObj = NULL;
1199
1200         if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
1201         { *ppvObj = This; 
1202         }
1203         else if(IsEqualIID(riid, &IID_IShellView))  /*IShellView*/
1204         { *ppvObj = (IShellView*)This;
1205         }
1206         else if(IsEqualIID(riid, &IID_IOleCommandTarget))  /*IOleCommandTarget*/
1207         {    *ppvObj = (IOleCommandTarget*)&(This->lpvtblOleCommandTarget);
1208         }   
1209         else if(IsEqualIID(riid, &IID_IDropTarget))  /*IDropTarget*/
1210         {    *ppvObj = (IDropTarget*)&(This->lpvtblDropTarget);
1211         }   
1212         else if(IsEqualIID(riid, &IID_IViewObject))  /*ViewObject*/
1213         {    *ppvObj = (IViewObject*)&(This->lpvtblViewObject);
1214         }   
1215
1216         if(*ppvObj)
1217         { IShellView_AddRef( (IShellView*) *ppvObj);
1218           TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1219           return S_OK;
1220         }
1221         TRACE(shell,"-- Interface: E_NOINTERFACE\n");
1222         return E_NOINTERFACE;
1223 }
1224
1225 /**************************************************************************
1226 *  IShellView::AddRef
1227 */
1228 static ULONG WINAPI IShellView_fnAddRef(IShellView * iface)
1229 {
1230         ICOM_THIS(IShellViewImpl, iface);
1231
1232         TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
1233
1234         shell32_ObjCount++;
1235         return ++(This->ref);
1236 }
1237 /**************************************************************************
1238 *  IShellView_Release
1239 */
1240 static ULONG WINAPI IShellView_fnRelease(IShellView * iface)
1241 {
1242         ICOM_THIS(IShellViewImpl, iface);
1243
1244         TRACE(shell,"(%p)->()\n",This);
1245
1246         shell32_ObjCount--;
1247         if (!--(This->ref)) 
1248         { TRACE(shell," destroying IShellView(%p)\n",This);
1249
1250           if(This->pSFParent)
1251             IShellFolder_Release(This->pSFParent);
1252
1253           if (This->aSelectedItems)
1254             SHFree(This->aSelectedItems);
1255
1256           if (This->pCommDlgBrowser)
1257             ICommDlgBrowser_Release(This->pCommDlgBrowser);
1258
1259           HeapFree(GetProcessHeap(),0,This);
1260           return 0;
1261         }
1262         return This->ref;
1263 }
1264 /**************************************************************************
1265 *  ShellView_GetWindow
1266 */
1267 static HRESULT WINAPI IShellView_fnGetWindow(IShellView * iface,HWND * phWnd)
1268 {
1269         ICOM_THIS(IShellViewImpl, iface);
1270
1271         TRACE(shell,"(%p)\n",This);
1272
1273         *phWnd = This->hWnd;
1274
1275         return S_OK;
1276 }
1277
1278 static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView * iface,BOOL fEnterMode)
1279 {
1280         ICOM_THIS(IShellViewImpl, iface);
1281
1282         FIXME(shell,"(%p) stub\n",This);
1283
1284         return E_NOTIMPL;
1285 }
1286 /**************************************************************************
1287 * IShellView_TranslateAccelerator
1288 *
1289 * FIXME:
1290 *  use the accel functions
1291 */
1292 static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg)
1293 {
1294         ICOM_THIS(IShellViewImpl, iface);
1295
1296         FIXME(shell,"(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
1297
1298         
1299         switch (lpmsg->message)
1300         { case WM_KEYDOWN:      TRACE(shell,"-- key=0x04%x",lpmsg->wParam) ;
1301         }
1302         return S_FALSE;
1303 }
1304
1305 static HRESULT WINAPI IShellView_fnEnableModeless(IShellView * iface,BOOL fEnable)
1306 {
1307         ICOM_THIS(IShellViewImpl, iface);
1308
1309         FIXME(shell,"(%p) stub\n",This);
1310
1311         return E_NOTIMPL;
1312 }
1313
1314 static HRESULT WINAPI IShellView_fnUIActivate(IShellView * iface,UINT uState)
1315 {
1316         ICOM_THIS(IShellViewImpl, iface);
1317
1318         CHAR    szName[MAX_PATH];
1319         LRESULT lResult;
1320         int     nPartArray[1] = {-1};
1321
1322         TRACE(shell,"(%p)->(state=%x) stub\n",This, uState);
1323         /*don't do anything if the state isn't really changing*/
1324         if(This->uState == uState)
1325         { return S_OK;
1326         }
1327
1328         /*OnActivate handles the menu merging and internal state*/
1329         ShellView_OnActivate(This, uState);
1330
1331         /*remove the docking window*/
1332         if(g_bShowIDW)
1333         { ShellView_AddRemoveDockingWindow(This, FALSE);
1334         }
1335
1336         /*only do This if we are active*/
1337         if(uState != SVUIA_DEACTIVATE)
1338         { /*update the status bar */
1339            strcpy(szName, "dummy32");
1340
1341           IShellFolder_GetFolderPath( This->pSFParent, szName + strlen(szName), sizeof(szName) - strlen(szName));
1342
1343           /* set the number of parts */
1344           IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1,
1345                                                         (LPARAM)nPartArray, &lResult);
1346
1347           /* set the text for the parts */
1348           IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1349                                                         0, (LPARAM)szName, &lResult);
1350
1351           /*add the docking window if necessary */
1352           if(g_bShowIDW)
1353           { ShellView_AddRemoveDockingWindow(This, TRUE);
1354           }
1355         }
1356         return S_OK;
1357 }
1358 static HRESULT WINAPI IShellView_fnRefresh(IShellView * iface)
1359 {
1360         ICOM_THIS(IShellViewImpl, iface);
1361
1362         TRACE(shell,"(%p)\n",This);
1363
1364         ListView_DeleteAllItems(This->hWndList);
1365         ShellView_FillList(This);
1366
1367         return S_OK;
1368 }
1369 static HRESULT WINAPI IShellView_fnCreateViewWindow(IShellView * iface, IShellView *lpPrevView,
1370                      LPCFOLDERSETTINGS lpfs, IShellBrowser * psb, RECT * prcView, HWND  *phWnd)
1371 {
1372         ICOM_THIS(IShellViewImpl, iface);
1373
1374         WNDCLASSA wc;
1375         *phWnd = 0;
1376
1377         
1378         TRACE(shell,"(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This, lpPrevView,lpfs, psb, prcView, phWnd);
1379         TRACE(shell,"-- 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);
1380
1381         /*set up the member variables*/
1382         This->pShellBrowser = psb;
1383         This->FolderSettings = *lpfs;
1384
1385         /*get our parent window*/
1386         IShellBrowser_AddRef(This->pShellBrowser);
1387         IShellBrowser_GetWindow(This->pShellBrowser, &(This->hWndParent));
1388
1389         /* try to get the ICommDlgBrowserInterface, adds a reference !!! */
1390         This->pCommDlgBrowser=NULL;
1391         if ( SUCCEEDED (IShellBrowser_QueryInterface( This->pShellBrowser, 
1392                         (REFIID)&IID_ICommDlgBrowser, (LPVOID*) &This->pCommDlgBrowser)))
1393         { TRACE(shell,"-- CommDlgBrowser\n");
1394         }
1395            
1396         /*if our window class has not been registered, then do so*/
1397         if(!GetClassInfoA(shell32_hInstance, SV_CLASS_NAME, &wc))
1398         { ZeroMemory(&wc, sizeof(wc));
1399           wc.style          = CS_HREDRAW | CS_VREDRAW;
1400           wc.lpfnWndProc    = (WNDPROC) ShellView_WndProc;
1401           wc.cbClsExtra     = 0;
1402           wc.cbWndExtra     = 0;
1403           wc.hInstance      = shell32_hInstance;
1404           wc.hIcon          = 0;
1405           wc.hCursor        = LoadCursorA (0, IDC_ARROWA);
1406           wc.hbrBackground  = (HBRUSH) (COLOR_WINDOW + 1);
1407           wc.lpszMenuName   = NULL;
1408           wc.lpszClassName  = SV_CLASS_NAME;
1409
1410           if(!RegisterClassA(&wc))
1411             return E_FAIL;
1412         }
1413
1414         *phWnd = CreateWindowExA(0, SV_CLASS_NAME, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
1415                            prcView->left, prcView->top, prcView->right - prcView->left, prcView->bottom - prcView->top,
1416                            This->hWndParent, 0, shell32_hInstance, (LPVOID)This);
1417                            
1418         MergeToolBar(This);
1419         
1420         if(!*phWnd)
1421           return E_FAIL;
1422
1423         return S_OK;
1424 }
1425
1426 static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView * iface)
1427 {
1428         ICOM_THIS(IShellViewImpl, iface);
1429
1430         TRACE(shell,"(%p)\n",This);
1431
1432         /*Make absolutely sure all our UI is cleaned up.*/
1433         IShellView_UIActivate((IShellView*)This, SVUIA_DEACTIVATE);
1434         if(This->hMenu)
1435         { DestroyMenu(This->hMenu);
1436         }
1437         DestroyWindow(This->hWnd);
1438         IShellBrowser_Release(This->pShellBrowser);
1439         return S_OK;
1440 }
1441
1442 static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView * iface, LPFOLDERSETTINGS lpfs)
1443 {
1444         ICOM_THIS(IShellViewImpl, iface);
1445
1446         TRACE(shell,"(%p)->(%p) vmode=%x flags=%x\n",This, lpfs, 
1447                 This->FolderSettings.ViewMode, This->FolderSettings.fFlags);
1448
1449         if (lpfs)
1450         { *lpfs = This->FolderSettings;
1451           return NOERROR;
1452         }
1453         else
1454           return E_INVALIDARG;
1455 }
1456
1457 static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView * iface, DWORD dwReserved,LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam)
1458 {
1459         ICOM_THIS(IShellViewImpl, iface);
1460
1461         FIXME(shell,"(%p) stub\n",This);
1462
1463         return E_NOTIMPL;
1464 }
1465
1466 static HRESULT WINAPI IShellView_fnSaveViewState(IShellView * iface)
1467 {
1468         ICOM_THIS(IShellViewImpl, iface);
1469
1470         FIXME(shell,"(%p) stub\n",This);
1471
1472         return S_OK;
1473 }
1474
1475 static HRESULT WINAPI IShellView_fnSelectItem(IShellView * iface, LPCITEMIDLIST pidlItem, UINT uFlags)
1476 {       ICOM_THIS(IShellViewImpl, iface);
1477         
1478         FIXME(shell,"(%p)->(pidl=%p, 0x%08x) stub\n",This, pidlItem, uFlags);
1479
1480         return E_NOTIMPL;
1481 }
1482
1483 static HRESULT WINAPI IShellView_fnGetItemObject(IShellView * iface, UINT uItem, REFIID riid, LPVOID *ppvOut)
1484 {
1485         ICOM_THIS(IShellViewImpl, iface);
1486
1487         LPUNKNOWN       pObj = NULL; 
1488         char    xriid[50];
1489         
1490         WINE_StringFromCLSID((LPCLSID)riid,xriid);
1491         TRACE(shell,"(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This, uItem, xriid, ppvOut);
1492
1493         *ppvOut = NULL;
1494         if(IsEqualIID(riid, &IID_IContextMenu))
1495         { ShellView_GetSelections(This);
1496           pObj =(LPUNKNOWN)IContextMenu_Constructor(This->pSFParent,This->aSelectedItems,This->uSelected);      
1497         }
1498         else if (IsEqualIID(riid, &IID_IDataObject))
1499         { ShellView_GetSelections(This);
1500           pObj =(LPUNKNOWN)IDataObject_Constructor(This->hWndParent, This->pSFParent,This->aSelectedItems,This->uSelected);
1501         }
1502
1503         TRACE(shell,"-- (%p)->(interface=%p)\n",This, ppvOut);
1504
1505         if(!pObj)
1506           return E_OUTOFMEMORY;
1507         *ppvOut = pObj;
1508         return S_OK;
1509 }
1510
1511 static struct ICOM_VTABLE(IShellView) svvt = 
1512 {       IShellView_fnQueryInterface,
1513         IShellView_fnAddRef,
1514         IShellView_fnRelease,
1515         IShellView_fnGetWindow,
1516         IShellView_fnContextSensitiveHelp,
1517         IShellView_fnTranslateAccelerator,
1518         IShellView_fnEnableModeless,
1519         IShellView_fnUIActivate,
1520         IShellView_fnRefresh,
1521         IShellView_fnCreateViewWindow,
1522         IShellView_fnDestroyViewWindow,
1523         IShellView_fnGetCurrentInfo,
1524         IShellView_fnAddPropertySheetPages,
1525         IShellView_fnSaveViewState,
1526         IShellView_fnSelectItem,
1527         IShellView_fnGetItemObject
1528 };
1529
1530
1531 /************************************************************************
1532  * ISVOleCmdTarget_QueryInterface (IUnknown)
1533  */
1534 static HRESULT WINAPI ISVOleCmdTarget_QueryInterface(
1535         IOleCommandTarget *     iface,
1536         REFIID                  iid,
1537         LPVOID*                 ppvObj)
1538 {
1539         _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1540
1541         return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj);
1542 }
1543
1544 /************************************************************************
1545  * ISVOleCmdTarget_AddRef (IUnknown)
1546  */
1547 static ULONG WINAPI ISVOleCmdTarget_AddRef(
1548         IOleCommandTarget *     iface)
1549 {
1550         _ICOM_THIS_From_IOleCommandTarget(IShellFolder, iface);
1551
1552         return IShellFolder_AddRef((IShellFolder*)This);
1553 }
1554
1555 /************************************************************************
1556  * ISVOleCmdTarget_Release (IUnknown)
1557  */
1558 static ULONG WINAPI ISVOleCmdTarget_Release(
1559         IOleCommandTarget *     iface)
1560 {
1561         _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1562
1563         return IShellFolder_Release((IShellFolder*)This);
1564 }
1565
1566 /************************************************************************
1567  * ISVOleCmdTarget_Exec (IOleCommandTarget)
1568  */
1569 static HRESULT WINAPI ISVOleCmdTarget_QueryStatus(
1570         IOleCommandTarget *iface,
1571         const GUID* pguidCmdGroup,
1572         ULONG cCmds, 
1573         OLECMD * prgCmds,
1574         OLECMDTEXT* pCmdText)
1575 {
1576         _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1577
1578         FIXME(shell, "(%p)->(%p 0x%08lx %p %p\n", This, pguidCmdGroup, cCmds, prgCmds, pCmdText);
1579         return E_NOTIMPL;
1580 }
1581
1582 /************************************************************************
1583  * ISVOleCmdTarget_Exec (IOleCommandTarget)
1584  */
1585 static HRESULT WINAPI ISVOleCmdTarget_Exec(
1586         IOleCommandTarget *iface,
1587         const GUID* pguidCmdGroup,
1588         DWORD nCmdID,
1589         DWORD nCmdexecopt,
1590         VARIANT* pvaIn,
1591         VARIANT* pvaOut)
1592 {
1593         _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface);
1594
1595         FIXME(shell, "(%p)->(%p 0x%08lx 0x%08lx %p %p)\n", This, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
1596         return E_NOTIMPL;
1597 }
1598
1599 static ICOM_VTABLE(IOleCommandTarget) ctvt = 
1600 {
1601         ISVOleCmdTarget_QueryInterface,
1602         ISVOleCmdTarget_AddRef,
1603         ISVOleCmdTarget_Release,
1604         ISVOleCmdTarget_QueryStatus,
1605         ISVOleCmdTarget_Exec
1606 };
1607
1608 /****************************************************************************
1609  * ISVDropTarget implementation
1610  */
1611
1612 static HRESULT WINAPI ISVDropTarget_QueryInterface(
1613         IDropTarget *iface,
1614         REFIID riid,
1615         LPVOID *ppvObj)
1616 {
1617         char    xriid[50];
1618
1619         _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1620
1621         WINE_StringFromCLSID((LPCLSID)riid,xriid);
1622
1623         TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
1624
1625         return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
1626 }
1627
1628 static ULONG WINAPI ISVDropTarget_AddRef( IDropTarget *iface)
1629 {
1630         _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1631
1632         TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
1633
1634         return IShellFolder_AddRef((IShellFolder*)This);
1635 }
1636
1637 static ULONG WINAPI ISVDropTarget_Release( IDropTarget *iface)
1638 {
1639         _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1640
1641         TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
1642
1643         return IShellFolder_Release((IShellFolder*)This);
1644 }
1645
1646 static HRESULT WINAPI ISVDropTarget_DragEnter(
1647         IDropTarget     *iface,
1648         IDataObject     *pDataObject,
1649         DWORD           grfKeyState,
1650         POINTL          pt,
1651         DWORD           *pdwEffect)
1652 {       
1653
1654         _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1655
1656         FIXME(shell, "Stub: This=%p, DataObject=%p\n",This,pDataObject);
1657
1658         return E_NOTIMPL;
1659 }
1660
1661 static HRESULT WINAPI ISVDropTarget_DragOver(
1662         IDropTarget     *iface,
1663         DWORD           grfKeyState,
1664         POINTL          pt,
1665         DWORD           *pdwEffect)
1666 {
1667         _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1668
1669         FIXME(shell, "Stub: This=%p\n",This);
1670
1671         return E_NOTIMPL;
1672 }
1673
1674 static HRESULT WINAPI ISVDropTarget_DragLeave(
1675         IDropTarget     *iface)
1676 {
1677         _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1678
1679         FIXME(shell, "Stub: This=%p\n",This);
1680
1681         return E_NOTIMPL;
1682 }
1683
1684 static HRESULT WINAPI ISVDropTarget_Drop(
1685         IDropTarget     *iface,
1686         IDataObject*    pDataObject,
1687         DWORD           grfKeyState,
1688         POINTL          pt,
1689         DWORD           *pdwEffect)
1690 {
1691         _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface);
1692
1693         FIXME(shell, "Stub: This=%p\n",This);
1694
1695         return E_NOTIMPL;
1696 }
1697
1698 static struct ICOM_VTABLE(IDropTarget) dtvt = 
1699 {
1700         ISVDropTarget_QueryInterface,
1701         ISVDropTarget_AddRef,
1702         ISVDropTarget_Release,
1703         ISVDropTarget_DragEnter,
1704         ISVDropTarget_DragOver,
1705         ISVDropTarget_DragLeave,
1706         ISVDropTarget_Drop
1707 };
1708
1709 /****************************************************************************
1710  * ISVViewObject implementation
1711  */
1712
1713 static HRESULT WINAPI ISVViewObject_QueryInterface(
1714         IViewObject *iface,
1715         REFIID riid,
1716         LPVOID *ppvObj)
1717 {
1718         char    xriid[50];
1719
1720         _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
1721
1722         WINE_StringFromCLSID((LPCLSID)riid,xriid);
1723
1724         TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
1725
1726         return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj);
1727 }
1728
1729 static ULONG WINAPI ISVViewObject_AddRef( IViewObject *iface)
1730 {
1731         _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
1732
1733         TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
1734
1735         return IShellFolder_AddRef((IShellFolder*)This);
1736 }
1737
1738 static ULONG WINAPI ISVViewObject_Release( IViewObject *iface)
1739 {
1740         _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
1741
1742         TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
1743
1744         return IShellFolder_Release((IShellFolder*)This);
1745 }
1746
1747 static HRESULT WINAPI ISVViewObject_Draw(
1748         IViewObject     *iface,
1749         DWORD dwDrawAspect,
1750         LONG lindex,
1751         void* pvAspect,
1752         DVTARGETDEVICE* ptd,
1753         HDC hdcTargetDev,
1754         HDC hdcDraw,
1755         LPCRECTL lprcBounds,
1756         LPCRECTL lprcWBounds, 
1757         pfnContinue pfnContinue,
1758         DWORD dwContinue)
1759 {       
1760
1761         _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
1762
1763         FIXME(shell, "Stub: This=%p\n",This);
1764
1765         return E_NOTIMPL;
1766 }
1767 static HRESULT WINAPI ISVViewObject_GetColorSet(
1768         IViewObject     *iface,
1769         DWORD dwDrawAspect,
1770         LONG lindex,
1771         void *pvAspect,
1772         DVTARGETDEVICE* ptd,
1773         HDC hicTargetDevice,
1774         LOGPALETTE** ppColorSet)
1775 {       
1776
1777         _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
1778
1779         FIXME(shell, "Stub: This=%p\n",This);
1780
1781         return E_NOTIMPL;
1782 }
1783 static HRESULT WINAPI ISVViewObject_Freeze(
1784         IViewObject     *iface,
1785         DWORD dwDrawAspect,
1786         LONG lindex,
1787         void* pvAspect,
1788         DWORD* pdwFreeze)
1789 {       
1790
1791         _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
1792
1793         FIXME(shell, "Stub: This=%p\n",This);
1794
1795         return E_NOTIMPL;
1796 }
1797 static HRESULT WINAPI ISVViewObject_Unfreeze(
1798         IViewObject     *iface,
1799         DWORD dwFreeze)
1800 {       
1801
1802         _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
1803
1804         FIXME(shell, "Stub: This=%p\n",This);
1805
1806         return E_NOTIMPL;
1807 }
1808 static HRESULT WINAPI ISVViewObject_SetAdvise(
1809         IViewObject     *iface,
1810         DWORD aspects,
1811         DWORD advf,
1812         IAdviseSink* pAdvSink)
1813 {       
1814
1815         _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
1816
1817         FIXME(shell, "Stub: This=%p\n",This);
1818
1819         return E_NOTIMPL;
1820 }
1821 static HRESULT WINAPI ISVViewObject_GetAdvise(
1822         IViewObject     *iface,
1823         DWORD* pAspects,
1824         DWORD* pAdvf,
1825         IAdviseSink** ppAdvSink)
1826 {       
1827
1828         _ICOM_THIS_From_IViewObject(IShellViewImpl, iface);
1829
1830         FIXME(shell, "Stub: This=%p\n",This);
1831
1832         return E_NOTIMPL;
1833 }
1834
1835
1836 static struct ICOM_VTABLE(IViewObject) vovt = 
1837 {
1838         ISVViewObject_QueryInterface,
1839         ISVViewObject_AddRef,
1840         ISVViewObject_Release,
1841         ISVViewObject_Draw,
1842         ISVViewObject_GetColorSet,
1843         ISVViewObject_Freeze,
1844         ISVViewObject_Unfreeze,
1845         ISVViewObject_SetAdvise,
1846         ISVViewObject_GetAdvise
1847 };
1848