4 * Copyright 1998,1999 <juergen.schmied@debitel.net>
6 * FIXME: when the ShellView_WndProc gets a WM_NCDESTROY should we do a
9 * FIXME: There is still a design problem in this implementation.
10 * This implementation is more or less ok for file system folders
11 * but there are many more kinds of folders.
12 * The shellview is not supposed to know much about the colums
13 * appearing in the view. To fix this it should use the IShellFolder2
14 * interface when possible to get the informations dynamically
15 * this will take a lot of work to implemet and wont likely not
16 * be done in near future
17 * Please considder this when code new features. Mail me if you
18 * are in doubt how to do things. (jsch 25/10/99)
20 * FIXME: Set the buttons in the filedialog according to the view state
27 #include "wine/obj_base.h"
28 #include "wine/obj_shellfolder.h"
29 #include "wine/obj_shellview.h"
30 #include "wine/obj_oleview.h"
31 #include "wine/obj_commdlgbrowser.h"
32 #include "wine/obj_shellbrowser.h"
33 #include "wine/obj_dockingwindowframe.h"
34 #include "wine/obj_extracticon.h"
35 #include "wine/obj_dragdrop.h"
36 #include "wine/undocshell.h"
39 #include "debugtools.h"
44 #include "shell32_main.h"
46 DEFAULT_DEBUG_CHANNEL(shell
)
52 }LISTVIEW_SORT_INFO
, *LPLISTVIEW_SORT_INFO
;
55 { ICOM_VFIELD(IShellView
);
57 ICOM_VTABLE(IOleCommandTarget
)* lpvtblOleCommandTarget
;
58 ICOM_VTABLE(IDropTarget
)* lpvtblDropTarget
;
59 ICOM_VTABLE(IDropSource
)* lpvtblDropSource
;
60 ICOM_VTABLE(IViewObject
)* lpvtblViewObject
;
61 IShellFolder
* pSFParent
;
62 IShellBrowser
* pShellBrowser
;
63 ICommDlgBrowser
* pCommDlgBrowser
;
67 FOLDERSETTINGS FolderSettings
;
72 LISTVIEW_SORT_INFO ListViewSortInfo
;
75 static struct ICOM_VTABLE(IShellView
) svvt
;
77 static struct ICOM_VTABLE(IOleCommandTarget
) ctvt
;
78 #define _IOleCommandTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblOleCommandTarget)))
79 #define _ICOM_THIS_From_IOleCommandTarget(class, name) class* This = (class*)(((char*)name)-_IOleCommandTarget_Offset);
81 static struct ICOM_VTABLE(IDropTarget
) dtvt
;
82 #define _IDropTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropTarget)))
83 #define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
85 static struct ICOM_VTABLE(IDropSource
) dsvt
;
86 #define _IDropSource_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropSource)))
87 #define _ICOM_THIS_From_IDropSource(class, name) class* This = (class*)(((char*)name)-_IDropSource_Offset);
89 static struct ICOM_VTABLE(IViewObject
) vovt
;
90 #define _IViewObject_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblViewObject)))
91 #define _ICOM_THIS_From_IViewObject(class, name) class* This = (class*)(((char*)name)-_IViewObject_Offset);
93 /* ListView Header ID's */
94 #define LISTVIEW_COLUMN_NAME 0
95 #define LISTVIEW_COLUMN_SIZE 1
96 #define LISTVIEW_COLUMN_TYPE 2
97 #define LISTVIEW_COLUMN_TIME 3
98 #define LISTVIEW_COLUMN_ATTRIB 4
101 #define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500)
102 #define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501)
103 #define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502)
105 #define ID_LISTVIEW 2000
107 #define TOOLBAR_ID (L"SHELLDLL_DefView")
109 #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
110 #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
111 #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
113 #define WM_SETTINGCHANGE WM_WININICHANGE
114 extern void WINAPI
_InsertMenuItem (HMENU hmenu
, UINT indexMenu
, BOOL fByPosition
,
115 UINT wID
, UINT fType
, LPSTR dwTypeData
, UINT fState
);
118 Items merged into the toolbar and and the filemenu
127 } MYTOOLINFO
, *LPMYTOOLINFO
;
131 { FCIDM_SHVIEW_BIGICON
, 0, 0, IDS_VIEW_LARGE
, TBSTATE_ENABLED
, TBSTYLE_BUTTON
},
132 { FCIDM_SHVIEW_SMALLICON
, 0, 0, IDS_VIEW_SMALL
, TBSTATE_ENABLED
, TBSTYLE_BUTTON
},
133 { FCIDM_SHVIEW_LISTVIEW
, 0, 0, IDS_VIEW_LIST
, TBSTATE_ENABLED
, TBSTYLE_BUTTON
},
134 { FCIDM_SHVIEW_REPORTVIEW
, 0, 0, IDS_VIEW_DETAILS
, TBSTATE_ENABLED
, TBSTYLE_BUTTON
},
138 typedef void (CALLBACK
*PFNSHGETSETTINGSPROC
)(LPSHELLFLAGSTATE lpsfs
, DWORD dwMask
);
140 /**********************************************************
141 * IShellView_Constructor
143 IShellView
* IShellView_Constructor( IShellFolder
* pFolder
)
144 { IShellViewImpl
* sv
;
145 sv
=(IShellViewImpl
*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IShellViewImpl
));
148 sv
->lpvtblOleCommandTarget
=&ctvt
;
149 sv
->lpvtblDropTarget
=&dtvt
;
150 sv
->lpvtblDropSource
=&dsvt
;
151 sv
->lpvtblViewObject
=&vovt
;
153 sv
->pSFParent
= pFolder
;
156 IShellFolder_AddRef(pFolder
);
158 TRACE("(%p)->(%p)\n",sv
, pFolder
);
160 return (IShellView
*) sv
;
163 /**********************************************************
165 * ##### helperfunctions for communication with ICommDlgBrowser #####
167 static BOOL
IsInCommDlg(IShellViewImpl
* This
)
168 { return(This
->pCommDlgBrowser
!= NULL
);
171 static HRESULT
IncludeObject(IShellViewImpl
* This
, LPCITEMIDLIST pidl
)
175 if ( IsInCommDlg(This
) )
177 TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl
);
178 ret
= ICommDlgBrowser_IncludeObject(This
->pCommDlgBrowser
, (IShellView
*)This
, pidl
);
179 TRACE("--0x%08lx\n", ret
);
184 static HRESULT
OnDefaultCommand(IShellViewImpl
* This
)
186 HRESULT ret
= S_FALSE
;
188 if (IsInCommDlg(This
))
190 TRACE("ICommDlgBrowser::OnDefaultCommand\n");
191 ret
= ICommDlgBrowser_OnDefaultCommand(This
->pCommDlgBrowser
, (IShellView
*)This
);
197 static HRESULT
OnStateChange(IShellViewImpl
* This
, UINT uFlags
)
199 HRESULT ret
= S_FALSE
;
201 if (IsInCommDlg(This
))
203 TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags
);
204 ret
= ICommDlgBrowser_OnStateChange(This
->pCommDlgBrowser
, (IShellView
*)This
, uFlags
);
209 /**********************************************************
210 * set the toolbar of the filedialog buttons
212 static void CheckToolbar(IShellViewImpl
* This
)
218 if (IsInCommDlg(This
))
220 IShellBrowser_SendControlMsg(This
->pShellBrowser
, FCW_TOOLBAR
, TB_CHECKBUTTON
,
221 FCIDM_TB_SMALLICON
, (This
->FolderSettings
.ViewMode
==FVM_LIST
)? TRUE
: FALSE
, &result
);
222 IShellBrowser_SendControlMsg(This
->pShellBrowser
, FCW_TOOLBAR
, TB_CHECKBUTTON
,
223 FCIDM_TB_REPORTVIEW
, (This
->FolderSettings
.ViewMode
==FVM_DETAILS
)? TRUE
: FALSE
, &result
);
224 IShellBrowser_SendControlMsg(This
->pShellBrowser
, FCW_TOOLBAR
, TB_ENABLEBUTTON
,
225 FCIDM_TB_SMALLICON
, TRUE
, &result
);
226 IShellBrowser_SendControlMsg(This
->pShellBrowser
, FCW_TOOLBAR
, TB_ENABLEBUTTON
,
227 FCIDM_TB_REPORTVIEW
, TRUE
, &result
);
231 /**********************************************************
233 * ##### helperfunctions for initializing the view #####
235 /**********************************************************
236 * change the style of the listview control
238 static void SetStyle(IShellViewImpl
* This
, DWORD dwAdd
, DWORD dwRemove
)
242 TRACE("(%p)\n", This
);
244 tmpstyle
= GetWindowLongA(This
->hWndList
, GWL_STYLE
);
245 SetWindowLongA(This
->hWndList
, GWL_STYLE
, dwAdd
| (tmpstyle
& ~dwRemove
));
248 /**********************************************************
249 * ShellView_CreateList()
252 static BOOL
ShellView_CreateList (IShellViewImpl
* This
)
257 dwStyle
= WS_TABSTOP
| WS_VISIBLE
| WS_CHILDWINDOW
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
|
258 LVS_SHAREIMAGELISTS
| LVS_EDITLABELS
| LVS_ALIGNLEFT
| LVS_AUTOARRANGE
;
260 switch (This
->FolderSettings
.ViewMode
)
262 case FVM_ICON
: dwStyle
|= LVS_ICON
; break;
263 case FVM_DETAILS
: dwStyle
|= LVS_REPORT
; break;
264 case FVM_SMALLICON
: dwStyle
|= LVS_SMALLICON
; break;
265 case FVM_LIST
: dwStyle
|= LVS_LIST
; break;
266 default: dwStyle
|= LVS_LIST
; break;
269 if (This
->FolderSettings
.fFlags
&& FWF_AUTOARRANGE
) dwStyle
|= LVS_AUTOARRANGE
;
270 /*if (This->FolderSettings.fFlags && FWF_DESKTOP); used from explorer*/
271 if (This
->FolderSettings
.fFlags
&& FWF_SINGLESEL
) dwStyle
|= LVS_SINGLESEL
;
273 This
->hWndList
=CreateWindowExA( WS_EX_CLIENTEDGE
,
286 This
->ListViewSortInfo
.bIsAscending
= TRUE
;
287 This
->ListViewSortInfo
.nHeaderID
= -1;
288 This
->ListViewSortInfo
.nLastHeaderID
= -1;
290 /* UpdateShellSettings(); */
293 /**********************************************************
294 * ShellView_InitList()
297 * FIXME: the headers should depend on the kind of shellfolder
298 * thats creating the shellview. this hack implements only the
299 * correct headers for a filesystem folder (jsch 25/10/99)
301 static BOOL
ShellView_InitList(IShellViewImpl
* This
)
308 ListView_DeleteAllItems(This
->hWndList
);
310 /*initialize the columns */
311 lvColumn
.mask
= LVCF_FMT
| LVCF_WIDTH
| LVCF_TEXT
; /* | LVCF_SUBITEM;*/
312 lvColumn
.fmt
= LVCFMT_LEFT
;
313 lvColumn
.pszText
= szString
;
316 LoadStringA(shell32_hInstance
, IDS_SHV_COLUMN1
, szString
, sizeof(szString
));
317 ListView_InsertColumnA(This
->hWndList
, 0, &lvColumn
);
320 LoadStringA(shell32_hInstance
, IDS_SHV_COLUMN2
, szString
, sizeof(szString
));
321 ListView_InsertColumnA(This
->hWndList
, 1, &lvColumn
);
324 LoadStringA(shell32_hInstance
, IDS_SHV_COLUMN3
, szString
, sizeof(szString
));
325 ListView_InsertColumnA(This
->hWndList
, 2, &lvColumn
);
328 LoadStringA(shell32_hInstance
, IDS_SHV_COLUMN4
, szString
, sizeof(szString
));
329 ListView_InsertColumnA(This
->hWndList
, 3, &lvColumn
);
331 ListView_SetImageList(This
->hWndList
, ShellSmallIconList
, LVSIL_SMALL
);
332 ListView_SetImageList(This
->hWndList
, ShellBigIconList
, LVSIL_NORMAL
);
336 /**********************************************************
337 * ShellView_CompareItems()
340 * internal, CALLBACK for DSA_Sort
342 static INT CALLBACK
ShellView_CompareItems(LPVOID lParam1
, LPVOID lParam2
, LPARAM lpData
)
345 TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1
, lParam2
, (LPVOID
) lpData
);
347 if(!lpData
) return 0;
349 ret
= (SHORT
) SCODE_CODE(IShellFolder_CompareIDs((LPSHELLFOLDER
)lpData
, 0, (LPITEMIDLIST
)lParam1
, (LPITEMIDLIST
)lParam2
));
350 TRACE("ret=%i\n",ret
);
354 /*************************************************************************
355 * ShellView_ListViewCompareItems
357 * Compare Function for the Listview (FileOpen Dialog)
360 * lParam1 [I] the first ItemIdList to compare with
361 * lParam2 [I] the second ItemIdList to compare with
362 * lpData [I] The column ID for the header Ctrl to process
365 * A negative value if the first item should precede the second,
366 * a positive value if the first item should follow the second,
367 * or zero if the two items are equivalent
370 * FIXME: function does what ShellView_CompareItems is supposed to do.
371 * unify it and figure out how to use the undocumented first parameter
372 * of IShellFolder_CompareIDs to do the job this function does and
373 * move this code to IShellFolder.
374 * make LISTVIEW_SORT_INFO obsolete
375 * the way this function works is only usable if we had only
376 * filesystemfolders (25/10/99 jsch)
378 static INT CALLBACK
ShellView_ListViewCompareItems(LPVOID lParam1
, LPVOID lParam2
, LPARAM lpData
)
382 char strName1
[MAX_PATH
], strName2
[MAX_PATH
];
383 BOOL bIsFolder1
, bIsFolder2
,bIsBothFolder
;
384 LPITEMIDLIST pItemIdList1
= (LPITEMIDLIST
) lParam1
;
385 LPITEMIDLIST pItemIdList2
= (LPITEMIDLIST
) lParam2
;
386 LISTVIEW_SORT_INFO
*pSortInfo
= (LPLISTVIEW_SORT_INFO
) lpData
;
389 bIsFolder1
= _ILIsFolder(pItemIdList1
);
390 bIsFolder2
= _ILIsFolder(pItemIdList2
);
391 bIsBothFolder
= bIsFolder1
&& bIsFolder2
;
393 /* When sorting between a File and a Folder, the Folder gets sorted first */
394 if( (bIsFolder1
|| bIsFolder2
) && !bIsBothFolder
)
396 nDiff
= bIsFolder1
? -1 : 1;
400 /* Sort by Time: Folders or Files can be sorted */
402 if(pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_TIME
)
404 _ILGetFileDateTime(pItemIdList1
, &fd1
);
405 _ILGetFileDateTime(pItemIdList2
, &fd2
);
406 nDiff
= CompareFileTime(&fd2
, &fd1
);
408 /* Sort by Attribute: Folder or Files can be sorted */
409 else if(pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_ATTRIB
)
411 _ILGetAttributeStr(pItemIdList1
, strName1
, MAX_PATH
);
412 _ILGetAttributeStr(pItemIdList2
, strName2
, MAX_PATH
);
413 nDiff
= strcasecmp(strName1
, strName2
);
415 /* Sort by FileName: Folder or Files can be sorted */
416 else if(pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_NAME
|| bIsBothFolder
)
419 _ILSimpleGetText(pItemIdList1
, strName1
, MAX_PATH
);
420 _ILSimpleGetText(pItemIdList2
, strName2
, MAX_PATH
);
421 nDiff
= strcasecmp(strName1
, strName2
);
423 /* Sort by File Size, Only valid for Files */
424 else if(pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_SIZE
)
426 nDiff
= (INT
)(_ILGetFileSize(pItemIdList1
, NULL
, 0) - _ILGetFileSize(pItemIdList2
, NULL
, 0));
428 /* Sort by File Type, Only valid for Files */
429 else if(pSortInfo
->nHeaderID
== LISTVIEW_COLUMN_TYPE
)
432 _ILGetFileType(pItemIdList1
, strName1
, MAX_PATH
);
433 _ILGetFileType(pItemIdList2
, strName2
, MAX_PATH
);
434 nDiff
= strcasecmp(strName1
, strName2
);
437 /* If the Date, FileSize, FileType, Attrib was the same, sort by FileName */
441 _ILSimpleGetText(pItemIdList1
, strName1
, MAX_PATH
);
442 _ILSimpleGetText(pItemIdList2
, strName2
, MAX_PATH
);
443 nDiff
= strcasecmp(strName1
, strName2
);
446 if(!pSortInfo
->bIsAscending
)
455 /**********************************************************
456 * ShellView_FillList()
462 static HRESULT
ShellView_FillList(IShellViewImpl
* This
)
464 LPENUMIDLIST pEnumIDList
;
474 /* get the itemlist from the shfolder*/
475 hRes
= IShellFolder_EnumObjects(This
->pSFParent
,This
->hWnd
, SHCONTF_NONFOLDERS
| SHCONTF_FOLDERS
, &pEnumIDList
);
483 /* create a pointer array */
484 hdpa
= pDPA_Create(16);
487 return(E_OUTOFMEMORY
);
490 /* copy the items into the array*/
491 while((S_OK
== IEnumIDList_Next(pEnumIDList
,1, &pidl
, &dwFetched
)) && dwFetched
)
493 if (pDPA_InsertPtr(hdpa
, 0x7fff, pidl
) == -1)
500 pDPA_Sort(hdpa
, ShellView_CompareItems
, (LPARAM
)This
->pSFParent
);
502 /*turn the listview's redrawing off*/
503 SendMessageA(This
->hWndList
, WM_SETREDRAW
, FALSE
, 0);
505 for (i
=0; i
< DPA_GetPtrCount(hdpa
); ++i
) /* DPA_GetPtrCount is a macro*/
507 pidl
= (LPITEMIDLIST
)DPA_GetPtr(hdpa
, i
);
508 if (IncludeObject(This
, pidl
) == S_OK
) /* in a commdlg This works as a filemask*/
510 ZeroMemory(&lvItem
, sizeof(lvItem
)); /* create the listviewitem*/
511 lvItem
.mask
= LVIF_TEXT
| LVIF_IMAGE
| LVIF_PARAM
; /*set the mask*/
512 lvItem
.iItem
= ListView_GetItemCount(This
->hWndList
); /*add the item to the end of the list*/
513 lvItem
.lParam
= (LPARAM
) pidl
; /*set the item's data*/
514 lvItem
.pszText
= LPSTR_TEXTCALLBACKA
; /*get text on a callback basis*/
515 lvItem
.iImage
= I_IMAGECALLBACK
; /*get the image on a callback basis*/
516 ListView_InsertItemA(This
->hWndList
, &lvItem
);
519 SHFree(pidl
); /* the listview has the COPY*/
522 /*turn the listview's redrawing back on and force it to draw*/
523 SendMessageA(This
->hWndList
, WM_SETREDRAW
, TRUE
, 0);
524 InvalidateRect(This
->hWndList
, NULL
, TRUE
);
525 UpdateWindow(This
->hWndList
);
527 IEnumIDList_Release(pEnumIDList
); /* destroy the list*/
533 /**********************************************************
534 * ShellView_OnCreate()
536 static LRESULT
ShellView_OnCreate(IShellViewImpl
* This
)
543 if(ShellView_CreateList(This
))
545 if(ShellView_InitList(This
))
547 ShellView_FillList(This
);
552 /* This makes a chrash since we havn't called OleInititialize. But if we
553 do this call in DllMain it breaks some apps. The native shell32 does not
554 call OleInitialize and not even depend on ole32.dll.
555 But for some apps it works...*/
556 if (SUCCEEDED(IShellFolder_CreateViewObject(This
->pSFParent
, This
->hWnd
, &IID_IDropTarget
, (LPVOID
*)&pdt
)))
558 pRegisterDragDrop(This
->hWnd
, pdt
);
559 IDropTarget_Release(pdt
);
565 /**********************************************************
566 * #### Handling of the menus ####
569 /**********************************************************
570 * ShellView_BuildFileMenu()
572 static HMENU
ShellView_BuildFileMenu(IShellViewImpl
* This
)
573 { CHAR szText
[MAX_PATH
];
578 TRACE("(%p)\n",This
);
580 hSubMenu
= CreatePopupMenu();
582 { /*get the number of items in our global array*/
583 for(nTools
= 0; Tools
[nTools
].idCommand
!= -1; nTools
++){}
585 /*add the menu items*/
586 for(i
= 0; i
< nTools
; i
++)
588 LoadStringA(shell32_hInstance
, Tools
[i
].idMenuString
, szText
, MAX_PATH
);
590 ZeroMemory(&mii
, sizeof(mii
));
591 mii
.cbSize
= sizeof(mii
);
592 mii
.fMask
= MIIM_TYPE
| MIIM_ID
| MIIM_STATE
;
594 if(TBSTYLE_SEP
!= Tools
[i
].bStyle
) /* no seperator*/
596 mii
.fType
= MFT_STRING
;
597 mii
.fState
= MFS_ENABLED
;
598 mii
.dwTypeData
= szText
;
599 mii
.wID
= Tools
[i
].idCommand
;
603 mii
.fType
= MFT_SEPARATOR
;
605 /* tack This item onto the end of the menu */
606 InsertMenuItemA(hSubMenu
, (UINT
)-1, TRUE
, &mii
);
609 TRACE("-- return (menu=0x%x)\n",hSubMenu
);
612 /**********************************************************
613 * ShellView_MergeFileMenu()
615 static void ShellView_MergeFileMenu(IShellViewImpl
* This
, HMENU hSubMenu
)
616 { TRACE("(%p)->(submenu=0x%08x) stub\n",This
,hSubMenu
);
619 { /*insert This item at the beginning of the menu */
620 _InsertMenuItem(hSubMenu
, 0, TRUE
, 0, MFT_SEPARATOR
, NULL
, MFS_ENABLED
);
621 _InsertMenuItem(hSubMenu
, 0, TRUE
, IDM_MYFILEITEM
, MFT_STRING
, "dummy45", MFS_ENABLED
);
627 /**********************************************************
628 * ShellView_MergeViewMenu()
631 static void ShellView_MergeViewMenu(IShellViewImpl
* This
, HMENU hSubMenu
)
634 TRACE("(%p)->(submenu=0x%08x)\n",This
,hSubMenu
);
637 { /*add a separator at the correct position in the menu*/
638 _InsertMenuItem(hSubMenu
, FCIDM_MENU_VIEW_SEP_OPTIONS
, FALSE
, 0, MFT_SEPARATOR
, NULL
, MFS_ENABLED
);
640 ZeroMemory(&mii
, sizeof(mii
));
641 mii
.cbSize
= sizeof(mii
);
642 mii
.fMask
= MIIM_SUBMENU
| MIIM_TYPE
| MIIM_DATA
;;
643 mii
.fType
= MFT_STRING
;
644 mii
.dwTypeData
= "View";
645 mii
.hSubMenu
= LoadMenuA(shell32_hInstance
, "MENU_001");
646 InsertMenuItemA(hSubMenu
, FCIDM_MENU_VIEW_SEP_OPTIONS
, FALSE
, &mii
);
650 /**********************************************************
651 * ShellView_GetSelections()
654 * number of selected items
656 static UINT
ShellView_GetSelections(IShellViewImpl
* This
)
666 This
->cidl
= ListView_GetSelectedCount(This
->hWndList
);
667 This
->apidl
= (LPITEMIDLIST
*)SHAlloc(This
->cidl
* sizeof(LPITEMIDLIST
));
669 TRACE("selected=%i\n", This
->cidl
);
673 TRACE("-- Items selected =%u\n", This
->cidl
);
675 ZeroMemory(&lvItem
, sizeof(lvItem
));
676 lvItem
.mask
= LVIF_STATE
| LVIF_PARAM
;
677 lvItem
.stateMask
= LVIS_SELECTED
;
679 while(ListView_GetItemA(This
->hWndList
, &lvItem
) && (i
< This
->cidl
))
681 if(lvItem
.state
& LVIS_SELECTED
)
683 This
->apidl
[i
] = (LPITEMIDLIST
)lvItem
.lParam
;
685 TRACE("-- selected Item found\n");
693 /**********************************************************
694 * ShellView_DoContextMenu()
696 static void ShellView_DoContextMenu(IShellViewImpl
* This
, WORD x
, WORD y
, BOOL bDefault
)
700 BOOL fExplore
= FALSE
;
702 LPCONTEXTMENU pContextMenu
= NULL
;
703 IContextMenu
* pCM
= NULL
;
704 CMINVOKECOMMANDINFO cmi
;
706 TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This
, x
, y
, bDefault
);
708 /* look, what's selected and create a context menu object of it*/
709 if( ShellView_GetSelections(This
) )
711 IShellFolder_GetUIObjectOf( This
->pSFParent
, This
->hWndParent
, This
->cidl
, This
->apidl
,
712 (REFIID
)&IID_IContextMenu
, NULL
, (LPVOID
*)&pContextMenu
);
716 TRACE("-- pContextMenu\n");
717 hMenu
= CreatePopupMenu();
721 /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/
722 if(SUCCEEDED(IShellBrowser_GetControlWindow(This
->pShellBrowser
,FCW_TREE
, &hwndTree
)) && hwndTree
)
724 TRACE("-- explore mode\n");
728 /* build the flags depending on what we can do with the selected item */
729 wFlags
= CMF_NORMAL
| (This
->cidl
!= 1 ? 0 : CMF_CANRENAME
) | (fExplore
? CMF_EXPLORE
: 0);
731 /* let the ContextMenu merge its items in */
732 if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu
, hMenu
, 0, FCIDM_SHVIEWFIRST
, FCIDM_SHVIEWLAST
, wFlags
)))
736 TRACE("-- get menu default command\n");
737 uCommand
= GetMenuDefaultItem(hMenu
, FALSE
, GMDI_GOINTOPOPUPS
);
741 TRACE("-- track popup\n");
742 uCommand
= TrackPopupMenu( hMenu
,TPM_LEFTALIGN
| TPM_RETURNCMD
,x
,y
,0,This
->hWnd
,NULL
);
747 TRACE("-- uCommand=%u\n", uCommand
);
748 if (IsInCommDlg(This
) && ((uCommand
==IDM_EXPLORE
) || (uCommand
==IDM_OPEN
)))
750 TRACE("-- dlg: OnDefaultCommand\n");
751 OnDefaultCommand(This
);
755 TRACE("-- explore -- invoke command\n");
756 ZeroMemory(&cmi
, sizeof(cmi
));
757 cmi
.cbSize
= sizeof(cmi
);
758 cmi
.hwnd
= This
->hWndParent
;
759 cmi
.lpVerb
= (LPCSTR
)MAKEINTRESOURCEA(uCommand
);
760 IContextMenu_InvokeCommand(pContextMenu
, &cmi
);
767 IContextMenu_Release(pContextMenu
);
770 else /* background context menu */
772 hMenu
= CreatePopupMenu();
774 pCM
= ISvBgCm_Constructor();
775 IContextMenu_QueryContextMenu(pCM
, hMenu
, 0, FCIDM_SHVIEWFIRST
, FCIDM_SHVIEWLAST
, 0);
777 uCommand
= TrackPopupMenu( hMenu
, TPM_LEFTALIGN
| TPM_RETURNCMD
,x
,y
,0,This
->hWnd
,NULL
);
780 TRACE("-- (%p)->(uCommand=0x%08x )\n",This
, uCommand
);
782 ZeroMemory(&cmi
, sizeof(cmi
));
783 cmi
.cbSize
= sizeof(cmi
);
784 cmi
.lpVerb
= (LPCSTR
)MAKEINTRESOURCEA(uCommand
);
785 cmi
.hwnd
= This
->hWndParent
;
786 IContextMenu_InvokeCommand(pCM
, &cmi
);
788 IContextMenu_Release(pCM
);
792 /**********************************************************
793 * ##### message handling #####
796 /**********************************************************
799 static LRESULT
ShellView_OnSize(IShellViewImpl
* This
, WORD wWidth
, WORD wHeight
)
801 TRACE("%p width=%u height=%u\n",This
, wWidth
,wHeight
);
803 /*resize the ListView to fit our window*/
806 MoveWindow(This
->hWndList
, 0, 0, wWidth
, wHeight
, TRUE
);
811 /**********************************************************
812 * ShellView_OnDeactivate()
817 static void ShellView_OnDeactivate(IShellViewImpl
* This
)
821 if(This
->uState
!= SVUIA_DEACTIVATE
)
825 IShellBrowser_SetMenuSB(This
->pShellBrowser
,0, 0, 0);
826 IShellBrowser_RemoveMenusSB(This
->pShellBrowser
,This
->hMenu
);
827 DestroyMenu(This
->hMenu
);
831 This
->uState
= SVUIA_DEACTIVATE
;
835 /**********************************************************
836 * ShellView_OnActivate()
838 static LRESULT
ShellView_OnActivate(IShellViewImpl
* This
, UINT uState
)
839 { OLEMENUGROUPWIDTHS omw
= { {0, 0, 0, 0, 0, 0} };
841 CHAR szText
[MAX_PATH
];
843 TRACE("%p uState=%x\n",This
,uState
);
845 /*don't do anything if the state isn't really changing */
846 if(This
->uState
== uState
)
851 ShellView_OnDeactivate(This
);
853 /*only do This if we are active */
854 if(uState
!= SVUIA_DEACTIVATE
)
857 This
->hMenu
= CreateMenu();
861 IShellBrowser_InsertMenusSB(This
->pShellBrowser
, This
->hMenu
, &omw
);
862 TRACE("-- after fnInsertMenusSB\n");
864 /*build the top level menu get the menu item's text*/
865 strcpy(szText
,"dummy 31");
867 ZeroMemory(&mii
, sizeof(mii
));
868 mii
.cbSize
= sizeof(mii
);
869 mii
.fMask
= MIIM_SUBMENU
| MIIM_TYPE
| MIIM_STATE
;
870 mii
.fType
= MFT_STRING
;
871 mii
.fState
= MFS_ENABLED
;
872 mii
.dwTypeData
= szText
;
873 mii
.hSubMenu
= ShellView_BuildFileMenu(This
);
875 /*insert our menu into the menu bar*/
878 InsertMenuItemA(This
->hMenu
, FCIDM_MENU_HELP
, FALSE
, &mii
);
881 /*get the view menu so we can merge with it*/
882 ZeroMemory(&mii
, sizeof(mii
));
883 mii
.cbSize
= sizeof(mii
);
884 mii
.fMask
= MIIM_SUBMENU
;
886 if(GetMenuItemInfoA(This
->hMenu
, FCIDM_MENU_VIEW
, FALSE
, &mii
))
888 ShellView_MergeViewMenu(This
, mii
.hSubMenu
);
891 /*add the items that should only be added if we have the focus*/
892 if(SVUIA_ACTIVATE_FOCUS
== uState
)
894 /*get the file menu so we can merge with it */
895 ZeroMemory(&mii
, sizeof(mii
));
896 mii
.cbSize
= sizeof(mii
);
897 mii
.fMask
= MIIM_SUBMENU
;
899 if(GetMenuItemInfoA(This
->hMenu
, FCIDM_MENU_FILE
, FALSE
, &mii
))
901 ShellView_MergeFileMenu(This
, mii
.hSubMenu
);
904 TRACE("-- before fnSetMenuSB\n");
905 IShellBrowser_SetMenuSB(This
->pShellBrowser
, This
->hMenu
, 0, This
->hWnd
);
908 This
->uState
= uState
;
913 /**********************************************************
914 * ShellView_OnSetFocus()
917 static LRESULT
ShellView_OnSetFocus(IShellViewImpl
* This
)
921 /* Tell the browser one of our windows has received the focus. This
922 should always be done before merging menus (OnActivate merges the
923 menus) if one of our windows has the focus.*/
925 IShellBrowser_OnViewWindowActive(This
->pShellBrowser
,(IShellView
*) This
);
926 ShellView_OnActivate(This
, SVUIA_ACTIVATE_FOCUS
);
928 /* Set the focus to the listview */
929 SetFocus(This
->hWndList
);
931 /* Notify the ICommDlgBrowser interface */
932 OnStateChange(This
,CDBOSC_SETFOCUS
);
937 /**********************************************************
938 * ShellView_OnKillFocus()
940 static LRESULT
ShellView_OnKillFocus(IShellViewImpl
* This
)
942 TRACE("(%p) stub\n",This
);
944 ShellView_OnActivate(This
, SVUIA_ACTIVATE_NOFOCUS
);
945 /* Notify the ICommDlgBrowser */
946 OnStateChange(This
,CDBOSC_KILLFOCUS
);
951 /**********************************************************
952 * ShellView_OnCommand()
955 * the CmdID's are the ones from the context menu
957 static LRESULT
ShellView_OnCommand(IShellViewImpl
* This
,DWORD dwCmdID
, DWORD dwCmd
, HWND hwndCmd
)
959 TRACE("(%p)->(0x%08lx 0x%08lx 0x%08x) stub\n",This
, dwCmdID
, dwCmd
, hwndCmd
);
963 case FCIDM_SHVIEW_SMALLICON
:
964 This
->FolderSettings
.ViewMode
= FVM_SMALLICON
;
965 SetStyle (This
, LVS_SMALLICON
, LVS_TYPEMASK
);
969 case FCIDM_SHVIEW_BIGICON
:
970 This
->FolderSettings
.ViewMode
= FVM_ICON
;
971 SetStyle (This
, LVS_ICON
, LVS_TYPEMASK
);
975 case FCIDM_SHVIEW_LISTVIEW
:
976 This
->FolderSettings
.ViewMode
= FVM_LIST
;
977 SetStyle (This
, LVS_LIST
, LVS_TYPEMASK
);
981 case FCIDM_SHVIEW_REPORTVIEW
:
982 This
->FolderSettings
.ViewMode
= FVM_DETAILS
;
983 SetStyle (This
, LVS_REPORT
, LVS_TYPEMASK
);
987 /* the menu-ID's for sorting are 0x30... see shrec.rc */
992 This
->ListViewSortInfo
.nHeaderID
= (LPARAM
) (dwCmdID
- 0x30);
993 This
->ListViewSortInfo
.bIsAscending
= TRUE
;
994 This
->ListViewSortInfo
.nLastHeaderID
= This
->ListViewSortInfo
.nHeaderID
;
995 ListView_SortItems(This
->hWndList
, ShellView_ListViewCompareItems
, (LPARAM
) (&(This
->ListViewSortInfo
)));
999 TRACE("-- COMMAND 0x%04lx unhandled\n", dwCmdID
);
1004 /**********************************************************
1005 * ShellView_OnNotify()
1008 static LRESULT
ShellView_OnNotify(IShellViewImpl
* This
, UINT CtlID
, LPNMHDR lpnmh
)
1009 { LPNMLISTVIEW lpnmlv
= (LPNMLISTVIEW
)lpnmh
;
1010 NMLVDISPINFOA
*lpdi
= (NMLVDISPINFOA
*)lpnmh
;
1014 TRACE("%p CtlID=%u lpnmh->code=%x\n",This
,CtlID
,lpnmh
->code
);
1019 TRACE("-- NM_SETFOCUS %p\n",This
);
1020 ShellView_OnSetFocus(This
);
1024 TRACE("-- NM_KILLFOCUS %p\n",This
);
1025 ShellView_OnDeactivate(This
);
1026 /* Notify the ICommDlgBrowser interface */
1027 OnStateChange(This
,CDBOSC_KILLFOCUS
);
1031 TRACE("-- HDN_ENDTRACKA %p\n",This
);
1032 /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0);
1033 nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/
1036 case LVN_DELETEITEM
:
1037 TRACE("-- LVN_DELETEITEM %p\n",This
);
1038 SHFree((LPITEMIDLIST
)lpnmlv
->lParam
); /*delete the pidl because we made a copy of it*/
1041 case LVN_ITEMACTIVATE
:
1042 TRACE("-- LVN_ITEMACTIVATE %p\n",This
);
1043 OnStateChange(This
, CDBOSC_SELCHANGE
); /* the browser will get the IDataObject now */
1044 ShellView_DoContextMenu(This
, 0, 0, TRUE
);
1047 case LVN_COLUMNCLICK
:
1048 This
->ListViewSortInfo
.nHeaderID
= lpnmlv
->iSubItem
;
1049 if(This
->ListViewSortInfo
.nLastHeaderID
== This
->ListViewSortInfo
.nHeaderID
)
1051 This
->ListViewSortInfo
.bIsAscending
= !This
->ListViewSortInfo
.bIsAscending
;
1055 This
->ListViewSortInfo
.bIsAscending
= TRUE
;
1057 This
->ListViewSortInfo
.nLastHeaderID
= This
->ListViewSortInfo
.nHeaderID
;
1059 ListView_SortItems(lpnmlv
->hdr
.hwndFrom
, ShellView_ListViewCompareItems
, (LPARAM
) (&(This
->ListViewSortInfo
)));
1062 case LVN_GETDISPINFOA
:
1063 TRACE("-- LVN_GETDISPINFOA %p\n",This
);
1064 pidl
= (LPITEMIDLIST
)lpdi
->item
.lParam
;
1067 if(lpdi
->item
.iSubItem
) /*is the sub-item information being requested?*/
1068 { if(lpdi
->item
.mask
& LVIF_TEXT
) /*is the text being requested?*/
1069 { if(_ILIsValue(pidl
)) /*is This a value or a folder?*/
1070 { switch (lpdi
->item
.iSubItem
)
1071 { case 1: /* size */
1072 _ILGetFileSize (pidl
, lpdi
->item
.pszText
, lpdi
->item
.cchTextMax
);
1074 case 2: /* extension */
1076 if (_ILGetExtension (pidl
, sTemp
, 64))
1077 { if (!( HCR_MapTypeToValue(sTemp
, sTemp
, 64, TRUE
)
1078 && HCR_MapTypeToValue(sTemp
, lpdi
->item
.pszText
, lpdi
->item
.cchTextMax
, FALSE
)))
1079 { lstrcpynA (lpdi
->item
.pszText
, sTemp
, lpdi
->item
.cchTextMax
);
1080 strncat (lpdi
->item
.pszText
, "-file", lpdi
->item
.cchTextMax
);
1083 else /* no extension found */
1084 { lpdi
->item
.pszText
[0]=0x00;
1089 _ILGetFileDate (pidl
, lpdi
->item
.pszText
, lpdi
->item
.cchTextMax
);
1093 else /*its a folder*/
1094 { switch (lpdi
->item
.iSubItem
)
1096 strcpy(lpdi
->item
.pszText
, "");
1099 lstrcpynA (lpdi
->item
.pszText
, "Folder", lpdi
->item
.cchTextMax
);
1102 _ILGetFileDate (pidl
, lpdi
->item
.pszText
, lpdi
->item
.cchTextMax
);
1106 TRACE("-- text=%s\n",lpdi
->item
.pszText
);
1109 else /*the item text is being requested*/
1111 if(lpdi
->item
.mask
& LVIF_TEXT
) /*is the text being requested?*/
1113 if(SUCCEEDED(IShellFolder_GetDisplayNameOf(This
->pSFParent
,pidl
, SHGDN_NORMAL
| SHGDN_INFOLDER
, &str
)))
1115 StrRetToStrNA(lpdi
->item
.pszText
, lpdi
->item
.cchTextMax
, &str
, pidl
);
1117 TRACE("-- text=%s\n",lpdi
->item
.pszText
);
1120 if(lpdi
->item
.mask
& LVIF_IMAGE
) /*is the image being requested?*/
1122 lpdi
->item
.iImage
= SHMapPIDLToSystemImageListIndex(This
->pSFParent
, pidl
, 0);
1127 case LVN_ITEMCHANGED
:
1128 TRACE("-- LVN_ITEMCHANGED %p\n",This
);
1129 OnStateChange(This
, CDBOSC_SELCHANGE
); /* the browser will get the IDataObject now */
1133 case LVN_BEGINRDRAG
:
1135 if (ShellView_GetSelections(This
))
1139 DWORD dwEffect
= DROPEFFECT_COPY
| DROPEFFECT_MOVE
;
1141 if (SUCCEEDED(IShellFolder_GetUIObjectOf(This
->pSFParent
, This
->hWnd
, This
->cidl
, This
->apidl
, &IID_IDataObject
,0,(LPVOID
*)&pda
)))
1143 IDropSource
* pds
= (IDropSource
*)&(This
->lpvtblDropSource
); /* own DropSource interface */
1145 if (SUCCEEDED(IShellFolder_GetAttributesOf(This
->pSFParent
, This
->cidl
, This
->apidl
, &dwAttributes
)))
1147 if (dwAttributes
& SFGAO_CANLINK
)
1149 dwEffect
|= DROPEFFECT_LINK
;
1156 pDoDragDrop(pda
, pds
, dwEffect
, &dwEffect
);
1159 IDataObject_Release(pda
);
1164 case LVN_BEGINLABELEDITA
:
1165 case LVN_ENDLABELEDITA
:
1166 FIXME("labeledit\n");
1170 TRACE("-- %p WM_COMMAND %s unhandled\n", This
, SPY_GetMsgName(lpnmh
->code
));
1176 /**********************************************************
1180 static LRESULT CALLBACK
ShellView_WndProc(HWND hWnd
, UINT uMessage
, WPARAM wParam
, LPARAM lParam
)
1182 IShellViewImpl
* pThis
= (IShellViewImpl
*)GetWindowLongA(hWnd
, GWL_USERDATA
);
1183 LPCREATESTRUCTA lpcs
;
1185 TRACE("(hwnd=%x msg=%x wparm=%x lparm=%lx)\n",hWnd
, uMessage
, wParam
, lParam
);
1190 lpcs
= (LPCREATESTRUCTA
)lParam
;
1191 pThis
= (IShellViewImpl
*)(lpcs
->lpCreateParams
);
1192 SetWindowLongA(hWnd
, GWL_USERDATA
, (LONG
)pThis
);
1193 pThis
->hWnd
= hWnd
; /*set the window handle*/
1196 case WM_SIZE
: return ShellView_OnSize(pThis
,LOWORD(lParam
), HIWORD(lParam
));
1197 case WM_SETFOCUS
: return ShellView_OnSetFocus(pThis
);
1198 case WM_KILLFOCUS
: return ShellView_OnKillFocus(pThis
);
1199 case WM_CREATE
: return ShellView_OnCreate(pThis
);
1200 case WM_ACTIVATE
: return ShellView_OnActivate(pThis
, SVUIA_ACTIVATE_FOCUS
);
1201 case WM_NOTIFY
: return ShellView_OnNotify(pThis
,(UINT
)wParam
, (LPNMHDR
)lParam
);
1202 case WM_COMMAND
: return ShellView_OnCommand(pThis
,
1203 GET_WM_COMMAND_ID(wParam
, lParam
),
1204 GET_WM_COMMAND_CMD(wParam
, lParam
),
1205 GET_WM_COMMAND_HWND(wParam
, lParam
));
1207 case WM_CONTEXTMENU
: ShellView_DoContextMenu(pThis
, LOWORD(lParam
), HIWORD(lParam
), FALSE
);
1210 case WM_SHOWWINDOW
: UpdateWindow(pThis
->hWndList
);
1213 case WM_GETDLGCODE
: return SendMessageA(pThis
->hWndList
,uMessage
,0,0);
1215 case WM_DESTROY
: pRevokeDragDrop(pThis
->hWnd
);
1219 return DefWindowProcA (hWnd
, uMessage
, wParam
, lParam
);
1221 /**********************************************************
1224 * The INTERFACE of the IShellView object
1227 **********************************************************
1228 * IShellView_QueryInterface
1230 static HRESULT WINAPI
IShellView_fnQueryInterface(IShellView
* iface
,REFIID riid
, LPVOID
*ppvObj
)
1232 ICOM_THIS(IShellViewImpl
, iface
);
1235 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
1236 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,xriid
,ppvObj
);
1240 if(IsEqualIID(riid
, &IID_IUnknown
))
1244 else if(IsEqualIID(riid
, &IID_IShellView
))
1246 *ppvObj
= (IShellView
*)This
;
1248 else if(IsEqualIID(riid
, &IID_IOleCommandTarget
))
1250 *ppvObj
= (IOleCommandTarget
*)&(This
->lpvtblOleCommandTarget
);
1252 else if(IsEqualIID(riid
, &IID_IDropTarget
))
1254 *ppvObj
= (IDropTarget
*)&(This
->lpvtblDropTarget
);
1256 else if(IsEqualIID(riid
, &IID_IDropSource
))
1258 *ppvObj
= (IDropSource
*)&(This
->lpvtblDropSource
);
1260 else if(IsEqualIID(riid
, &IID_IViewObject
))
1262 *ppvObj
= (IViewObject
*)&(This
->lpvtblViewObject
);
1267 IUnknown_AddRef( (IUnknown
*)*ppvObj
);
1268 TRACE("-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
1271 TRACE("-- Interface: E_NOINTERFACE\n");
1272 return E_NOINTERFACE
;
1275 /**********************************************************
1278 static ULONG WINAPI
IShellView_fnAddRef(IShellView
* iface
)
1280 ICOM_THIS(IShellViewImpl
, iface
);
1282 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1285 return ++(This
->ref
);
1287 /**********************************************************
1288 * IShellView_Release
1290 static ULONG WINAPI
IShellView_fnRelease(IShellView
* iface
)
1292 ICOM_THIS(IShellViewImpl
, iface
);
1294 TRACE("(%p)->()\n",This
);
1300 TRACE(" destroying IShellView(%p)\n",This
);
1303 IShellFolder_Release(This
->pSFParent
);
1306 SHFree(This
->apidl
);
1308 if (This
->pCommDlgBrowser
)
1309 ICommDlgBrowser_Release(This
->pCommDlgBrowser
);
1311 HeapFree(GetProcessHeap(),0,This
);
1317 /**********************************************************
1318 * ShellView_GetWindow
1320 static HRESULT WINAPI
IShellView_fnGetWindow(IShellView
* iface
,HWND
* phWnd
)
1322 ICOM_THIS(IShellViewImpl
, iface
);
1324 TRACE("(%p)\n",This
);
1326 *phWnd
= This
->hWnd
;
1331 static HRESULT WINAPI
IShellView_fnContextSensitiveHelp(IShellView
* iface
,BOOL fEnterMode
)
1333 ICOM_THIS(IShellViewImpl
, iface
);
1335 FIXME("(%p) stub\n",This
);
1340 /**********************************************************
1341 * IShellView_TranslateAccelerator
1344 * use the accel functions
1346 static HRESULT WINAPI
IShellView_fnTranslateAccelerator(IShellView
* iface
,LPMSG lpmsg
)
1348 ICOM_THIS(IShellViewImpl
, iface
);
1351 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This
,lpmsg
, lpmsg
->hwnd
, lpmsg
->message
, lpmsg
->lParam
, lpmsg
->wParam
);
1354 if ((lpmsg
->message
>=WM_KEYFIRST
) && (lpmsg
->message
>=WM_KEYLAST
))
1356 TRACE("-- key=0x04%x",lpmsg
->wParam
) ;
1358 return S_FALSE
; /* not handled */
1361 static HRESULT WINAPI
IShellView_fnEnableModeless(IShellView
* iface
,BOOL fEnable
)
1363 ICOM_THIS(IShellViewImpl
, iface
);
1365 FIXME("(%p) stub\n",This
);
1370 static HRESULT WINAPI
IShellView_fnUIActivate(IShellView
* iface
,UINT uState
)
1372 ICOM_THIS(IShellViewImpl
, iface
);
1375 CHAR szName[MAX_PATH];
1378 int nPartArray
[1] = {-1};
1380 TRACE("(%p)->(state=%x) stub\n",This
, uState
);
1382 /*don't do anything if the state isn't really changing*/
1383 if(This
->uState
== uState
)
1388 /*OnActivate handles the menu merging and internal state*/
1389 ShellView_OnActivate(This
, uState
);
1391 /*only do This if we are active*/
1392 if(uState
!= SVUIA_DEACTIVATE
)
1396 GetFolderPath is not a method of IShellFolder
1397 IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) );
1399 /* set the number of parts */
1400 IShellBrowser_SendControlMsg(This
->pShellBrowser
, FCW_STATUS
, SB_SETPARTS
, 1,
1401 (LPARAM
)nPartArray
, &lResult
);
1403 /* set the text for the parts */
1405 IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA,
1406 0, (LPARAM)szName, &lResult);
1413 static HRESULT WINAPI
IShellView_fnRefresh(IShellView
* iface
)
1415 ICOM_THIS(IShellViewImpl
, iface
);
1417 TRACE("(%p)\n",This
);
1419 ListView_DeleteAllItems(This
->hWndList
);
1420 ShellView_FillList(This
);
1425 static HRESULT WINAPI
IShellView_fnCreateViewWindow(
1427 IShellView
*lpPrevView
,
1428 LPCFOLDERSETTINGS lpfs
,
1429 IShellBrowser
* psb
,
1433 ICOM_THIS(IShellViewImpl
, iface
);
1439 TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This
, lpPrevView
,lpfs
, psb
, prcView
, phWnd
);
1440 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
);
1442 /*set up the member variables*/
1443 This
->pShellBrowser
= psb
;
1444 This
->FolderSettings
= *lpfs
;
1446 /*get our parent window*/
1447 IShellBrowser_AddRef(This
->pShellBrowser
);
1448 IShellBrowser_GetWindow(This
->pShellBrowser
, &(This
->hWndParent
));
1450 /* try to get the ICommDlgBrowserInterface, adds a reference !!! */
1451 This
->pCommDlgBrowser
=NULL
;
1452 if ( SUCCEEDED (IShellBrowser_QueryInterface( This
->pShellBrowser
,
1453 (REFIID
)&IID_ICommDlgBrowser
, (LPVOID
*) &This
->pCommDlgBrowser
)))
1455 TRACE("-- CommDlgBrowser\n");
1458 /*if our window class has not been registered, then do so*/
1459 if(!GetClassInfoA(shell32_hInstance
, SV_CLASS_NAME
, &wc
))
1461 ZeroMemory(&wc
, sizeof(wc
));
1462 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
1463 wc
.lpfnWndProc
= (WNDPROC
) ShellView_WndProc
;
1466 wc
.hInstance
= shell32_hInstance
;
1468 wc
.hCursor
= LoadCursorA (0, IDC_ARROWA
);
1469 wc
.hbrBackground
= (HBRUSH
) (COLOR_WINDOW
+ 1);
1470 wc
.lpszMenuName
= NULL
;
1471 wc
.lpszClassName
= SV_CLASS_NAME
;
1473 if(!RegisterClassA(&wc
))
1477 *phWnd
= CreateWindowExA(0,
1480 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_TABSTOP
,
1483 prcView
->right
- prcView
->left
,
1484 prcView
->bottom
- prcView
->top
,
1498 static HRESULT WINAPI
IShellView_fnDestroyViewWindow(IShellView
* iface
)
1500 ICOM_THIS(IShellViewImpl
, iface
);
1502 TRACE("(%p)\n",This
);
1504 /*Make absolutely sure all our UI is cleaned up.*/
1505 IShellView_UIActivate((IShellView
*)This
, SVUIA_DEACTIVATE
);
1509 DestroyMenu(This
->hMenu
);
1512 DestroyWindow(This
->hWnd
);
1513 IShellBrowser_Release(This
->pShellBrowser
);
1518 static HRESULT WINAPI
IShellView_fnGetCurrentInfo(IShellView
* iface
, LPFOLDERSETTINGS lpfs
)
1520 ICOM_THIS(IShellViewImpl
, iface
);
1522 TRACE("(%p)->(%p) vmode=%x flags=%x\n",This
, lpfs
,
1523 This
->FolderSettings
.ViewMode
, This
->FolderSettings
.fFlags
);
1525 if (!lpfs
) return E_INVALIDARG
;
1527 *lpfs
= This
->FolderSettings
;
1531 static HRESULT WINAPI
IShellView_fnAddPropertySheetPages(IShellView
* iface
, DWORD dwReserved
,LPFNADDPROPSHEETPAGE lpfn
, LPARAM lparam
)
1533 ICOM_THIS(IShellViewImpl
, iface
);
1535 FIXME("(%p) stub\n",This
);
1540 static HRESULT WINAPI
IShellView_fnSaveViewState(IShellView
* iface
)
1542 ICOM_THIS(IShellViewImpl
, iface
);
1544 FIXME("(%p) stub\n",This
);
1549 static HRESULT WINAPI
IShellView_fnSelectItem(IShellView
* iface
, LPCITEMIDLIST pidlItem
, UINT uFlags
)
1550 { ICOM_THIS(IShellViewImpl
, iface
);
1552 FIXME("(%p)->(pidl=%p, 0x%08x) stub\n",This
, pidlItem
, uFlags
);
1557 static HRESULT WINAPI
IShellView_fnGetItemObject(IShellView
* iface
, UINT uItem
, REFIID riid
, LPVOID
*ppvOut
)
1559 ICOM_THIS(IShellViewImpl
, iface
);
1563 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
1564 TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This
, uItem
, xriid
, ppvOut
);
1570 case SVGIO_BACKGROUND
:
1571 *ppvOut
= ISvBgCm_Constructor();
1574 case SVGIO_SELECTION
:
1575 ShellView_GetSelections(This
);
1576 IShellFolder_GetUIObjectOf(This
->pSFParent
, This
->hWnd
, This
->cidl
, This
->apidl
, riid
, 0, ppvOut
);
1579 TRACE("-- (%p)->(interface=%p)\n",This
, *ppvOut
);
1581 if(!*ppvOut
) return E_OUTOFMEMORY
;
1586 static struct ICOM_VTABLE(IShellView
) svvt
=
1588 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1589 IShellView_fnQueryInterface
,
1590 IShellView_fnAddRef
,
1591 IShellView_fnRelease
,
1592 IShellView_fnGetWindow
,
1593 IShellView_fnContextSensitiveHelp
,
1594 IShellView_fnTranslateAccelerator
,
1595 IShellView_fnEnableModeless
,
1596 IShellView_fnUIActivate
,
1597 IShellView_fnRefresh
,
1598 IShellView_fnCreateViewWindow
,
1599 IShellView_fnDestroyViewWindow
,
1600 IShellView_fnGetCurrentInfo
,
1601 IShellView_fnAddPropertySheetPages
,
1602 IShellView_fnSaveViewState
,
1603 IShellView_fnSelectItem
,
1604 IShellView_fnGetItemObject
1608 /**********************************************************
1609 * ISVOleCmdTarget_QueryInterface (IUnknown)
1611 static HRESULT WINAPI
ISVOleCmdTarget_QueryInterface(
1612 IOleCommandTarget
* iface
,
1616 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl
, iface
);
1618 return IShellFolder_QueryInterface((IShellFolder
*)This
, iid
, ppvObj
);
1621 /**********************************************************
1622 * ISVOleCmdTarget_AddRef (IUnknown)
1624 static ULONG WINAPI
ISVOleCmdTarget_AddRef(
1625 IOleCommandTarget
* iface
)
1627 _ICOM_THIS_From_IOleCommandTarget(IShellFolder
, iface
);
1629 return IShellFolder_AddRef((IShellFolder
*)This
);
1632 /**********************************************************
1633 * ISVOleCmdTarget_Release (IUnknown)
1635 static ULONG WINAPI
ISVOleCmdTarget_Release(
1636 IOleCommandTarget
* iface
)
1638 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl
, iface
);
1640 return IShellFolder_Release((IShellFolder
*)This
);
1643 /**********************************************************
1644 * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
1646 static HRESULT WINAPI
ISVOleCmdTarget_QueryStatus(
1647 IOleCommandTarget
*iface
,
1648 const GUID
* pguidCmdGroup
,
1651 OLECMDTEXT
* pCmdText
)
1655 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl
, iface
);
1657 WINE_StringFromCLSID((LPCLSID
)pguidCmdGroup
,xguid
);
1659 FIXME("(%p)->(%p(%s) 0x%08lx %p %p\n", This
, pguidCmdGroup
, xguid
, cCmds
, prgCmds
, pCmdText
);
1663 /**********************************************************
1664 * ISVOleCmdTarget_Exec (IOleCommandTarget)
1666 * nCmdID is the OLECMDID_* enumeration
1668 static HRESULT WINAPI
ISVOleCmdTarget_Exec(
1669 IOleCommandTarget
*iface
,
1670 const GUID
* pguidCmdGroup
,
1678 _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl
, iface
);
1680 WINE_StringFromCLSID((LPCLSID
)pguidCmdGroup
,xguid
);
1682 FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08lx Opt:0x%08lx %p %p)\n", This
, xguid
, nCmdID
, nCmdexecopt
, pvaIn
, pvaOut
);
1686 static ICOM_VTABLE(IOleCommandTarget
) ctvt
=
1688 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1689 ISVOleCmdTarget_QueryInterface
,
1690 ISVOleCmdTarget_AddRef
,
1691 ISVOleCmdTarget_Release
,
1692 ISVOleCmdTarget_QueryStatus
,
1693 ISVOleCmdTarget_Exec
1696 /**********************************************************
1697 * ISVDropTarget implementation
1700 static HRESULT WINAPI
ISVDropTarget_QueryInterface(
1707 _ICOM_THIS_From_IDropTarget(IShellViewImpl
, iface
);
1709 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
1711 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,xriid
,ppvObj
);
1713 return IShellFolder_QueryInterface((IShellFolder
*)This
, riid
, ppvObj
);
1716 static ULONG WINAPI
ISVDropTarget_AddRef( IDropTarget
*iface
)
1718 _ICOM_THIS_From_IDropTarget(IShellViewImpl
, iface
);
1720 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1722 return IShellFolder_AddRef((IShellFolder
*)This
);
1725 static ULONG WINAPI
ISVDropTarget_Release( IDropTarget
*iface
)
1727 _ICOM_THIS_From_IDropTarget(IShellViewImpl
, iface
);
1729 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1731 return IShellFolder_Release((IShellFolder
*)This
);
1734 static HRESULT WINAPI
ISVDropTarget_DragEnter(
1736 IDataObject
*pDataObject
,
1742 _ICOM_THIS_From_IDropTarget(IShellViewImpl
, iface
);
1744 FIXME("Stub: This=%p, DataObject=%p\n",This
,pDataObject
);
1749 static HRESULT WINAPI
ISVDropTarget_DragOver(
1755 _ICOM_THIS_From_IDropTarget(IShellViewImpl
, iface
);
1757 FIXME("Stub: This=%p\n",This
);
1762 static HRESULT WINAPI
ISVDropTarget_DragLeave(
1765 _ICOM_THIS_From_IDropTarget(IShellViewImpl
, iface
);
1767 FIXME("Stub: This=%p\n",This
);
1772 static HRESULT WINAPI
ISVDropTarget_Drop(
1774 IDataObject
* pDataObject
,
1779 _ICOM_THIS_From_IDropTarget(IShellViewImpl
, iface
);
1781 FIXME("Stub: This=%p\n",This
);
1786 static struct ICOM_VTABLE(IDropTarget
) dtvt
=
1788 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1789 ISVDropTarget_QueryInterface
,
1790 ISVDropTarget_AddRef
,
1791 ISVDropTarget_Release
,
1792 ISVDropTarget_DragEnter
,
1793 ISVDropTarget_DragOver
,
1794 ISVDropTarget_DragLeave
,
1798 /**********************************************************
1799 * ISVDropSource implementation
1802 static HRESULT WINAPI
ISVDropSource_QueryInterface(
1809 _ICOM_THIS_From_IDropSource(IShellViewImpl
, iface
);
1811 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
1813 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,xriid
,ppvObj
);
1815 return IShellFolder_QueryInterface((IShellFolder
*)This
, riid
, ppvObj
);
1818 static ULONG WINAPI
ISVDropSource_AddRef( IDropSource
*iface
)
1820 _ICOM_THIS_From_IDropSource(IShellViewImpl
, iface
);
1822 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1824 return IShellFolder_AddRef((IShellFolder
*)This
);
1827 static ULONG WINAPI
ISVDropSource_Release( IDropSource
*iface
)
1829 _ICOM_THIS_From_IDropSource(IShellViewImpl
, iface
);
1831 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1833 return IShellFolder_Release((IShellFolder
*)This
);
1835 static HRESULT WINAPI
ISVDropSource_QueryContinueDrag(
1837 BOOL fEscapePressed
,
1840 _ICOM_THIS_From_IDropSource(IShellViewImpl
, iface
);
1841 TRACE("(%p)\n",This
);
1844 return DRAGDROP_S_CANCEL
;
1845 else if (!(grfKeyState
& MK_LBUTTON
) && !(grfKeyState
& MK_RBUTTON
))
1846 return DRAGDROP_S_DROP
;
1851 static HRESULT WINAPI
ISVDropSource_GiveFeedback(
1855 _ICOM_THIS_From_IDropSource(IShellViewImpl
, iface
);
1856 TRACE("(%p)\n",This
);
1858 return DRAGDROP_S_USEDEFAULTCURSORS
;
1861 static struct ICOM_VTABLE(IDropSource
) dsvt
=
1863 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1864 ISVDropSource_QueryInterface
,
1865 ISVDropSource_AddRef
,
1866 ISVDropSource_Release
,
1867 ISVDropSource_QueryContinueDrag
,
1868 ISVDropSource_GiveFeedback
1870 /**********************************************************
1871 * ISVViewObject implementation
1874 static HRESULT WINAPI
ISVViewObject_QueryInterface(
1881 _ICOM_THIS_From_IViewObject(IShellViewImpl
, iface
);
1883 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
1885 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This
,xriid
,ppvObj
);
1887 return IShellFolder_QueryInterface((IShellFolder
*)This
, riid
, ppvObj
);
1890 static ULONG WINAPI
ISVViewObject_AddRef( IViewObject
*iface
)
1892 _ICOM_THIS_From_IViewObject(IShellViewImpl
, iface
);
1894 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1896 return IShellFolder_AddRef((IShellFolder
*)This
);
1899 static ULONG WINAPI
ISVViewObject_Release( IViewObject
*iface
)
1901 _ICOM_THIS_From_IViewObject(IShellViewImpl
, iface
);
1903 TRACE("(%p)->(count=%lu)\n",This
,This
->ref
);
1905 return IShellFolder_Release((IShellFolder
*)This
);
1908 static HRESULT WINAPI
ISVViewObject_Draw(
1913 DVTARGETDEVICE
* ptd
,
1916 LPCRECTL lprcBounds
,
1917 LPCRECTL lprcWBounds
,
1918 IVO_ContCallback pfnContinue
,
1922 _ICOM_THIS_From_IViewObject(IShellViewImpl
, iface
);
1924 FIXME("Stub: This=%p\n",This
);
1928 static HRESULT WINAPI
ISVViewObject_GetColorSet(
1933 DVTARGETDEVICE
* ptd
,
1934 HDC hicTargetDevice
,
1935 LOGPALETTE
** ppColorSet
)
1938 _ICOM_THIS_From_IViewObject(IShellViewImpl
, iface
);
1940 FIXME("Stub: This=%p\n",This
);
1944 static HRESULT WINAPI
ISVViewObject_Freeze(
1952 _ICOM_THIS_From_IViewObject(IShellViewImpl
, iface
);
1954 FIXME("Stub: This=%p\n",This
);
1958 static HRESULT WINAPI
ISVViewObject_Unfreeze(
1963 _ICOM_THIS_From_IViewObject(IShellViewImpl
, iface
);
1965 FIXME("Stub: This=%p\n",This
);
1969 static HRESULT WINAPI
ISVViewObject_SetAdvise(
1973 IAdviseSink
* pAdvSink
)
1976 _ICOM_THIS_From_IViewObject(IShellViewImpl
, iface
);
1978 FIXME("Stub: This=%p\n",This
);
1982 static HRESULT WINAPI
ISVViewObject_GetAdvise(
1986 IAdviseSink
** ppAdvSink
)
1989 _ICOM_THIS_From_IViewObject(IShellViewImpl
, iface
);
1991 FIXME("Stub: This=%p\n",This
);
1997 static struct ICOM_VTABLE(IViewObject
) vovt
=
1999 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2000 ISVViewObject_QueryInterface
,
2001 ISVViewObject_AddRef
,
2002 ISVViewObject_Release
,
2004 ISVViewObject_GetColorSet
,
2005 ISVViewObject_Freeze
,
2006 ISVViewObject_Unfreeze
,
2007 ISVViewObject_SetAdvise
,
2008 ISVViewObject_GetAdvise