| 1 | /* | 
|---|
| 2 | *      ShellView | 
|---|
| 3 | * | 
|---|
| 4 | *      Copyright 1998,1999     <juergen.schmied@debitel.net> | 
|---|
| 5 | * | 
|---|
| 6 | * This is the view visualizing the data provied by the shellfolder. | 
|---|
| 7 | * No direct access to data from pidls should be done from here. | 
|---|
| 8 | * | 
|---|
| 9 | * FIXME: The order by part of the background context menu should be | 
|---|
| 10 | * buily according to the columns shown. | 
|---|
| 11 | * | 
|---|
| 12 | * FIXME: Load/Save the view state from/into the stream provied by | 
|---|
| 13 | * the ShellBrowser | 
|---|
| 14 | * | 
|---|
| 15 | * FIXME: CheckToolbar: handle the "new folder" and "folder up" button | 
|---|
| 16 | * | 
|---|
| 17 | * FIXME: ShellView_FillList: consider sort orders | 
|---|
| 18 | * | 
|---|
| 19 | * FIXME: implement the drag and drop in the old (msg-based) way | 
|---|
| 20 | * | 
|---|
| 21 | * FIXME: when the ShellView_WndProc gets a WM_NCDESTROY should we do a | 
|---|
| 22 | * Release() ??? | 
|---|
| 23 | */ | 
|---|
| 24 |  | 
|---|
| 25 | #include <stdlib.h> | 
|---|
| 26 | #include <string.h> | 
|---|
| 27 |  | 
|---|
| 28 | #include "windef.h" | 
|---|
| 29 | #include "winerror.h" | 
|---|
| 30 | #include "winnls.h" | 
|---|
| 31 | #include "servprov.h" | 
|---|
| 32 | #include "shlguid.h" | 
|---|
| 33 | #include "shlobj.h" | 
|---|
| 34 | #include "undocshell.h" | 
|---|
| 35 | #include "shresdef.h" | 
|---|
| 36 | #include "debugtools.h" | 
|---|
| 37 |  | 
|---|
| 38 | #include "docobj.h" | 
|---|
| 39 | #include "pidl.h" | 
|---|
| 40 | #include "shell32_main.h" | 
|---|
| 41 | #include "shellfolder.h" | 
|---|
| 42 |  | 
|---|
| 43 | DEFAULT_DEBUG_CHANNEL(shell); | 
|---|
| 44 |  | 
|---|
| 45 | typedef struct | 
|---|
| 46 | {   BOOL    bIsAscending; | 
|---|
| 47 | INT     nHeaderID; | 
|---|
| 48 | INT     nLastHeaderID; | 
|---|
| 49 | }LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO; | 
|---|
| 50 |  | 
|---|
| 51 | typedef struct | 
|---|
| 52 | {       ICOM_VFIELD(IShellView); | 
|---|
| 53 | DWORD           ref; | 
|---|
| 54 | ICOM_VTABLE(IOleCommandTarget)* lpvtblOleCommandTarget; | 
|---|
| 55 | ICOM_VTABLE(IDropTarget)*       lpvtblDropTarget; | 
|---|
| 56 | ICOM_VTABLE(IDropSource)*       lpvtblDropSource; | 
|---|
| 57 | ICOM_VTABLE(IViewObject)*       lpvtblViewObject; | 
|---|
| 58 | IShellFolder*   pSFParent; | 
|---|
| 59 | IShellFolder2*  pSF2Parent; | 
|---|
| 60 | IShellBrowser*  pShellBrowser; | 
|---|
| 61 | ICommDlgBrowser*        pCommDlgBrowser; | 
|---|
| 62 | HWND            hWnd;           /* SHELLDLL_DefView */ | 
|---|
| 63 | HWND            hWndList;       /* ListView control */ | 
|---|
| 64 | HWND            hWndParent; | 
|---|
| 65 | FOLDERSETTINGS  FolderSettings; | 
|---|
| 66 | HMENU           hMenu; | 
|---|
| 67 | UINT            uState; | 
|---|
| 68 | UINT            cidl; | 
|---|
| 69 | LPITEMIDLIST    *apidl; | 
|---|
| 70 | LISTVIEW_SORT_INFO ListViewSortInfo; | 
|---|
| 71 | HANDLE          hNotify;        /* change notification handle */ | 
|---|
| 72 | HANDLE          hAccel; | 
|---|
| 73 | } IShellViewImpl; | 
|---|
| 74 |  | 
|---|
| 75 | static struct ICOM_VTABLE(IShellView) svvt; | 
|---|
| 76 |  | 
|---|
| 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); | 
|---|
| 80 |  | 
|---|
| 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); | 
|---|
| 84 |  | 
|---|
| 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); | 
|---|
| 88 |  | 
|---|
| 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); | 
|---|
| 92 |  | 
|---|
| 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 | 
|---|
| 99 |  | 
|---|
| 100 | /*menu items */ | 
|---|
| 101 | #define IDM_VIEW_FILES  (FCIDM_SHVIEWFIRST + 0x500) | 
|---|
| 102 | #define IDM_VIEW_IDW    (FCIDM_SHVIEWFIRST + 0x501) | 
|---|
| 103 | #define IDM_MYFILEITEM  (FCIDM_SHVIEWFIRST + 0x502) | 
|---|
| 104 |  | 
|---|
| 105 | #define ID_LISTVIEW     2000 | 
|---|
| 106 |  | 
|---|
| 107 | #define SHV_CHANGE_NOTIFY WM_USER + 0x1111 | 
|---|
| 108 |  | 
|---|
| 109 | /*windowsx.h */ | 
|---|
| 110 | #define GET_WM_COMMAND_ID(wp, lp)               LOWORD(wp) | 
|---|
| 111 | #define GET_WM_COMMAND_HWND(wp, lp)             (HWND)(lp) | 
|---|
| 112 | #define GET_WM_COMMAND_CMD(wp, lp)              HIWORD(wp) | 
|---|
| 113 |  | 
|---|
| 114 | extern void WINAPI _InsertMenuItem (HMENU hmenu, UINT indexMenu, BOOL fByPosition, | 
|---|
| 115 | UINT wID, UINT fType, LPSTR dwTypeData, UINT fState); | 
|---|
| 116 |  | 
|---|
| 117 | /* | 
|---|
| 118 | Items merged into the toolbar and and the filemenu | 
|---|
| 119 | */ | 
|---|
| 120 | typedef struct | 
|---|
| 121 | {  int   idCommand; | 
|---|
| 122 | int   iImage; | 
|---|
| 123 | int   idButtonString; | 
|---|
| 124 | int   idMenuString; | 
|---|
| 125 | BYTE  bState; | 
|---|
| 126 | BYTE  bStyle; | 
|---|
| 127 | } MYTOOLINFO, *LPMYTOOLINFO; | 
|---|
| 128 |  | 
|---|
| 129 | MYTOOLINFO Tools[] = | 
|---|
| 130 | { | 
|---|
| 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 }, | 
|---|
| 135 | { -1, 0, 0, 0, 0, 0} | 
|---|
| 136 | }; | 
|---|
| 137 |  | 
|---|
| 138 | #ifdef __WIN32OS2__ | 
|---|
| 139 | typedef void (* CALLBACK PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask); | 
|---|
| 140 | #else | 
|---|
| 141 | typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask); | 
|---|
| 142 | #endif | 
|---|
| 143 |  | 
|---|
| 144 | /********************************************************** | 
|---|
| 145 | *      IShellView_Constructor | 
|---|
| 146 | */ | 
|---|
| 147 | IShellView * IShellView_Constructor( IShellFolder * pFolder) | 
|---|
| 148 | {       IShellViewImpl * sv; | 
|---|
| 149 | sv=(IShellViewImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IShellViewImpl)); | 
|---|
| 150 | sv->ref=1; | 
|---|
| 151 | ICOM_VTBL(sv)=&svvt; | 
|---|
| 152 | sv->lpvtblOleCommandTarget=&ctvt; | 
|---|
| 153 | sv->lpvtblDropTarget=&dtvt; | 
|---|
| 154 | sv->lpvtblDropSource=&dsvt; | 
|---|
| 155 | sv->lpvtblViewObject=&vovt; | 
|---|
| 156 |  | 
|---|
| 157 | sv->pSFParent = pFolder; | 
|---|
| 158 | if(pFolder) IShellFolder_AddRef(pFolder); | 
|---|
| 159 | IShellFolder_QueryInterface(sv->pSFParent, &IID_IShellFolder2, (LPVOID*)&sv->pSF2Parent); | 
|---|
| 160 |  | 
|---|
| 161 | TRACE("(%p)->(%p)\n",sv, pFolder); | 
|---|
| 162 | shell32_ObjCount++; | 
|---|
| 163 | return (IShellView *) sv; | 
|---|
| 164 | } | 
|---|
| 165 |  | 
|---|
| 166 | /********************************************************** | 
|---|
| 167 | * | 
|---|
| 168 | * ##### helperfunctions for communication with ICommDlgBrowser ##### | 
|---|
| 169 | */ | 
|---|
| 170 | static BOOL IsInCommDlg(IShellViewImpl * This) | 
|---|
| 171 | {       return(This->pCommDlgBrowser != NULL); | 
|---|
| 172 | } | 
|---|
| 173 |  | 
|---|
| 174 | static HRESULT IncludeObject(IShellViewImpl * This, LPCITEMIDLIST pidl) | 
|---|
| 175 | { | 
|---|
| 176 | HRESULT ret = S_OK; | 
|---|
| 177 |  | 
|---|
| 178 | if ( IsInCommDlg(This) ) | 
|---|
| 179 | { | 
|---|
| 180 | TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl); | 
|---|
| 181 | ret = ICommDlgBrowser_IncludeObject(This->pCommDlgBrowser, (IShellView*)This, pidl); | 
|---|
| 182 | TRACE("--0x%08lx\n", ret); | 
|---|
| 183 | } | 
|---|
| 184 | return ret; | 
|---|
| 185 | } | 
|---|
| 186 |  | 
|---|
| 187 | static HRESULT OnDefaultCommand(IShellViewImpl * This) | 
|---|
| 188 | { | 
|---|
| 189 | HRESULT ret = S_FALSE; | 
|---|
| 190 |  | 
|---|
| 191 | if (IsInCommDlg(This)) | 
|---|
| 192 | { | 
|---|
| 193 | TRACE("ICommDlgBrowser::OnDefaultCommand\n"); | 
|---|
| 194 | ret = ICommDlgBrowser_OnDefaultCommand(This->pCommDlgBrowser, (IShellView*)This); | 
|---|
| 195 | TRACE("--\n"); | 
|---|
| 196 | } | 
|---|
| 197 | return ret; | 
|---|
| 198 | } | 
|---|
| 199 |  | 
|---|
| 200 | static HRESULT OnStateChange(IShellViewImpl * This, UINT uFlags) | 
|---|
| 201 | { | 
|---|
| 202 | HRESULT ret = S_FALSE; | 
|---|
| 203 |  | 
|---|
| 204 | if (IsInCommDlg(This)) | 
|---|
| 205 | { | 
|---|
| 206 | TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags); | 
|---|
| 207 | ret = ICommDlgBrowser_OnStateChange(This->pCommDlgBrowser, (IShellView*)This, uFlags); | 
|---|
| 208 | TRACE("--\n"); | 
|---|
| 209 | } | 
|---|
| 210 | return ret; | 
|---|
| 211 | } | 
|---|
| 212 | /********************************************************** | 
|---|
| 213 | *      set the toolbar of the filedialog buttons | 
|---|
| 214 | * | 
|---|
| 215 | * - activates the buttons from the shellbrowser according to | 
|---|
| 216 | *   the view state | 
|---|
| 217 | */ | 
|---|
| 218 | static void CheckToolbar(IShellViewImpl * This) | 
|---|
| 219 | { | 
|---|
| 220 | LRESULT result; | 
|---|
| 221 |  | 
|---|
| 222 | TRACE("\n"); | 
|---|
| 223 |  | 
|---|
| 224 | if (IsInCommDlg(This)) | 
|---|
| 225 | { | 
|---|
| 226 | IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON, | 
|---|
| 227 | FCIDM_TB_SMALLICON, (This->FolderSettings.ViewMode==FVM_LIST)? TRUE : FALSE, &result); | 
|---|
| 228 | IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_CHECKBUTTON, | 
|---|
| 229 | FCIDM_TB_REPORTVIEW, (This->FolderSettings.ViewMode==FVM_DETAILS)? TRUE : FALSE, &result); | 
|---|
| 230 | IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON, | 
|---|
| 231 | FCIDM_TB_SMALLICON, TRUE, &result); | 
|---|
| 232 | IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_TOOLBAR, TB_ENABLEBUTTON, | 
|---|
| 233 | FCIDM_TB_REPORTVIEW, TRUE, &result); | 
|---|
| 234 | } | 
|---|
| 235 | } | 
|---|
| 236 |  | 
|---|
| 237 | /********************************************************** | 
|---|
| 238 | * | 
|---|
| 239 | * ##### helperfunctions for initializing the view ##### | 
|---|
| 240 | */ | 
|---|
| 241 | /********************************************************** | 
|---|
| 242 | *      change the style of the listview control | 
|---|
| 243 | */ | 
|---|
| 244 | static void SetStyle(IShellViewImpl * This, DWORD dwAdd, DWORD dwRemove) | 
|---|
| 245 | { | 
|---|
| 246 | DWORD tmpstyle; | 
|---|
| 247 |  | 
|---|
| 248 | TRACE("(%p)\n", This); | 
|---|
| 249 |  | 
|---|
| 250 | tmpstyle = GetWindowLongA(This->hWndList, GWL_STYLE); | 
|---|
| 251 | SetWindowLongA(This->hWndList, GWL_STYLE, dwAdd | (tmpstyle & ~dwRemove)); | 
|---|
| 252 | } | 
|---|
| 253 |  | 
|---|
| 254 | /********************************************************** | 
|---|
| 255 | * ShellView_CreateList() | 
|---|
| 256 | * | 
|---|
| 257 | * - creates the list view window | 
|---|
| 258 | */ | 
|---|
| 259 | static BOOL ShellView_CreateList (IShellViewImpl * This) | 
|---|
| 260 | {       DWORD dwStyle; | 
|---|
| 261 |  | 
|---|
| 262 | TRACE("%p\n",This); | 
|---|
| 263 |  | 
|---|
| 264 | dwStyle = WS_TABSTOP | WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | | 
|---|
| 265 | LVS_SHAREIMAGELISTS | LVS_EDITLABELS | LVS_ALIGNLEFT | LVS_AUTOARRANGE; | 
|---|
| 266 |  | 
|---|
| 267 | switch (This->FolderSettings.ViewMode) | 
|---|
| 268 | { | 
|---|
| 269 | case FVM_ICON:        dwStyle |= LVS_ICON;            break; | 
|---|
| 270 | case FVM_DETAILS:     dwStyle |= LVS_REPORT;          break; | 
|---|
| 271 | case FVM_SMALLICON:   dwStyle |= LVS_SMALLICON;       break; | 
|---|
| 272 | case FVM_LIST:        dwStyle |= LVS_LIST;            break; | 
|---|
| 273 | default:              dwStyle |= LVS_LIST;            break; | 
|---|
| 274 | } | 
|---|
| 275 |  | 
|---|
| 276 | if (This->FolderSettings.fFlags & FWF_AUTOARRANGE)      dwStyle |= LVS_AUTOARRANGE; | 
|---|
| 277 | /*if (This->FolderSettings.fFlags && FWF_DESKTOP); used from explorer*/ | 
|---|
| 278 | if (This->FolderSettings.fFlags & FWF_SINGLESEL)        dwStyle |= LVS_SINGLESEL; | 
|---|
| 279 |  | 
|---|
| 280 | This->hWndList=CreateWindowExA( WS_EX_CLIENTEDGE, | 
|---|
| 281 | WC_LISTVIEWA, | 
|---|
| 282 | NULL, | 
|---|
| 283 | dwStyle, | 
|---|
| 284 | 0,0,0,0, | 
|---|
| 285 | This->hWnd, | 
|---|
| 286 | (HMENU)ID_LISTVIEW, | 
|---|
| 287 | shell32_hInstance, | 
|---|
| 288 | NULL); | 
|---|
| 289 |  | 
|---|
| 290 | if(!This->hWndList) | 
|---|
| 291 | return FALSE; | 
|---|
| 292 |  | 
|---|
| 293 | This->ListViewSortInfo.bIsAscending = TRUE; | 
|---|
| 294 | This->ListViewSortInfo.nHeaderID = -1; | 
|---|
| 295 | This->ListViewSortInfo.nLastHeaderID = -1; | 
|---|
| 296 |  | 
|---|
| 297 | /*  UpdateShellSettings(); */ | 
|---|
| 298 | return TRUE; | 
|---|
| 299 | } | 
|---|
| 300 |  | 
|---|
| 301 | /********************************************************** | 
|---|
| 302 | * ShellView_InitList() | 
|---|
| 303 | * | 
|---|
| 304 | * - adds all needed columns to the shellview | 
|---|
| 305 | */ | 
|---|
| 306 | static BOOL ShellView_InitList(IShellViewImpl * This) | 
|---|
| 307 | { | 
|---|
| 308 | LVCOLUMNA       lvColumn; | 
|---|
| 309 | SHELLDETAILS    sd; | 
|---|
| 310 | int     i; | 
|---|
| 311 | char    szTemp[50]; | 
|---|
| 312 |  | 
|---|
| 313 | TRACE("%p\n",This); | 
|---|
| 314 |  | 
|---|
| 315 | ListView_DeleteAllItems(This->hWndList); | 
|---|
| 316 |  | 
|---|
| 317 | lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT; | 
|---|
| 318 | lvColumn.pszText = szTemp; | 
|---|
| 319 |  | 
|---|
| 320 | if (This->pSF2Parent) | 
|---|
| 321 | { | 
|---|
| 322 | for (i=0; 1; i++) | 
|---|
| 323 | { | 
|---|
| 324 | if (!SUCCEEDED(IShellFolder2_GetDetailsOf(This->pSF2Parent, NULL, i, &sd))) | 
|---|
| 325 | break; | 
|---|
| 326 | lvColumn.fmt = sd.fmt; | 
|---|
| 327 | lvColumn.cx = sd.cxChar*8; /* chars->pixel */ | 
|---|
| 328 | StrRetToStrNA( szTemp, 50, &sd.str, NULL); | 
|---|
| 329 | ListView_InsertColumnA(This->hWndList, i, &lvColumn); | 
|---|
| 330 | } | 
|---|
| 331 | } | 
|---|
| 332 | else | 
|---|
| 333 | { | 
|---|
| 334 | FIXME("no SF2\n"); | 
|---|
| 335 | } | 
|---|
| 336 |  | 
|---|
| 337 | ListView_SetImageList(This->hWndList, ShellSmallIconList, LVSIL_SMALL); | 
|---|
| 338 | ListView_SetImageList(This->hWndList, ShellBigIconList, LVSIL_NORMAL); | 
|---|
| 339 |  | 
|---|
| 340 | return TRUE; | 
|---|
| 341 | } | 
|---|
| 342 | /********************************************************** | 
|---|
| 343 | * ShellView_CompareItems() | 
|---|
| 344 | * | 
|---|
| 345 | * NOTES | 
|---|
| 346 | *  internal, CALLBACK for DSA_Sort | 
|---|
| 347 | */ | 
|---|
| 348 | static INT CALLBACK ShellView_CompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData) | 
|---|
| 349 | { | 
|---|
| 350 | int ret; | 
|---|
| 351 | TRACE("pidl1=%p pidl2=%p lpsf=%p\n", lParam1, lParam2, (LPVOID) lpData); | 
|---|
| 352 |  | 
|---|
| 353 | if(!lpData) return 0; | 
|---|
| 354 |  | 
|---|
| 355 | ret =  (SHORT) SCODE_CODE(IShellFolder_CompareIDs((LPSHELLFOLDER)lpData, 0, (LPITEMIDLIST)lParam1, (LPITEMIDLIST)lParam2)); | 
|---|
| 356 | TRACE("ret=%i\n",ret); | 
|---|
| 357 | return ret; | 
|---|
| 358 | } | 
|---|
| 359 |  | 
|---|
| 360 | /************************************************************************* | 
|---|
| 361 | * ShellView_ListViewCompareItems | 
|---|
| 362 | * | 
|---|
| 363 | * Compare Function for the Listview (FileOpen Dialog) | 
|---|
| 364 | * | 
|---|
| 365 | * PARAMS | 
|---|
| 366 | *     lParam1       [I] the first ItemIdList to compare with | 
|---|
| 367 | *     lParam2       [I] the second ItemIdList to compare with | 
|---|
| 368 | *     lpData        [I] The column ID for the header Ctrl to process | 
|---|
| 369 | * | 
|---|
| 370 | * RETURNS | 
|---|
| 371 | *     A negative value if the first item should precede the second, | 
|---|
| 372 | *     a positive value if the first item should follow the second, | 
|---|
| 373 | *     or zero if the two items are equivalent | 
|---|
| 374 | * | 
|---|
| 375 | * NOTES | 
|---|
| 376 | *      FIXME: function does what ShellView_CompareItems is supposed to do. | 
|---|
| 377 | *      unify it and figure out how to use the undocumented first parameter | 
|---|
| 378 | *      of IShellFolder_CompareIDs to do the job this function does and | 
|---|
| 379 | *      move this code to IShellFolder. | 
|---|
| 380 | *      make LISTVIEW_SORT_INFO obsolete | 
|---|
| 381 | *      the way this function works is only usable if we had only | 
|---|
| 382 | *      filesystemfolders  (25/10/99 jsch) | 
|---|
| 383 | */ | 
|---|
| 384 | static INT CALLBACK ShellView_ListViewCompareItems(LPVOID lParam1, LPVOID lParam2, LPARAM lpData) | 
|---|
| 385 | { | 
|---|
| 386 | INT nDiff=0; | 
|---|
| 387 | FILETIME fd1, fd2; | 
|---|
| 388 | char strName1[MAX_PATH], strName2[MAX_PATH]; | 
|---|
| 389 | BOOL bIsFolder1, bIsFolder2,bIsBothFolder; | 
|---|
| 390 | LPITEMIDLIST pItemIdList1 = (LPITEMIDLIST) lParam1; | 
|---|
| 391 | LPITEMIDLIST pItemIdList2 = (LPITEMIDLIST) lParam2; | 
|---|
| 392 | LISTVIEW_SORT_INFO *pSortInfo = (LPLISTVIEW_SORT_INFO) lpData; | 
|---|
| 393 |  | 
|---|
| 394 |  | 
|---|
| 395 | bIsFolder1 = _ILIsFolder(pItemIdList1); | 
|---|
| 396 | bIsFolder2 = _ILIsFolder(pItemIdList2); | 
|---|
| 397 | bIsBothFolder = bIsFolder1 && bIsFolder2; | 
|---|
| 398 |  | 
|---|
| 399 | /* When sorting between a File and a Folder, the Folder gets sorted first */ | 
|---|
| 400 | if( (bIsFolder1 || bIsFolder2) && !bIsBothFolder) | 
|---|
| 401 | { | 
|---|
| 402 | nDiff = bIsFolder1 ? -1 : 1; | 
|---|
| 403 | } | 
|---|
| 404 | else | 
|---|
| 405 | { | 
|---|
| 406 | /* Sort by Time: Folders or Files can be sorted */ | 
|---|
| 407 |  | 
|---|
| 408 | if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME) | 
|---|
| 409 | { | 
|---|
| 410 | _ILGetFileDateTime(pItemIdList1, &fd1); | 
|---|
| 411 | _ILGetFileDateTime(pItemIdList2, &fd2); | 
|---|
| 412 | nDiff = CompareFileTime(&fd2, &fd1); | 
|---|
| 413 | } | 
|---|
| 414 | /* Sort by Attribute: Folder or Files can be sorted */ | 
|---|
| 415 | else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB) | 
|---|
| 416 | { | 
|---|
| 417 | _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH); | 
|---|
| 418 | _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH); | 
|---|
| 419 | nDiff = strcasecmp(strName1, strName2); | 
|---|
| 420 | } | 
|---|
| 421 | /* Sort by FileName: Folder or Files can be sorted */ | 
|---|
| 422 | else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder) | 
|---|
| 423 | { | 
|---|
| 424 | /* Sort by Text */ | 
|---|
| 425 | _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH); | 
|---|
| 426 | _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH); | 
|---|
| 427 | nDiff = strcasecmp(strName1, strName2); | 
|---|
| 428 | } | 
|---|
| 429 | /* Sort by File Size, Only valid for Files */ | 
|---|
| 430 | else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE) | 
|---|
| 431 | { | 
|---|
| 432 | nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0)); | 
|---|
| 433 | } | 
|---|
| 434 | /* Sort by File Type, Only valid for Files */ | 
|---|
| 435 | else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE) | 
|---|
| 436 | { | 
|---|
| 437 | /* Sort by Type */ | 
|---|
| 438 | _ILGetFileType(pItemIdList1, strName1, MAX_PATH); | 
|---|
| 439 | _ILGetFileType(pItemIdList2, strName2, MAX_PATH); | 
|---|
| 440 | nDiff = strcasecmp(strName1, strName2); | 
|---|
| 441 | } | 
|---|
| 442 | } | 
|---|
| 443 | /*  If the Date, FileSize, FileType, Attrib was the same, sort by FileName */ | 
|---|
| 444 |  | 
|---|
| 445 | if(nDiff == 0) | 
|---|
| 446 | { | 
|---|
| 447 | _ILSimpleGetText(pItemIdList1, strName1, MAX_PATH); | 
|---|
| 448 | _ILSimpleGetText(pItemIdList2, strName2, MAX_PATH); | 
|---|
| 449 | nDiff = strcasecmp(strName1, strName2); | 
|---|
| 450 | } | 
|---|
| 451 |  | 
|---|
| 452 | if(!pSortInfo->bIsAscending) | 
|---|
| 453 | { | 
|---|
| 454 | nDiff = -nDiff; | 
|---|
| 455 | } | 
|---|
| 456 |  | 
|---|
| 457 | return nDiff; | 
|---|
| 458 |  | 
|---|
| 459 | } | 
|---|
| 460 |  | 
|---|
| 461 | /********************************************************** | 
|---|
| 462 | *  LV_FindItemByPidl() | 
|---|
| 463 | */ | 
|---|
| 464 | static int LV_FindItemByPidl( | 
|---|
| 465 | IShellViewImpl * This, | 
|---|
| 466 | LPCITEMIDLIST pidl) | 
|---|
| 467 | { | 
|---|
| 468 | LVITEMA lvItem; | 
|---|
| 469 | ZeroMemory(&lvItem, sizeof(LVITEMA)); | 
|---|
| 470 | lvItem.mask = LVIF_PARAM; | 
|---|
| 471 | for(lvItem.iItem = 0; ListView_GetItemA(This->hWndList, &lvItem); lvItem.iItem++) | 
|---|
| 472 | { | 
|---|
| 473 | LPITEMIDLIST currentpidl = (LPITEMIDLIST) lvItem.lParam; | 
|---|
| 474 | HRESULT hr = IShellFolder_CompareIDs(This->pSFParent, 0, pidl, currentpidl); | 
|---|
| 475 | if(SUCCEEDED(hr) && !HRESULT_CODE(hr)) | 
|---|
| 476 | { | 
|---|
| 477 | return lvItem.iItem; | 
|---|
| 478 | } | 
|---|
| 479 | } | 
|---|
| 480 | return -1; | 
|---|
| 481 | } | 
|---|
| 482 |  | 
|---|
| 483 | /********************************************************** | 
|---|
| 484 | * LV_AddItem() | 
|---|
| 485 | */ | 
|---|
| 486 | static BOOLEAN LV_AddItem(IShellViewImpl * This, LPCITEMIDLIST pidl) | 
|---|
| 487 | { | 
|---|
| 488 | LVITEMA lvItem; | 
|---|
| 489 |  | 
|---|
| 490 | TRACE("(%p)(pidl=%p)\n", This, pidl); | 
|---|
| 491 |  | 
|---|
| 492 | ZeroMemory(&lvItem, sizeof(lvItem));    /* create the listview item*/ | 
|---|
| 493 | lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;      /*set the mask*/ | 
|---|
| 494 | lvItem.iItem = ListView_GetItemCount(This->hWndList);   /*add the item to the end of the list*/ | 
|---|
| 495 | lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidl));                           /*set the item's data*/ | 
|---|
| 496 | lvItem.pszText = LPSTR_TEXTCALLBACKA;                   /*get text on a callback basis*/ | 
|---|
| 497 | lvItem.iImage = I_IMAGECALLBACK;                        /*get the image on a callback basis*/ | 
|---|
| 498 | return (-1==ListView_InsertItemA(This->hWndList, &lvItem))? FALSE: TRUE; | 
|---|
| 499 | } | 
|---|
| 500 |  | 
|---|
| 501 | /********************************************************** | 
|---|
| 502 | * LV_DeleteItem() | 
|---|
| 503 | */ | 
|---|
| 504 | static BOOLEAN LV_DeleteItem(IShellViewImpl * This, LPCITEMIDLIST pidl) | 
|---|
| 505 | { | 
|---|
| 506 | int nIndex; | 
|---|
| 507 |  | 
|---|
| 508 | TRACE("(%p)(pidl=%p)\n", This, pidl); | 
|---|
| 509 |  | 
|---|
| 510 | nIndex = LV_FindItemByPidl(This, ILFindLastID(pidl)); | 
|---|
| 511 | return (-1==ListView_DeleteItem(This->hWndList, nIndex))? FALSE: TRUE; | 
|---|
| 512 | } | 
|---|
| 513 |  | 
|---|
| 514 | /********************************************************** | 
|---|
| 515 | * LV_RenameItem() | 
|---|
| 516 | */ | 
|---|
| 517 | static BOOLEAN LV_RenameItem(IShellViewImpl * This, LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew ) | 
|---|
| 518 | { | 
|---|
| 519 | int nItem; | 
|---|
| 520 | LVITEMA lvItem; | 
|---|
| 521 |  | 
|---|
| 522 | TRACE("(%p)(pidlold=%p pidlnew=%p)\n", This, pidlOld, pidlNew); | 
|---|
| 523 |  | 
|---|
| 524 | nItem = LV_FindItemByPidl(This, ILFindLastID(pidlOld)); | 
|---|
| 525 | if ( -1 != nItem ) | 
|---|
| 526 | { | 
|---|
| 527 | ZeroMemory(&lvItem, sizeof(lvItem));  /* create the listview item*/ | 
|---|
| 528 | lvItem.mask = LVIF_PARAM;             /* only the pidl */ | 
|---|
| 529 | lvItem.iItem = nItem; | 
|---|
| 530 | ListView_GetItemA(This->hWndList, &lvItem); | 
|---|
| 531 |  | 
|---|
| 532 | SHFree((LPITEMIDLIST)lvItem.lParam); | 
|---|
| 533 | lvItem.mask = LVIF_PARAM; | 
|---|
| 534 | lvItem.iItem = nItem; | 
|---|
| 535 | lvItem.lParam = (LPARAM) ILClone(ILFindLastID(pidlNew));      /* set the item's data */ | 
|---|
| 536 | ListView_SetItemA(This->hWndList, &lvItem); | 
|---|
| 537 | ListView_Update(This->hWndList, nItem); | 
|---|
| 538 | return TRUE;                                  /* FIXME: better handling */ | 
|---|
| 539 | } | 
|---|
| 540 | return FALSE; | 
|---|
| 541 | } | 
|---|
| 542 | /********************************************************** | 
|---|
| 543 | * ShellView_FillList() | 
|---|
| 544 | * | 
|---|
| 545 | * - gets the objectlist from the shellfolder | 
|---|
| 546 | * - sorts the list | 
|---|
| 547 | * - fills the list into the view | 
|---|
| 548 | */ | 
|---|
| 549 |  | 
|---|
| 550 | static HRESULT ShellView_FillList(IShellViewImpl * This) | 
|---|
| 551 | { | 
|---|
| 552 | LPENUMIDLIST    pEnumIDList; | 
|---|
| 553 | LPITEMIDLIST    pidl; | 
|---|
| 554 | DWORD           dwFetched; | 
|---|
| 555 | UINT            i; | 
|---|
| 556 | HRESULT         hRes; | 
|---|
| 557 | HDPA            hdpa; | 
|---|
| 558 |  | 
|---|
| 559 | TRACE("%p\n",This); | 
|---|
| 560 |  | 
|---|
| 561 | /* get the itemlist from the shfolder*/ | 
|---|
| 562 | hRes = IShellFolder_EnumObjects(This->pSFParent,This->hWnd, SHCONTF_NONFOLDERS | SHCONTF_FOLDERS, &pEnumIDList); | 
|---|
| 563 | if (hRes != S_OK) | 
|---|
| 564 | { | 
|---|
| 565 | if (hRes==S_FALSE) | 
|---|
| 566 | return(NOERROR); | 
|---|
| 567 | return(hRes); | 
|---|
| 568 | } | 
|---|
| 569 |  | 
|---|
| 570 | /* create a pointer array */ | 
|---|
| 571 | hdpa = pDPA_Create(16); | 
|---|
| 572 | if (!hdpa) | 
|---|
| 573 | { | 
|---|
| 574 | return(E_OUTOFMEMORY); | 
|---|
| 575 | } | 
|---|
| 576 |  | 
|---|
| 577 | /* copy the items into the array*/ | 
|---|
| 578 | while((S_OK == IEnumIDList_Next(pEnumIDList,1, &pidl, &dwFetched)) && dwFetched) | 
|---|
| 579 | { | 
|---|
| 580 | if (pDPA_InsertPtr(hdpa, 0x7fff, pidl) == -1) | 
|---|
| 581 | { | 
|---|
| 582 | SHFree(pidl); | 
|---|
| 583 | } | 
|---|
| 584 | } | 
|---|
| 585 |  | 
|---|
| 586 | /* sort the array */ | 
|---|
| 587 | pDPA_Sort(hdpa, ShellView_CompareItems, (LPARAM)This->pSFParent); | 
|---|
| 588 |  | 
|---|
| 589 | /*turn the listview's redrawing off*/ | 
|---|
| 590 | SendMessageA(This->hWndList, WM_SETREDRAW, FALSE, 0); | 
|---|
| 591 |  | 
|---|
| 592 | for (i=0; i < DPA_GetPtrCount(hdpa); ++i)       /* DPA_GetPtrCount is a macro*/ | 
|---|
| 593 | { | 
|---|
| 594 | pidl = (LPITEMIDLIST)pDPA_GetPtr(hdpa, i); | 
|---|
| 595 |  | 
|---|
| 596 | /* in a commdlg This works as a filemask*/ | 
|---|
| 597 | if ( IncludeObject(This, pidl)==S_OK ) | 
|---|
| 598 | LV_AddItem(This, pidl); | 
|---|
| 599 | SHFree(pidl); | 
|---|
| 600 | } | 
|---|
| 601 |  | 
|---|
| 602 | /*turn the listview's redrawing back on and force it to draw*/ | 
|---|
| 603 | SendMessageA(This->hWndList, WM_SETREDRAW, TRUE, 0); | 
|---|
| 604 |  | 
|---|
| 605 | IEnumIDList_Release(pEnumIDList); /* destroy the list*/ | 
|---|
| 606 | pDPA_Destroy(hdpa); | 
|---|
| 607 |  | 
|---|
| 608 | return S_OK; | 
|---|
| 609 | } | 
|---|
| 610 |  | 
|---|
| 611 | /********************************************************** | 
|---|
| 612 | *  ShellView_OnCreate() | 
|---|
| 613 | */ | 
|---|
| 614 | static LRESULT ShellView_OnCreate(IShellViewImpl * This) | 
|---|
| 615 | { | 
|---|
| 616 | IDropTarget* pdt; | 
|---|
| 617 | NOTIFYREGISTER ntreg; | 
|---|
| 618 | IPersistFolder2 * ppf2 = NULL; | 
|---|
| 619 |  | 
|---|
| 620 | TRACE("%p\n",This); | 
|---|
| 621 |  | 
|---|
| 622 | if(ShellView_CreateList(This)) | 
|---|
| 623 | { | 
|---|
| 624 | if(ShellView_InitList(This)) | 
|---|
| 625 | { | 
|---|
| 626 | ShellView_FillList(This); | 
|---|
| 627 | } | 
|---|
| 628 | } | 
|---|
| 629 |  | 
|---|
| 630 | if(GetShellOle()) | 
|---|
| 631 | { | 
|---|
| 632 | if (SUCCEEDED(IShellFolder_CreateViewObject(This->pSFParent, This->hWnd, &IID_IDropTarget, (LPVOID*)&pdt))) | 
|---|
| 633 | { | 
|---|
| 634 | pRegisterDragDrop(This->hWnd, pdt); | 
|---|
| 635 | IDropTarget_Release(pdt); | 
|---|
| 636 | } | 
|---|
| 637 | } | 
|---|
| 638 |  | 
|---|
| 639 | /* register for receiving notifications */ | 
|---|
| 640 | IShellFolder_QueryInterface(This->pSFParent, &IID_IPersistFolder2, (LPVOID*)&ppf2); | 
|---|
| 641 | if (ppf2) | 
|---|
| 642 | { | 
|---|
| 643 | IPersistFolder2_GetCurFolder(ppf2, &ntreg.pidlPath); | 
|---|
| 644 | ntreg.bWatchSubtree = FALSE; | 
|---|
| 645 | This->hNotify = SHChangeNotifyRegister(This->hWnd, SHCNF_IDLIST, SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg); | 
|---|
| 646 | SHFree(ntreg.pidlPath); | 
|---|
| 647 | IPersistFolder2_Release(ppf2); | 
|---|
| 648 | } | 
|---|
| 649 |  | 
|---|
| 650 | This->hAccel = LoadAcceleratorsA(shell32_hInstance, "shv_accel"); | 
|---|
| 651 |  | 
|---|
| 652 | return S_OK; | 
|---|
| 653 | } | 
|---|
| 654 |  | 
|---|
| 655 | /********************************************************** | 
|---|
| 656 | *      #### Handling of the menus #### | 
|---|
| 657 | */ | 
|---|
| 658 |  | 
|---|
| 659 | /********************************************************** | 
|---|
| 660 | * ShellView_BuildFileMenu() | 
|---|
| 661 | */ | 
|---|
| 662 | static HMENU ShellView_BuildFileMenu(IShellViewImpl * This) | 
|---|
| 663 | {       CHAR    szText[MAX_PATH]; | 
|---|
| 664 | MENUITEMINFOA   mii; | 
|---|
| 665 | int     nTools,i; | 
|---|
| 666 | HMENU   hSubMenu; | 
|---|
| 667 |  | 
|---|
| 668 | TRACE("(%p)\n",This); | 
|---|
| 669 |  | 
|---|
| 670 | hSubMenu = CreatePopupMenu(); | 
|---|
| 671 | if(hSubMenu) | 
|---|
| 672 | { /*get the number of items in our global array*/ | 
|---|
| 673 | for(nTools = 0; Tools[nTools].idCommand != -1; nTools++){} | 
|---|
| 674 |  | 
|---|
| 675 | /*add the menu items*/ | 
|---|
| 676 | for(i = 0; i < nTools; i++) | 
|---|
| 677 | { | 
|---|
| 678 | LoadStringA(shell32_hInstance, Tools[i].idMenuString, szText, MAX_PATH); | 
|---|
| 679 |  | 
|---|
| 680 | ZeroMemory(&mii, sizeof(mii)); | 
|---|
| 681 | mii.cbSize = sizeof(mii); | 
|---|
| 682 | mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE; | 
|---|
| 683 |  | 
|---|
| 684 | if(TBSTYLE_SEP != Tools[i].bStyle) /* no seperator*/ | 
|---|
| 685 | { | 
|---|
| 686 | mii.fType = MFT_STRING; | 
|---|
| 687 | mii.fState = MFS_ENABLED; | 
|---|
| 688 | mii.dwTypeData = szText; | 
|---|
| 689 | mii.wID = Tools[i].idCommand; | 
|---|
| 690 | } | 
|---|
| 691 | else | 
|---|
| 692 | { | 
|---|
| 693 | mii.fType = MFT_SEPARATOR; | 
|---|
| 694 | } | 
|---|
| 695 | /* tack This item onto the end of the menu */ | 
|---|
| 696 | InsertMenuItemA(hSubMenu, (UINT)-1, TRUE, &mii); | 
|---|
| 697 | } | 
|---|
| 698 | } | 
|---|
| 699 | TRACE("-- return (menu=0x%x)\n",hSubMenu); | 
|---|
| 700 | return hSubMenu; | 
|---|
| 701 | } | 
|---|
| 702 | /********************************************************** | 
|---|
| 703 | * ShellView_MergeFileMenu() | 
|---|
| 704 | */ | 
|---|
| 705 | static void ShellView_MergeFileMenu(IShellViewImpl * This, HMENU hSubMenu) | 
|---|
| 706 | {       TRACE("(%p)->(submenu=0x%08x) stub\n",This,hSubMenu); | 
|---|
| 707 |  | 
|---|
| 708 | if(hSubMenu) | 
|---|
| 709 | { /*insert This item at the beginning of the menu */ | 
|---|
| 710 | _InsertMenuItem(hSubMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED); | 
|---|
| 711 | _InsertMenuItem(hSubMenu, 0, TRUE, IDM_MYFILEITEM, MFT_STRING, "dummy45", MFS_ENABLED); | 
|---|
| 712 |  | 
|---|
| 713 | } | 
|---|
| 714 | TRACE("--\n"); | 
|---|
| 715 | } | 
|---|
| 716 |  | 
|---|
| 717 | /********************************************************** | 
|---|
| 718 | * ShellView_MergeViewMenu() | 
|---|
| 719 | */ | 
|---|
| 720 |  | 
|---|
| 721 | static void ShellView_MergeViewMenu(IShellViewImpl * This, HMENU hSubMenu) | 
|---|
| 722 | {       MENUITEMINFOA   mii; | 
|---|
| 723 |  | 
|---|
| 724 | TRACE("(%p)->(submenu=0x%08x)\n",This,hSubMenu); | 
|---|
| 725 |  | 
|---|
| 726 | if(hSubMenu) | 
|---|
| 727 | { /*add a separator at the correct position in the menu*/ | 
|---|
| 728 | _InsertMenuItem(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, 0, MFT_SEPARATOR, NULL, MFS_ENABLED); | 
|---|
| 729 |  | 
|---|
| 730 | ZeroMemory(&mii, sizeof(mii)); | 
|---|
| 731 | mii.cbSize = sizeof(mii); | 
|---|
| 732 | mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_DATA;; | 
|---|
| 733 | mii.fType = MFT_STRING; | 
|---|
| 734 | mii.dwTypeData = "View"; | 
|---|
| 735 | mii.hSubMenu = LoadMenuA(shell32_hInstance, "MENU_001"); | 
|---|
| 736 | InsertMenuItemA(hSubMenu, FCIDM_MENU_VIEW_SEP_OPTIONS, FALSE, &mii); | 
|---|
| 737 | } | 
|---|
| 738 | } | 
|---|
| 739 |  | 
|---|
| 740 | /********************************************************** | 
|---|
| 741 | *   ShellView_GetSelections() | 
|---|
| 742 | * | 
|---|
| 743 | * - fills the this->apidl list with the selected objects | 
|---|
| 744 | * | 
|---|
| 745 | * RETURNS | 
|---|
| 746 | *  number of selected items | 
|---|
| 747 | */ | 
|---|
| 748 | static UINT ShellView_GetSelections(IShellViewImpl * This) | 
|---|
| 749 | { | 
|---|
| 750 | LVITEMA lvItem; | 
|---|
| 751 | UINT    i = 0; | 
|---|
| 752 |  | 
|---|
| 753 | if (This->apidl) | 
|---|
| 754 | { | 
|---|
| 755 | SHFree(This->apidl); | 
|---|
| 756 | } | 
|---|
| 757 |  | 
|---|
| 758 | This->cidl = ListView_GetSelectedCount(This->hWndList); | 
|---|
| 759 | This->apidl = (LPITEMIDLIST*)SHAlloc(This->cidl * sizeof(LPITEMIDLIST)); | 
|---|
| 760 |  | 
|---|
| 761 | TRACE("selected=%i\n", This->cidl); | 
|---|
| 762 |  | 
|---|
| 763 | if(This->apidl) | 
|---|
| 764 | { | 
|---|
| 765 | TRACE("-- Items selected =%u\n", This->cidl); | 
|---|
| 766 |  | 
|---|
| 767 | ZeroMemory(&lvItem, sizeof(lvItem)); | 
|---|
| 768 | lvItem.mask = LVIF_STATE | LVIF_PARAM; | 
|---|
| 769 | lvItem.stateMask = LVIS_SELECTED; | 
|---|
| 770 |  | 
|---|
| 771 | while(ListView_GetItemA(This->hWndList, &lvItem) && (i < This->cidl)) | 
|---|
| 772 | { | 
|---|
| 773 | if(lvItem.state & LVIS_SELECTED) | 
|---|
| 774 | { | 
|---|
| 775 | This->apidl[i] = (LPITEMIDLIST)lvItem.lParam; | 
|---|
| 776 | i++; | 
|---|
| 777 | TRACE("-- selected Item found\n"); | 
|---|
| 778 | } | 
|---|
| 779 | lvItem.iItem++; | 
|---|
| 780 | } | 
|---|
| 781 | } | 
|---|
| 782 | return This->cidl; | 
|---|
| 783 |  | 
|---|
| 784 | } | 
|---|
| 785 | /********************************************************** | 
|---|
| 786 | *      ShellView_DoContextMenu() | 
|---|
| 787 | */ | 
|---|
| 788 | static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL bDefault) | 
|---|
| 789 | {       UINT    uCommand; | 
|---|
| 790 | DWORD   wFlags; | 
|---|
| 791 | HMENU   hMenu; | 
|---|
| 792 | BOOL    fExplore = FALSE; | 
|---|
| 793 | HWND    hwndTree = 0; | 
|---|
| 794 | LPCONTEXTMENU   pContextMenu = NULL; | 
|---|
| 795 | IContextMenu *  pCM = NULL; | 
|---|
| 796 | CMINVOKECOMMANDINFO     cmi; | 
|---|
| 797 |  | 
|---|
| 798 | TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, bDefault); | 
|---|
| 799 |  | 
|---|
| 800 | /* look, what's selected and create a context menu object of it*/ | 
|---|
| 801 | if( ShellView_GetSelections(This) ) | 
|---|
| 802 | { | 
|---|
| 803 | IShellFolder_GetUIObjectOf( This->pSFParent, This->hWndParent, This->cidl, This->apidl, | 
|---|
| 804 | (REFIID)&IID_IContextMenu, NULL, (LPVOID *)&pContextMenu); | 
|---|
| 805 |  | 
|---|
| 806 | if(pContextMenu) | 
|---|
| 807 | { | 
|---|
| 808 | TRACE("-- pContextMenu\n"); | 
|---|
| 809 | hMenu = CreatePopupMenu(); | 
|---|
| 810 |  | 
|---|
| 811 | if( hMenu ) | 
|---|
| 812 | { | 
|---|
| 813 | /* See if we are in Explore or Open mode. If the browser's tree is present, we are in Explore mode.*/ | 
|---|
| 814 | if(SUCCEEDED(IShellBrowser_GetControlWindow(This->pShellBrowser,FCW_TREE, &hwndTree)) && hwndTree) | 
|---|
| 815 | { | 
|---|
| 816 | TRACE("-- explore mode\n"); | 
|---|
| 817 | fExplore = TRUE; | 
|---|
| 818 | } | 
|---|
| 819 |  | 
|---|
| 820 | /* build the flags depending on what we can do with the selected item */ | 
|---|
| 821 | wFlags = CMF_NORMAL | (This->cidl != 1 ? 0 : CMF_CANRENAME) | (fExplore ? CMF_EXPLORE : 0); | 
|---|
| 822 |  | 
|---|
| 823 | /* let the ContextMenu merge its items in */ | 
|---|
| 824 | if (SUCCEEDED(IContextMenu_QueryContextMenu( pContextMenu, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, wFlags ))) | 
|---|
| 825 | { | 
|---|
| 826 | if( bDefault ) | 
|---|
| 827 | { | 
|---|
| 828 | TRACE("-- get menu default command\n"); | 
|---|
| 829 | uCommand = GetMenuDefaultItem(hMenu, FALSE, GMDI_GOINTOPOPUPS); | 
|---|
| 830 | } | 
|---|
| 831 | else | 
|---|
| 832 | { | 
|---|
| 833 | TRACE("-- track popup\n"); | 
|---|
| 834 | uCommand = TrackPopupMenu( hMenu,TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL); | 
|---|
| 835 | } | 
|---|
| 836 |  | 
|---|
| 837 | if(uCommand > 0) | 
|---|
| 838 | { | 
|---|
| 839 | TRACE("-- uCommand=%u\n", uCommand); | 
|---|
| 840 | if (IsInCommDlg(This) && ((uCommand==FCIDM_SHVIEW_EXPLORE) || (uCommand==FCIDM_SHVIEW_OPEN))) | 
|---|
| 841 | { | 
|---|
| 842 | TRACE("-- dlg: OnDefaultCommand\n"); | 
|---|
| 843 | OnDefaultCommand(This); | 
|---|
| 844 | } | 
|---|
| 845 | else | 
|---|
| 846 | { | 
|---|
| 847 | TRACE("-- explore -- invoke command\n"); | 
|---|
| 848 | ZeroMemory(&cmi, sizeof(cmi)); | 
|---|
| 849 | cmi.cbSize = sizeof(cmi); | 
|---|
| 850 | cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */ | 
|---|
| 851 | cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand); | 
|---|
| 852 | IContextMenu_InvokeCommand(pContextMenu, &cmi); | 
|---|
| 853 | } | 
|---|
| 854 | } | 
|---|
| 855 | DestroyMenu(hMenu); | 
|---|
| 856 | } | 
|---|
| 857 | } | 
|---|
| 858 | if (pContextMenu) | 
|---|
| 859 | IContextMenu_Release(pContextMenu); | 
|---|
| 860 | } | 
|---|
| 861 | } | 
|---|
| 862 | else    /* background context menu */ | 
|---|
| 863 | { | 
|---|
| 864 | hMenu = CreatePopupMenu(); | 
|---|
| 865 |  | 
|---|
| 866 | pCM = ISvBgCm_Constructor(This->pSFParent); | 
|---|
| 867 | IContextMenu_QueryContextMenu(pCM, hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0); | 
|---|
| 868 |  | 
|---|
| 869 | uCommand = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RETURNCMD,x,y,0,This->hWnd,NULL); | 
|---|
| 870 | DestroyMenu(hMenu); | 
|---|
| 871 |  | 
|---|
| 872 | TRACE("-- (%p)->(uCommand=0x%08x )\n",This, uCommand); | 
|---|
| 873 |  | 
|---|
| 874 | ZeroMemory(&cmi, sizeof(cmi)); | 
|---|
| 875 | cmi.cbSize = sizeof(cmi); | 
|---|
| 876 | cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand); | 
|---|
| 877 | cmi.hwnd = This->hWndParent; | 
|---|
| 878 | IContextMenu_InvokeCommand(pCM, &cmi); | 
|---|
| 879 |  | 
|---|
| 880 | IContextMenu_Release(pCM); | 
|---|
| 881 | } | 
|---|
| 882 | } | 
|---|
| 883 |  | 
|---|
| 884 | /********************************************************** | 
|---|
| 885 | *      ##### message handling ##### | 
|---|
| 886 | */ | 
|---|
| 887 |  | 
|---|
| 888 | /********************************************************** | 
|---|
| 889 | *  ShellView_OnSize() | 
|---|
| 890 | */ | 
|---|
| 891 | static LRESULT ShellView_OnSize(IShellViewImpl * This, WORD wWidth, WORD wHeight) | 
|---|
| 892 | { | 
|---|
| 893 | TRACE("%p width=%u height=%u\n",This, wWidth,wHeight); | 
|---|
| 894 |  | 
|---|
| 895 | /*resize the ListView to fit our window*/ | 
|---|
| 896 | if(This->hWndList) | 
|---|
| 897 | { | 
|---|
| 898 | MoveWindow(This->hWndList, 0, 0, wWidth, wHeight, TRUE); | 
|---|
| 899 | } | 
|---|
| 900 |  | 
|---|
| 901 | return S_OK; | 
|---|
| 902 | } | 
|---|
| 903 | /********************************************************** | 
|---|
| 904 | * ShellView_OnDeactivate() | 
|---|
| 905 | * | 
|---|
| 906 | * NOTES | 
|---|
| 907 | *  internal | 
|---|
| 908 | */ | 
|---|
| 909 | static void ShellView_OnDeactivate(IShellViewImpl * This) | 
|---|
| 910 | { | 
|---|
| 911 | TRACE("%p\n",This); | 
|---|
| 912 |  | 
|---|
| 913 | if(This->uState != SVUIA_DEACTIVATE) | 
|---|
| 914 | { | 
|---|
| 915 | if(This->hMenu) | 
|---|
| 916 | { | 
|---|
| 917 | IShellBrowser_SetMenuSB(This->pShellBrowser,0, 0, 0); | 
|---|
| 918 | IShellBrowser_RemoveMenusSB(This->pShellBrowser,This->hMenu); | 
|---|
| 919 | DestroyMenu(This->hMenu); | 
|---|
| 920 | This->hMenu = 0; | 
|---|
| 921 | } | 
|---|
| 922 |  | 
|---|
| 923 | This->uState = SVUIA_DEACTIVATE; | 
|---|
| 924 | } | 
|---|
| 925 | } | 
|---|
| 926 |  | 
|---|
| 927 | /********************************************************** | 
|---|
| 928 | * ShellView_OnActivate() | 
|---|
| 929 | */ | 
|---|
| 930 | static LRESULT ShellView_OnActivate(IShellViewImpl * This, UINT uState) | 
|---|
| 931 | {       OLEMENUGROUPWIDTHS   omw = { {0, 0, 0, 0, 0, 0} }; | 
|---|
| 932 | MENUITEMINFOA         mii; | 
|---|
| 933 | CHAR                szText[MAX_PATH]; | 
|---|
| 934 |  | 
|---|
| 935 | TRACE("%p uState=%x\n",This,uState); | 
|---|
| 936 |  | 
|---|
| 937 | /*don't do anything if the state isn't really changing */ | 
|---|
| 938 | if(This->uState == uState) | 
|---|
| 939 | { | 
|---|
| 940 | return S_OK; | 
|---|
| 941 | } | 
|---|
| 942 |  | 
|---|
| 943 | ShellView_OnDeactivate(This); | 
|---|
| 944 |  | 
|---|
| 945 | /*only do This if we are active */ | 
|---|
| 946 | if(uState != SVUIA_DEACTIVATE) | 
|---|
| 947 | { | 
|---|
| 948 | /*merge the menus */ | 
|---|
| 949 | This->hMenu = CreateMenu(); | 
|---|
| 950 |  | 
|---|
| 951 | if(This->hMenu) | 
|---|
| 952 | { | 
|---|
| 953 | IShellBrowser_InsertMenusSB(This->pShellBrowser, This->hMenu, &omw); | 
|---|
| 954 | TRACE("-- after fnInsertMenusSB\n"); | 
|---|
| 955 |  | 
|---|
| 956 | /*build the top level menu get the menu item's text*/ | 
|---|
| 957 | strcpy(szText,"dummy 31"); | 
|---|
| 958 |  | 
|---|
| 959 | ZeroMemory(&mii, sizeof(mii)); | 
|---|
| 960 | mii.cbSize = sizeof(mii); | 
|---|
| 961 | mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_STATE; | 
|---|
| 962 | mii.fType = MFT_STRING; | 
|---|
| 963 | mii.fState = MFS_ENABLED; | 
|---|
| 964 | mii.dwTypeData = szText; | 
|---|
| 965 | mii.hSubMenu = ShellView_BuildFileMenu(This); | 
|---|
| 966 |  | 
|---|
| 967 | /*insert our menu into the menu bar*/ | 
|---|
| 968 | if(mii.hSubMenu) | 
|---|
| 969 | { | 
|---|
| 970 | InsertMenuItemA(This->hMenu, FCIDM_MENU_HELP, FALSE, &mii); | 
|---|
| 971 | } | 
|---|
| 972 |  | 
|---|
| 973 | /*get the view menu so we can merge with it*/ | 
|---|
| 974 | ZeroMemory(&mii, sizeof(mii)); | 
|---|
| 975 | mii.cbSize = sizeof(mii); | 
|---|
| 976 | mii.fMask = MIIM_SUBMENU; | 
|---|
| 977 |  | 
|---|
| 978 | if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_VIEW, FALSE, &mii)) | 
|---|
| 979 | { | 
|---|
| 980 | ShellView_MergeViewMenu(This, mii.hSubMenu); | 
|---|
| 981 | } | 
|---|
| 982 |  | 
|---|
| 983 | /*add the items that should only be added if we have the focus*/ | 
|---|
| 984 | if(SVUIA_ACTIVATE_FOCUS == uState) | 
|---|
| 985 | { | 
|---|
| 986 | /*get the file menu so we can merge with it */ | 
|---|
| 987 | ZeroMemory(&mii, sizeof(mii)); | 
|---|
| 988 | mii.cbSize = sizeof(mii); | 
|---|
| 989 | mii.fMask = MIIM_SUBMENU; | 
|---|
| 990 |  | 
|---|
| 991 | if(GetMenuItemInfoA(This->hMenu, FCIDM_MENU_FILE, FALSE, &mii)) | 
|---|
| 992 | { | 
|---|
| 993 | ShellView_MergeFileMenu(This, mii.hSubMenu); | 
|---|
| 994 | } | 
|---|
| 995 | } | 
|---|
| 996 | TRACE("-- before fnSetMenuSB\n"); | 
|---|
| 997 | IShellBrowser_SetMenuSB(This->pShellBrowser, This->hMenu, 0, This->hWnd); | 
|---|
| 998 | } | 
|---|
| 999 | } | 
|---|
| 1000 | This->uState = uState; | 
|---|
| 1001 | TRACE("--\n"); | 
|---|
| 1002 | return S_OK; | 
|---|
| 1003 | } | 
|---|
| 1004 |  | 
|---|
| 1005 | /********************************************************** | 
|---|
| 1006 | *  ShellView_OnSetFocus() | 
|---|
| 1007 | * | 
|---|
| 1008 | */ | 
|---|
| 1009 | static LRESULT ShellView_OnSetFocus(IShellViewImpl * This) | 
|---|
| 1010 | { | 
|---|
| 1011 | TRACE("%p\n",This); | 
|---|
| 1012 |  | 
|---|
| 1013 | /* Tell the browser one of our windows has received the focus. This | 
|---|
| 1014 | should always be done before merging menus (OnActivate merges the | 
|---|
| 1015 | menus) if one of our windows has the focus.*/ | 
|---|
| 1016 |  | 
|---|
| 1017 | IShellBrowser_OnViewWindowActive(This->pShellBrowser,(IShellView*) This); | 
|---|
| 1018 | ShellView_OnActivate(This, SVUIA_ACTIVATE_FOCUS); | 
|---|
| 1019 |  | 
|---|
| 1020 | /* Set the focus to the listview */ | 
|---|
| 1021 | SetFocus(This->hWndList); | 
|---|
| 1022 |  | 
|---|
| 1023 | /* Notify the ICommDlgBrowser interface */ | 
|---|
| 1024 | OnStateChange(This,CDBOSC_SETFOCUS); | 
|---|
| 1025 |  | 
|---|
| 1026 | return 0; | 
|---|
| 1027 | } | 
|---|
| 1028 |  | 
|---|
| 1029 | /********************************************************** | 
|---|
| 1030 | * ShellView_OnKillFocus() | 
|---|
| 1031 | */ | 
|---|
| 1032 | static LRESULT ShellView_OnKillFocus(IShellViewImpl * This) | 
|---|
| 1033 | { | 
|---|
| 1034 | TRACE("(%p) stub\n",This); | 
|---|
| 1035 |  | 
|---|
| 1036 | ShellView_OnActivate(This, SVUIA_ACTIVATE_NOFOCUS); | 
|---|
| 1037 | /* Notify the ICommDlgBrowser */ | 
|---|
| 1038 | OnStateChange(This,CDBOSC_KILLFOCUS); | 
|---|
| 1039 |  | 
|---|
| 1040 | return 0; | 
|---|
| 1041 | } | 
|---|
| 1042 |  | 
|---|
| 1043 | /********************************************************** | 
|---|
| 1044 | * ShellView_OnCommand() | 
|---|
| 1045 | * | 
|---|
| 1046 | * NOTES | 
|---|
| 1047 | *       the CmdID's are the ones from the context menu | 
|---|
| 1048 | */ | 
|---|
| 1049 | static LRESULT ShellView_OnCommand(IShellViewImpl * This,DWORD dwCmdID, DWORD dwCmd, HWND hwndCmd) | 
|---|
| 1050 | { | 
|---|
| 1051 | TRACE("(%p)->(0x%08lx 0x%08lx 0x%08x) stub\n",This, dwCmdID, dwCmd, hwndCmd); | 
|---|
| 1052 |  | 
|---|
| 1053 | switch(dwCmdID) | 
|---|
| 1054 | { | 
|---|
| 1055 | case FCIDM_SHVIEW_SMALLICON: | 
|---|
| 1056 | This->FolderSettings.ViewMode = FVM_SMALLICON; | 
|---|
| 1057 | SetStyle (This, LVS_SMALLICON, LVS_TYPEMASK); | 
|---|
| 1058 | CheckToolbar(This); | 
|---|
| 1059 | break; | 
|---|
| 1060 |  | 
|---|
| 1061 | case FCIDM_SHVIEW_BIGICON: | 
|---|
| 1062 | This->FolderSettings.ViewMode = FVM_ICON; | 
|---|
| 1063 | SetStyle (This, LVS_ICON, LVS_TYPEMASK); | 
|---|
| 1064 | CheckToolbar(This); | 
|---|
| 1065 | break; | 
|---|
| 1066 |  | 
|---|
| 1067 | case FCIDM_SHVIEW_LISTVIEW: | 
|---|
| 1068 | This->FolderSettings.ViewMode = FVM_LIST; | 
|---|
| 1069 | SetStyle (This, LVS_LIST, LVS_TYPEMASK); | 
|---|
| 1070 | CheckToolbar(This); | 
|---|
| 1071 | break; | 
|---|
| 1072 |  | 
|---|
| 1073 | case FCIDM_SHVIEW_REPORTVIEW: | 
|---|
| 1074 | This->FolderSettings.ViewMode = FVM_DETAILS; | 
|---|
| 1075 | SetStyle (This, LVS_REPORT, LVS_TYPEMASK); | 
|---|
| 1076 | CheckToolbar(This); | 
|---|
| 1077 | break; | 
|---|
| 1078 |  | 
|---|
| 1079 | /* the menu-ID's for sorting are 0x30... see shrec.rc */ | 
|---|
| 1080 | case 0x30: | 
|---|
| 1081 | case 0x31: | 
|---|
| 1082 | case 0x32: | 
|---|
| 1083 | case 0x33: | 
|---|
| 1084 | This->ListViewSortInfo.nHeaderID = (LPARAM) (dwCmdID - 0x30); | 
|---|
| 1085 | This->ListViewSortInfo.bIsAscending = TRUE; | 
|---|
| 1086 | This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID; | 
|---|
| 1087 | ListView_SortItems(This->hWndList, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo))); | 
|---|
| 1088 | break; | 
|---|
| 1089 |  | 
|---|
| 1090 | default: | 
|---|
| 1091 | TRACE("-- COMMAND 0x%04lx unhandled\n", dwCmdID); | 
|---|
| 1092 | } | 
|---|
| 1093 | return 0; | 
|---|
| 1094 | } | 
|---|
| 1095 |  | 
|---|
| 1096 | /********************************************************** | 
|---|
| 1097 | * ShellView_OnNotify() | 
|---|
| 1098 | */ | 
|---|
| 1099 |  | 
|---|
| 1100 | static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpnmh) | 
|---|
| 1101 | {       LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lpnmh; | 
|---|
| 1102 | NMLVDISPINFOA *lpdi = (NMLVDISPINFOA *)lpnmh; | 
|---|
| 1103 | LPITEMIDLIST pidl; | 
|---|
| 1104 |  | 
|---|
| 1105 | TRACE("%p CtlID=%u lpnmh->code=%x\n",This,CtlID,lpnmh->code); | 
|---|
| 1106 |  | 
|---|
| 1107 | switch(lpnmh->code) | 
|---|
| 1108 | { | 
|---|
| 1109 | case NM_SETFOCUS: | 
|---|
| 1110 | TRACE("-- NM_SETFOCUS %p\n",This); | 
|---|
| 1111 | ShellView_OnSetFocus(This); | 
|---|
| 1112 | break; | 
|---|
| 1113 |  | 
|---|
| 1114 | case NM_KILLFOCUS: | 
|---|
| 1115 | TRACE("-- NM_KILLFOCUS %p\n",This); | 
|---|
| 1116 | ShellView_OnDeactivate(This); | 
|---|
| 1117 | /* Notify the ICommDlgBrowser interface */ | 
|---|
| 1118 | OnStateChange(This,CDBOSC_KILLFOCUS); | 
|---|
| 1119 | break; | 
|---|
| 1120 |  | 
|---|
| 1121 | case HDN_ENDTRACKA: | 
|---|
| 1122 | TRACE("-- HDN_ENDTRACKA %p\n",This); | 
|---|
| 1123 | /*nColumn1 = ListView_GetColumnWidth(This->hWndList, 0); | 
|---|
| 1124 | nColumn2 = ListView_GetColumnWidth(This->hWndList, 1);*/ | 
|---|
| 1125 | break; | 
|---|
| 1126 |  | 
|---|
| 1127 | case LVN_DELETEITEM: | 
|---|
| 1128 | TRACE("-- LVN_DELETEITEM %p\n",This); | 
|---|
| 1129 | SHFree((LPITEMIDLIST)lpnmlv->lParam);     /*delete the pidl because we made a copy of it*/ | 
|---|
| 1130 | break; | 
|---|
| 1131 |  | 
|---|
| 1132 | case LVN_ITEMACTIVATE: | 
|---|
| 1133 | TRACE("-- LVN_ITEMACTIVATE %p\n",This); | 
|---|
| 1134 | OnStateChange(This, CDBOSC_SELCHANGE);  /* the browser will get the IDataObject now */ | 
|---|
| 1135 | ShellView_DoContextMenu(This, 0, 0, TRUE); | 
|---|
| 1136 | break; | 
|---|
| 1137 |  | 
|---|
| 1138 | case LVN_COLUMNCLICK: | 
|---|
| 1139 | This->ListViewSortInfo.nHeaderID = lpnmlv->iSubItem; | 
|---|
| 1140 | if(This->ListViewSortInfo.nLastHeaderID == This->ListViewSortInfo.nHeaderID) | 
|---|
| 1141 | { | 
|---|
| 1142 | This->ListViewSortInfo.bIsAscending = !This->ListViewSortInfo.bIsAscending; | 
|---|
| 1143 | } | 
|---|
| 1144 | else | 
|---|
| 1145 | { | 
|---|
| 1146 | This->ListViewSortInfo.bIsAscending = TRUE; | 
|---|
| 1147 | } | 
|---|
| 1148 | This->ListViewSortInfo.nLastHeaderID = This->ListViewSortInfo.nHeaderID; | 
|---|
| 1149 |  | 
|---|
| 1150 | ListView_SortItems(lpnmlv->hdr.hwndFrom, ShellView_ListViewCompareItems, (LPARAM) (&(This->ListViewSortInfo))); | 
|---|
| 1151 | break; | 
|---|
| 1152 |  | 
|---|
| 1153 | case LVN_GETDISPINFOA: | 
|---|
| 1154 | case LVN_GETDISPINFOW: | 
|---|
| 1155 | TRACE("-- LVN_GETDISPINFO %p\n",This); | 
|---|
| 1156 | pidl = (LPITEMIDLIST)lpdi->item.lParam; | 
|---|
| 1157 |  | 
|---|
| 1158 | if(lpdi->item.mask & LVIF_TEXT)     /* text requested */ | 
|---|
| 1159 | { | 
|---|
| 1160 | if (This->pSF2Parent) | 
|---|
| 1161 | { | 
|---|
| 1162 | SHELLDETAILS sd; | 
|---|
| 1163 | IShellFolder2_GetDetailsOf(This->pSF2Parent, pidl, lpdi->item.iSubItem, &sd); | 
|---|
| 1164 | if (lpnmh->code == LVN_GETDISPINFOA) | 
|---|
| 1165 | { | 
|---|
| 1166 | StrRetToStrNA( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL); | 
|---|
| 1167 | TRACE("-- text=%s\n",lpdi->item.pszText); | 
|---|
| 1168 | } | 
|---|
| 1169 | else /* LVN_GETDISPINFOW */ | 
|---|
| 1170 | { | 
|---|
| 1171 | StrRetToStrNW( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL); | 
|---|
| 1172 | TRACE("-- text=%s\n",debugstr_w((WCHAR*)(lpdi->item.pszText))); | 
|---|
| 1173 | } | 
|---|
| 1174 | } | 
|---|
| 1175 | else | 
|---|
| 1176 | { | 
|---|
| 1177 | FIXME("no SF2\n"); | 
|---|
| 1178 | } | 
|---|
| 1179 | } | 
|---|
| 1180 | if(lpdi->item.mask & LVIF_IMAGE)    /* image requested */ | 
|---|
| 1181 | { | 
|---|
| 1182 | lpdi->item.iImage = SHMapPIDLToSystemImageListIndex(This->pSFParent, pidl, 0); | 
|---|
| 1183 | } | 
|---|
| 1184 | break; | 
|---|
| 1185 |  | 
|---|
| 1186 | case LVN_ITEMCHANGED: | 
|---|
| 1187 | TRACE("-- LVN_ITEMCHANGED %p\n",This); | 
|---|
| 1188 | OnStateChange(This, CDBOSC_SELCHANGE);  /* the browser will get the IDataObject now */ | 
|---|
| 1189 | break; | 
|---|
| 1190 |  | 
|---|
| 1191 | case LVN_BEGINDRAG: | 
|---|
| 1192 | case LVN_BEGINRDRAG: | 
|---|
| 1193 | TRACE("-- LVN_BEGINDRAG\n"); | 
|---|
| 1194 |  | 
|---|
| 1195 | if (ShellView_GetSelections(This)) | 
|---|
| 1196 | { | 
|---|
| 1197 | IDataObject * pda; | 
|---|
| 1198 | DWORD dwAttributes = SFGAO_CANLINK; | 
|---|
| 1199 | DWORD dwEffect = DROPEFFECT_COPY | DROPEFFECT_MOVE; | 
|---|
| 1200 |  | 
|---|
| 1201 | if(GetShellOle()) | 
|---|
| 1202 | { | 
|---|
| 1203 | if (SUCCEEDED(IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, &IID_IDataObject,0,(LPVOID *)&pda))) | 
|---|
| 1204 | { | 
|---|
| 1205 | IDropSource * pds = (IDropSource*)&(This->lpvtblDropSource);  /* own DropSource interface */ | 
|---|
| 1206 |  | 
|---|
| 1207 | if (SUCCEEDED(IShellFolder_GetAttributesOf(This->pSFParent, This->cidl, This->apidl, &dwAttributes))) | 
|---|
| 1208 | { | 
|---|
| 1209 | if (dwAttributes & SFGAO_CANLINK) | 
|---|
| 1210 | { | 
|---|
| 1211 | dwEffect |= DROPEFFECT_LINK; | 
|---|
| 1212 | } | 
|---|
| 1213 | } | 
|---|
| 1214 |  | 
|---|
| 1215 | if (pds) | 
|---|
| 1216 | { | 
|---|
| 1217 | DWORD dwEffect; | 
|---|
| 1218 | pDoDragDrop(pda, pds, dwEffect, &dwEffect); | 
|---|
| 1219 | } | 
|---|
| 1220 | IDataObject_Release(pda); | 
|---|
| 1221 | } | 
|---|
| 1222 | } | 
|---|
| 1223 | } | 
|---|
| 1224 | break; | 
|---|
| 1225 |  | 
|---|
| 1226 | case LVN_BEGINLABELEDITA: | 
|---|
| 1227 | { | 
|---|
| 1228 | DWORD dwAttr = SFGAO_CANRENAME; | 
|---|
| 1229 | pidl = (LPITEMIDLIST)lpdi->item.lParam; | 
|---|
| 1230 |  | 
|---|
| 1231 | TRACE("-- LVN_BEGINLABELEDITA %p\n",This); | 
|---|
| 1232 |  | 
|---|
| 1233 | IShellFolder_GetAttributesOf(This->pSFParent, 1, &pidl, &dwAttr); | 
|---|
| 1234 | if (SFGAO_CANRENAME & dwAttr) | 
|---|
| 1235 | { | 
|---|
| 1236 | return FALSE; | 
|---|
| 1237 | } | 
|---|
| 1238 | return TRUE; | 
|---|
| 1239 | } | 
|---|
| 1240 | break; | 
|---|
| 1241 |  | 
|---|
| 1242 | case LVN_ENDLABELEDITA: | 
|---|
| 1243 | { | 
|---|
| 1244 | TRACE("-- LVN_ENDLABELEDITA %p\n",This); | 
|---|
| 1245 | if (lpdi->item.pszText) | 
|---|
| 1246 | { | 
|---|
| 1247 | HRESULT hr; | 
|---|
| 1248 | WCHAR wszNewName[MAX_PATH]; | 
|---|
| 1249 | LVITEMA lvItem; | 
|---|
| 1250 |  | 
|---|
| 1251 | ZeroMemory(&lvItem, sizeof(LVITEMA)); | 
|---|
| 1252 | lvItem.iItem = lpdi->item.iItem; | 
|---|
| 1253 | lvItem.mask = LVIF_PARAM; | 
|---|
| 1254 | ListView_GetItemA(This->hWndList, &lvItem); | 
|---|
| 1255 |  | 
|---|
| 1256 | pidl = (LPITEMIDLIST)lpdi->item.lParam; | 
|---|
| 1257 | if (!MultiByteToWideChar( CP_ACP, 0, lpdi->item.pszText, -1, wszNewName, MAX_PATH )) | 
|---|
| 1258 | wszNewName[MAX_PATH-1] = 0; | 
|---|
| 1259 | hr = IShellFolder_SetNameOf(This->pSFParent, 0, pidl, wszNewName, SHGDN_INFOLDER, &pidl); | 
|---|
| 1260 |  | 
|---|
| 1261 | if(SUCCEEDED(hr) && pidl) | 
|---|
| 1262 | { | 
|---|
| 1263 | lvItem.mask = LVIF_PARAM; | 
|---|
| 1264 | lvItem.lParam = (LPARAM)pidl; | 
|---|
| 1265 | ListView_SetItemA(This->hWndList, &lvItem); | 
|---|
| 1266 | return TRUE; | 
|---|
| 1267 | } | 
|---|
| 1268 | } | 
|---|
| 1269 | return FALSE; | 
|---|
| 1270 | } | 
|---|
| 1271 | break; | 
|---|
| 1272 |  | 
|---|
| 1273 | case LVN_KEYDOWN: | 
|---|
| 1274 | { | 
|---|
| 1275 | /*  MSG msg; | 
|---|
| 1276 | msg.hwnd = This->hWnd; | 
|---|
| 1277 | msg.message = WM_KEYDOWN; | 
|---|
| 1278 | msg.wParam = plvKeyDown->wVKey; | 
|---|
| 1279 | msg.lParam = 0; | 
|---|
| 1280 | msg.time = 0; | 
|---|
| 1281 | msg.pt = 0;*/ | 
|---|
| 1282 |  | 
|---|
| 1283 | LPNMLVKEYDOWN plvKeyDown = (LPNMLVKEYDOWN) lpnmh; | 
|---|
| 1284 |  | 
|---|
| 1285 | /* initiate a rename of the selected file or directory */ | 
|---|
| 1286 | if(plvKeyDown->wVKey == VK_F2) | 
|---|
| 1287 | { | 
|---|
| 1288 | /* see how many files are selected */ | 
|---|
| 1289 | int i = ListView_GetSelectedCount(This->hWndList); | 
|---|
| 1290 |  | 
|---|
| 1291 | /* get selected item */ | 
|---|
| 1292 | if(i == 1) | 
|---|
| 1293 | { | 
|---|
| 1294 | /* get selected item */ | 
|---|
| 1295 | i = ListView_GetNextItem(This->hWndList, -1, | 
|---|
| 1296 | LVNI_SELECTED); | 
|---|
| 1297 |  | 
|---|
| 1298 | ListView_EnsureVisible(This->hWndList, i, 0); | 
|---|
| 1299 | ListView_EditLabelA(This->hWndList, i); | 
|---|
| 1300 | } | 
|---|
| 1301 | } | 
|---|
| 1302 | #if 0 | 
|---|
| 1303 | TranslateAccelerator(This->hWnd, This->hAccel, &msg) | 
|---|
| 1304 | #endif | 
|---|
| 1305 | else if(plvKeyDown->wVKey == VK_DELETE) | 
|---|
| 1306 | { | 
|---|
| 1307 | int i, item_index; | 
|---|
| 1308 | LVITEMA item; | 
|---|
| 1309 | LPITEMIDLIST* pItems; | 
|---|
| 1310 | ISFHelper *psfhlp; | 
|---|
| 1311 |  | 
|---|
| 1312 | IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper, | 
|---|
| 1313 | (LPVOID*)&psfhlp); | 
|---|
| 1314 |  | 
|---|
| 1315 | if(!(i = ListView_GetSelectedCount(This->hWndList))) | 
|---|
| 1316 | break; | 
|---|
| 1317 |  | 
|---|
| 1318 | /* allocate memory for the pidl array */ | 
|---|
| 1319 | pItems = HeapAlloc(GetProcessHeap(), 0, | 
|---|
| 1320 | sizeof(LPITEMIDLIST) * i); | 
|---|
| 1321 |  | 
|---|
| 1322 | /* retrieve all selected items */ | 
|---|
| 1323 | i = 0; | 
|---|
| 1324 | item_index = -1; | 
|---|
| 1325 | while(ListView_GetSelectedCount(This->hWndList) > i) | 
|---|
| 1326 | { | 
|---|
| 1327 | /* get selected item */ | 
|---|
| 1328 | item_index = ListView_GetNextItem(This->hWndList, | 
|---|
| 1329 | item_index, LVNI_SELECTED); | 
|---|
| 1330 | #ifdef __WIN32OS2__ | 
|---|
| 1331 | item.mask = LVIF_PARAM; | 
|---|
| 1332 | #endif | 
|---|
| 1333 | item.iItem = item_index; | 
|---|
| 1334 | ListView_GetItemA(This->hWndList, &item); | 
|---|
| 1335 |  | 
|---|
| 1336 | /* get item pidl */ | 
|---|
| 1337 | pItems[i] = (LPITEMIDLIST)item.lParam; | 
|---|
| 1338 |  | 
|---|
| 1339 | i++; | 
|---|
| 1340 | } | 
|---|
| 1341 |  | 
|---|
| 1342 | /* perform the item deletion */ | 
|---|
| 1343 | ISFHelper_DeleteItems(psfhlp, i, pItems); | 
|---|
| 1344 |  | 
|---|
| 1345 | /* free pidl array memory */ | 
|---|
| 1346 | HeapFree(GetProcessHeap(), 0, pItems); | 
|---|
| 1347 | } | 
|---|
| 1348 | else | 
|---|
| 1349 | FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey); | 
|---|
| 1350 | } | 
|---|
| 1351 | break; | 
|---|
| 1352 |  | 
|---|
| 1353 | default: | 
|---|
| 1354 | TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code); | 
|---|
| 1355 | break;; | 
|---|
| 1356 | } | 
|---|
| 1357 | return 0; | 
|---|
| 1358 | } | 
|---|
| 1359 |  | 
|---|
| 1360 | /********************************************************** | 
|---|
| 1361 | * ShellView_OnChange() | 
|---|
| 1362 | */ | 
|---|
| 1363 |  | 
|---|
| 1364 | static LRESULT ShellView_OnChange(IShellViewImpl * This, LPITEMIDLIST * Pidls, LONG wEventId) | 
|---|
| 1365 | { | 
|---|
| 1366 |  | 
|---|
| 1367 | TRACE("(%p)(%p,%p,0x%08lx)\n", This, Pidls[0], Pidls[1], wEventId); | 
|---|
| 1368 | switch(wEventId) | 
|---|
| 1369 | { | 
|---|
| 1370 | case SHCNE_MKDIR: | 
|---|
| 1371 | case SHCNE_CREATE: | 
|---|
| 1372 | LV_AddItem(This, Pidls[0]); | 
|---|
| 1373 | break; | 
|---|
| 1374 | case SHCNE_RMDIR: | 
|---|
| 1375 | case SHCNE_DELETE: | 
|---|
| 1376 | LV_DeleteItem(This, Pidls[0]); | 
|---|
| 1377 | break; | 
|---|
| 1378 | case SHCNE_RENAMEFOLDER: | 
|---|
| 1379 | case SHCNE_RENAMEITEM: | 
|---|
| 1380 | LV_RenameItem(This, Pidls[0], Pidls[1]); | 
|---|
| 1381 | break; | 
|---|
| 1382 | case SHCNE_UPDATEITEM: | 
|---|
| 1383 | break; | 
|---|
| 1384 | } | 
|---|
| 1385 | return TRUE; | 
|---|
| 1386 | } | 
|---|
| 1387 | /********************************************************** | 
|---|
| 1388 | *  ShellView_WndProc | 
|---|
| 1389 | */ | 
|---|
| 1390 |  | 
|---|
| 1391 | static LRESULT CALLBACK ShellView_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) | 
|---|
| 1392 | { | 
|---|
| 1393 | IShellViewImpl * pThis = (IShellViewImpl*)GetWindowLongA(hWnd, GWL_USERDATA); | 
|---|
| 1394 | LPCREATESTRUCTA lpcs; | 
|---|
| 1395 |  | 
|---|
| 1396 | TRACE("(hwnd=%x msg=%x wparm=%x lparm=%lx)\n",hWnd, uMessage, wParam, lParam); | 
|---|
| 1397 |  | 
|---|
| 1398 | switch (uMessage) | 
|---|
| 1399 | { | 
|---|
| 1400 | case WM_NCCREATE: | 
|---|
| 1401 | lpcs = (LPCREATESTRUCTA)lParam; | 
|---|
| 1402 | pThis = (IShellViewImpl*)(lpcs->lpCreateParams); | 
|---|
| 1403 | SetWindowLongA(hWnd, GWL_USERDATA, (LONG)pThis); | 
|---|
| 1404 | pThis->hWnd = hWnd;        /*set the window handle*/ | 
|---|
| 1405 | break; | 
|---|
| 1406 |  | 
|---|
| 1407 | case WM_SIZE:         return ShellView_OnSize(pThis,LOWORD(lParam), HIWORD(lParam)); | 
|---|
| 1408 | case WM_SETFOCUS:     return ShellView_OnSetFocus(pThis); | 
|---|
| 1409 | case WM_KILLFOCUS:    return ShellView_OnKillFocus(pThis); | 
|---|
| 1410 | case WM_CREATE:       return ShellView_OnCreate(pThis); | 
|---|
| 1411 | case WM_ACTIVATE:     return ShellView_OnActivate(pThis, SVUIA_ACTIVATE_FOCUS); | 
|---|
| 1412 | case WM_NOTIFY:       return ShellView_OnNotify(pThis,(UINT)wParam, (LPNMHDR)lParam); | 
|---|
| 1413 | case WM_COMMAND:      return ShellView_OnCommand(pThis, | 
|---|
| 1414 | GET_WM_COMMAND_ID(wParam, lParam), | 
|---|
| 1415 | GET_WM_COMMAND_CMD(wParam, lParam), | 
|---|
| 1416 | GET_WM_COMMAND_HWND(wParam, lParam)); | 
|---|
| 1417 | case SHV_CHANGE_NOTIFY: return ShellView_OnChange(pThis, (LPITEMIDLIST*)wParam, (LONG)lParam); | 
|---|
| 1418 |  | 
|---|
| 1419 | case WM_CONTEXTMENU:  ShellView_DoContextMenu(pThis, LOWORD(lParam), HIWORD(lParam), FALSE); | 
|---|
| 1420 | return 0; | 
|---|
| 1421 |  | 
|---|
| 1422 | case WM_SHOWWINDOW:   UpdateWindow(pThis->hWndList); | 
|---|
| 1423 | break; | 
|---|
| 1424 |  | 
|---|
| 1425 | case WM_GETDLGCODE:   return SendMessageA(pThis->hWndList,uMessage,0,0); | 
|---|
| 1426 |  | 
|---|
| 1427 | case WM_DESTROY:      if(GetShellOle()) | 
|---|
| 1428 | { | 
|---|
| 1429 | pRevokeDragDrop(pThis->hWnd); | 
|---|
| 1430 | } | 
|---|
| 1431 | SHChangeNotifyDeregister(pThis->hNotify); | 
|---|
| 1432 | break; | 
|---|
| 1433 | } | 
|---|
| 1434 |  | 
|---|
| 1435 | return DefWindowProcA (hWnd, uMessage, wParam, lParam); | 
|---|
| 1436 | } | 
|---|
| 1437 | /********************************************************** | 
|---|
| 1438 | * | 
|---|
| 1439 | * | 
|---|
| 1440 | *  The INTERFACE of the IShellView object | 
|---|
| 1441 | * | 
|---|
| 1442 | * | 
|---|
| 1443 | ********************************************************** | 
|---|
| 1444 | *  IShellView_QueryInterface | 
|---|
| 1445 | */ | 
|---|
| 1446 | static HRESULT WINAPI IShellView_fnQueryInterface(IShellView * iface,REFIID riid, LPVOID *ppvObj) | 
|---|
| 1447 | { | 
|---|
| 1448 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1449 |  | 
|---|
| 1450 | TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); | 
|---|
| 1451 |  | 
|---|
| 1452 | *ppvObj = NULL; | 
|---|
| 1453 |  | 
|---|
| 1454 | if(IsEqualIID(riid, &IID_IUnknown)) | 
|---|
| 1455 | { | 
|---|
| 1456 | *ppvObj = This; | 
|---|
| 1457 | } | 
|---|
| 1458 | else if(IsEqualIID(riid, &IID_IShellView)) | 
|---|
| 1459 | { | 
|---|
| 1460 | *ppvObj = (IShellView*)This; | 
|---|
| 1461 | } | 
|---|
| 1462 | else if(IsEqualIID(riid, &IID_IOleCommandTarget)) | 
|---|
| 1463 | { | 
|---|
| 1464 | *ppvObj = (IOleCommandTarget*)&(This->lpvtblOleCommandTarget); | 
|---|
| 1465 | } | 
|---|
| 1466 | else if(IsEqualIID(riid, &IID_IDropTarget)) | 
|---|
| 1467 | { | 
|---|
| 1468 | *ppvObj = (IDropTarget*)&(This->lpvtblDropTarget); | 
|---|
| 1469 | } | 
|---|
| 1470 | else if(IsEqualIID(riid, &IID_IDropSource)) | 
|---|
| 1471 | { | 
|---|
| 1472 | *ppvObj = (IDropSource*)&(This->lpvtblDropSource); | 
|---|
| 1473 | } | 
|---|
| 1474 | else if(IsEqualIID(riid, &IID_IViewObject)) | 
|---|
| 1475 | { | 
|---|
| 1476 | *ppvObj = (IViewObject*)&(This->lpvtblViewObject); | 
|---|
| 1477 | } | 
|---|
| 1478 |  | 
|---|
| 1479 | if(*ppvObj) | 
|---|
| 1480 | { | 
|---|
| 1481 | IUnknown_AddRef( (IUnknown*)*ppvObj ); | 
|---|
| 1482 | TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj); | 
|---|
| 1483 | return S_OK; | 
|---|
| 1484 | } | 
|---|
| 1485 | TRACE("-- Interface: E_NOINTERFACE\n"); | 
|---|
| 1486 | return E_NOINTERFACE; | 
|---|
| 1487 | } | 
|---|
| 1488 |  | 
|---|
| 1489 | /********************************************************** | 
|---|
| 1490 | *  IShellView_AddRef | 
|---|
| 1491 | */ | 
|---|
| 1492 | static ULONG WINAPI IShellView_fnAddRef(IShellView * iface) | 
|---|
| 1493 | { | 
|---|
| 1494 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1495 |  | 
|---|
| 1496 | TRACE("(%p)->(count=%lu)\n",This,This->ref); | 
|---|
| 1497 |  | 
|---|
| 1498 | shell32_ObjCount++; | 
|---|
| 1499 | return ++(This->ref); | 
|---|
| 1500 | } | 
|---|
| 1501 | /********************************************************** | 
|---|
| 1502 | *  IShellView_Release | 
|---|
| 1503 | */ | 
|---|
| 1504 | static ULONG WINAPI IShellView_fnRelease(IShellView * iface) | 
|---|
| 1505 | { | 
|---|
| 1506 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1507 |  | 
|---|
| 1508 | TRACE("(%p)->()\n",This); | 
|---|
| 1509 |  | 
|---|
| 1510 | shell32_ObjCount--; | 
|---|
| 1511 |  | 
|---|
| 1512 | if (!--(This->ref)) | 
|---|
| 1513 | { | 
|---|
| 1514 | TRACE(" destroying IShellView(%p)\n",This); | 
|---|
| 1515 |  | 
|---|
| 1516 | if(This->pSFParent) | 
|---|
| 1517 | IShellFolder_Release(This->pSFParent); | 
|---|
| 1518 |  | 
|---|
| 1519 | if(This->pSF2Parent) | 
|---|
| 1520 | IShellFolder2_Release(This->pSF2Parent); | 
|---|
| 1521 |  | 
|---|
| 1522 | if (This->apidl) | 
|---|
| 1523 | SHFree(This->apidl); | 
|---|
| 1524 |  | 
|---|
| 1525 | if (This->pCommDlgBrowser) | 
|---|
| 1526 | ICommDlgBrowser_Release(This->pCommDlgBrowser); | 
|---|
| 1527 |  | 
|---|
| 1528 | HeapFree(GetProcessHeap(),0,This); | 
|---|
| 1529 | return 0; | 
|---|
| 1530 | } | 
|---|
| 1531 | return This->ref; | 
|---|
| 1532 | } | 
|---|
| 1533 |  | 
|---|
| 1534 | /********************************************************** | 
|---|
| 1535 | *  ShellView_GetWindow | 
|---|
| 1536 | */ | 
|---|
| 1537 | static HRESULT WINAPI IShellView_fnGetWindow(IShellView * iface,HWND * phWnd) | 
|---|
| 1538 | { | 
|---|
| 1539 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1540 |  | 
|---|
| 1541 | TRACE("(%p)\n",This); | 
|---|
| 1542 |  | 
|---|
| 1543 | *phWnd = This->hWnd; | 
|---|
| 1544 |  | 
|---|
| 1545 | return S_OK; | 
|---|
| 1546 | } | 
|---|
| 1547 |  | 
|---|
| 1548 | static HRESULT WINAPI IShellView_fnContextSensitiveHelp(IShellView * iface,BOOL fEnterMode) | 
|---|
| 1549 | { | 
|---|
| 1550 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1551 |  | 
|---|
| 1552 | FIXME("(%p) stub\n",This); | 
|---|
| 1553 |  | 
|---|
| 1554 | return E_NOTIMPL; | 
|---|
| 1555 | } | 
|---|
| 1556 |  | 
|---|
| 1557 | /********************************************************** | 
|---|
| 1558 | * IShellView_TranslateAccelerator | 
|---|
| 1559 | * | 
|---|
| 1560 | * FIXME: | 
|---|
| 1561 | *  use the accel functions | 
|---|
| 1562 | */ | 
|---|
| 1563 | static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg) | 
|---|
| 1564 | { | 
|---|
| 1565 | #if 0 | 
|---|
| 1566 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1567 |  | 
|---|
| 1568 | FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam); | 
|---|
| 1569 | #endif | 
|---|
| 1570 |  | 
|---|
| 1571 | if ((lpmsg->message>=WM_KEYFIRST) && (lpmsg->message>=WM_KEYLAST)) | 
|---|
| 1572 | { | 
|---|
| 1573 | TRACE("-- key=0x04%x\n",lpmsg->wParam) ; | 
|---|
| 1574 | } | 
|---|
| 1575 | return S_FALSE; /* not handled */ | 
|---|
| 1576 | } | 
|---|
| 1577 |  | 
|---|
| 1578 | static HRESULT WINAPI IShellView_fnEnableModeless(IShellView * iface,BOOL fEnable) | 
|---|
| 1579 | { | 
|---|
| 1580 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1581 |  | 
|---|
| 1582 | FIXME("(%p) stub\n",This); | 
|---|
| 1583 |  | 
|---|
| 1584 | return E_NOTIMPL; | 
|---|
| 1585 | } | 
|---|
| 1586 |  | 
|---|
| 1587 | static HRESULT WINAPI IShellView_fnUIActivate(IShellView * iface,UINT uState) | 
|---|
| 1588 | { | 
|---|
| 1589 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1590 |  | 
|---|
| 1591 | /* | 
|---|
| 1592 | CHAR    szName[MAX_PATH]; | 
|---|
| 1593 | */ | 
|---|
| 1594 | LRESULT lResult; | 
|---|
| 1595 | int     nPartArray[1] = {-1}; | 
|---|
| 1596 |  | 
|---|
| 1597 | TRACE("(%p)->(state=%x) stub\n",This, uState); | 
|---|
| 1598 |  | 
|---|
| 1599 | /*don't do anything if the state isn't really changing*/ | 
|---|
| 1600 | if(This->uState == uState) | 
|---|
| 1601 | { | 
|---|
| 1602 | return S_OK; | 
|---|
| 1603 | } | 
|---|
| 1604 |  | 
|---|
| 1605 | /*OnActivate handles the menu merging and internal state*/ | 
|---|
| 1606 | ShellView_OnActivate(This, uState); | 
|---|
| 1607 |  | 
|---|
| 1608 | /*only do This if we are active*/ | 
|---|
| 1609 | if(uState != SVUIA_DEACTIVATE) | 
|---|
| 1610 | { | 
|---|
| 1611 |  | 
|---|
| 1612 | /* | 
|---|
| 1613 | GetFolderPath is not a method of IShellFolder | 
|---|
| 1614 | IShellFolder_GetFolderPath( This->pSFParent, szName, sizeof(szName) ); | 
|---|
| 1615 | */ | 
|---|
| 1616 | /* set the number of parts */ | 
|---|
| 1617 | IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETPARTS, 1, | 
|---|
| 1618 | (LPARAM)nPartArray, &lResult); | 
|---|
| 1619 |  | 
|---|
| 1620 | /* set the text for the parts */ | 
|---|
| 1621 | /* | 
|---|
| 1622 | IShellBrowser_SendControlMsg(This->pShellBrowser, FCW_STATUS, SB_SETTEXTA, | 
|---|
| 1623 | 0, (LPARAM)szName, &lResult); | 
|---|
| 1624 | */ | 
|---|
| 1625 | } | 
|---|
| 1626 |  | 
|---|
| 1627 | return S_OK; | 
|---|
| 1628 | } | 
|---|
| 1629 |  | 
|---|
| 1630 | static HRESULT WINAPI IShellView_fnRefresh(IShellView * iface) | 
|---|
| 1631 | { | 
|---|
| 1632 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1633 |  | 
|---|
| 1634 | TRACE("(%p)\n",This); | 
|---|
| 1635 |  | 
|---|
| 1636 | ListView_DeleteAllItems(This->hWndList); | 
|---|
| 1637 | ShellView_FillList(This); | 
|---|
| 1638 |  | 
|---|
| 1639 | return S_OK; | 
|---|
| 1640 | } | 
|---|
| 1641 |  | 
|---|
| 1642 | static HRESULT WINAPI IShellView_fnCreateViewWindow( | 
|---|
| 1643 | IShellView * iface, | 
|---|
| 1644 | IShellView *lpPrevView, | 
|---|
| 1645 | LPCFOLDERSETTINGS lpfs, | 
|---|
| 1646 | IShellBrowser * psb, | 
|---|
| 1647 | RECT * prcView, | 
|---|
| 1648 | HWND  *phWnd) | 
|---|
| 1649 | { | 
|---|
| 1650 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1651 |  | 
|---|
| 1652 | WNDCLASSA wc; | 
|---|
| 1653 | *phWnd = 0; | 
|---|
| 1654 |  | 
|---|
| 1655 |  | 
|---|
| 1656 | TRACE("(%p)->(shlview=%p set=%p shlbrs=%p rec=%p hwnd=%p) incomplete\n",This, lpPrevView,lpfs, psb, prcView, phWnd); | 
|---|
| 1657 | 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); | 
|---|
| 1658 |  | 
|---|
| 1659 | /*set up the member variables*/ | 
|---|
| 1660 | This->pShellBrowser = psb; | 
|---|
| 1661 | This->FolderSettings = *lpfs; | 
|---|
| 1662 |  | 
|---|
| 1663 | /*get our parent window*/ | 
|---|
| 1664 | IShellBrowser_AddRef(This->pShellBrowser); | 
|---|
| 1665 | IShellBrowser_GetWindow(This->pShellBrowser, &(This->hWndParent)); | 
|---|
| 1666 |  | 
|---|
| 1667 | /* try to get the ICommDlgBrowserInterface, adds a reference !!! */ | 
|---|
| 1668 | This->pCommDlgBrowser=NULL; | 
|---|
| 1669 | if ( SUCCEEDED (IShellBrowser_QueryInterface( This->pShellBrowser, | 
|---|
| 1670 | (REFIID)&IID_ICommDlgBrowser, (LPVOID*) &This->pCommDlgBrowser))) | 
|---|
| 1671 | { | 
|---|
| 1672 | TRACE("-- CommDlgBrowser\n"); | 
|---|
| 1673 | } | 
|---|
| 1674 |  | 
|---|
| 1675 | /*if our window class has not been registered, then do so*/ | 
|---|
| 1676 | if(!GetClassInfoA(shell32_hInstance, SV_CLASS_NAME, &wc)) | 
|---|
| 1677 | { | 
|---|
| 1678 | ZeroMemory(&wc, sizeof(wc)); | 
|---|
| 1679 | wc.style              = CS_HREDRAW | CS_VREDRAW; | 
|---|
| 1680 | wc.lpfnWndProc        = (WNDPROC) ShellView_WndProc; | 
|---|
| 1681 | wc.cbClsExtra         = 0; | 
|---|
| 1682 | wc.cbWndExtra         = 0; | 
|---|
| 1683 | wc.hInstance          = shell32_hInstance; | 
|---|
| 1684 | wc.hIcon              = 0; | 
|---|
| 1685 | wc.hCursor            = LoadCursorA (0, IDC_ARROWA); | 
|---|
| 1686 | wc.hbrBackground      = (HBRUSH) (COLOR_WINDOW + 1); | 
|---|
| 1687 | wc.lpszMenuName       = NULL; | 
|---|
| 1688 | wc.lpszClassName      = SV_CLASS_NAME; | 
|---|
| 1689 |  | 
|---|
| 1690 | if(!RegisterClassA(&wc)) | 
|---|
| 1691 | return E_FAIL; | 
|---|
| 1692 | } | 
|---|
| 1693 |  | 
|---|
| 1694 | *phWnd = CreateWindowExA(0, | 
|---|
| 1695 | SV_CLASS_NAME, | 
|---|
| 1696 | NULL, | 
|---|
| 1697 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, | 
|---|
| 1698 | prcView->left, | 
|---|
| 1699 | prcView->top, | 
|---|
| 1700 | prcView->right - prcView->left, | 
|---|
| 1701 | prcView->bottom - prcView->top, | 
|---|
| 1702 | This->hWndParent, | 
|---|
| 1703 | 0, | 
|---|
| 1704 | shell32_hInstance, | 
|---|
| 1705 | (LPVOID)This); | 
|---|
| 1706 |  | 
|---|
| 1707 | CheckToolbar(This); | 
|---|
| 1708 |  | 
|---|
| 1709 | if(!*phWnd) return E_FAIL; | 
|---|
| 1710 |  | 
|---|
| 1711 | return S_OK; | 
|---|
| 1712 | } | 
|---|
| 1713 |  | 
|---|
| 1714 | static HRESULT WINAPI IShellView_fnDestroyViewWindow(IShellView * iface) | 
|---|
| 1715 | { | 
|---|
| 1716 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1717 |  | 
|---|
| 1718 | TRACE("(%p)\n",This); | 
|---|
| 1719 |  | 
|---|
| 1720 | /*Make absolutely sure all our UI is cleaned up.*/ | 
|---|
| 1721 | IShellView_UIActivate((IShellView*)This, SVUIA_DEACTIVATE); | 
|---|
| 1722 |  | 
|---|
| 1723 | if(This->hMenu) | 
|---|
| 1724 | { | 
|---|
| 1725 | DestroyMenu(This->hMenu); | 
|---|
| 1726 | } | 
|---|
| 1727 |  | 
|---|
| 1728 | DestroyWindow(This->hWnd); | 
|---|
| 1729 | IShellBrowser_Release(This->pShellBrowser); | 
|---|
| 1730 |  | 
|---|
| 1731 | return S_OK; | 
|---|
| 1732 | } | 
|---|
| 1733 |  | 
|---|
| 1734 | static HRESULT WINAPI IShellView_fnGetCurrentInfo(IShellView * iface, LPFOLDERSETTINGS lpfs) | 
|---|
| 1735 | { | 
|---|
| 1736 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1737 |  | 
|---|
| 1738 | TRACE("(%p)->(%p) vmode=%x flags=%x\n",This, lpfs, | 
|---|
| 1739 | This->FolderSettings.ViewMode, This->FolderSettings.fFlags); | 
|---|
| 1740 |  | 
|---|
| 1741 | if (!lpfs) return E_INVALIDARG; | 
|---|
| 1742 |  | 
|---|
| 1743 | *lpfs = This->FolderSettings; | 
|---|
| 1744 | return NOERROR; | 
|---|
| 1745 | } | 
|---|
| 1746 |  | 
|---|
| 1747 | static HRESULT WINAPI IShellView_fnAddPropertySheetPages(IShellView * iface, DWORD dwReserved,LPFNADDPROPSHEETPAGE lpfn, LPARAM lparam) | 
|---|
| 1748 | { | 
|---|
| 1749 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1750 |  | 
|---|
| 1751 | FIXME("(%p) stub\n",This); | 
|---|
| 1752 |  | 
|---|
| 1753 | return E_NOTIMPL; | 
|---|
| 1754 | } | 
|---|
| 1755 |  | 
|---|
| 1756 | static HRESULT WINAPI IShellView_fnSaveViewState(IShellView * iface) | 
|---|
| 1757 | { | 
|---|
| 1758 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1759 |  | 
|---|
| 1760 | FIXME("(%p) stub\n",This); | 
|---|
| 1761 |  | 
|---|
| 1762 | return S_OK; | 
|---|
| 1763 | } | 
|---|
| 1764 |  | 
|---|
| 1765 | static HRESULT WINAPI IShellView_fnSelectItem( | 
|---|
| 1766 | IShellView * iface, | 
|---|
| 1767 | LPCITEMIDLIST pidl, | 
|---|
| 1768 | UINT uFlags) | 
|---|
| 1769 | { | 
|---|
| 1770 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1771 | int i; | 
|---|
| 1772 |  | 
|---|
| 1773 | TRACE("(%p)->(pidl=%p, 0x%08x) stub\n",This, pidl, uFlags); | 
|---|
| 1774 |  | 
|---|
| 1775 | i = LV_FindItemByPidl(This, pidl); | 
|---|
| 1776 |  | 
|---|
| 1777 | if (i != -1) | 
|---|
| 1778 | { | 
|---|
| 1779 | LVITEMA lvItem; | 
|---|
| 1780 |  | 
|---|
| 1781 | if(uFlags & SVSI_ENSUREVISIBLE) | 
|---|
| 1782 | ListView_EnsureVisible(This->hWndList, i, 0); | 
|---|
| 1783 |  | 
|---|
| 1784 | ZeroMemory(&lvItem, sizeof(LVITEMA)); | 
|---|
| 1785 | lvItem.mask = LVIF_STATE; | 
|---|
| 1786 | lvItem.iItem = 0; | 
|---|
| 1787 |  | 
|---|
| 1788 | while(ListView_GetItemA(This->hWndList, &lvItem)) | 
|---|
| 1789 | { | 
|---|
| 1790 | if (lvItem.iItem == i) | 
|---|
| 1791 | { | 
|---|
| 1792 | if (uFlags & SVSI_SELECT) | 
|---|
| 1793 | lvItem.state |= LVIS_SELECTED; | 
|---|
| 1794 | else | 
|---|
| 1795 | lvItem.state &= ~LVIS_SELECTED; | 
|---|
| 1796 |  | 
|---|
| 1797 | if(uFlags & SVSI_FOCUSED) | 
|---|
| 1798 | lvItem.state &= ~LVIS_FOCUSED; | 
|---|
| 1799 | } | 
|---|
| 1800 | else | 
|---|
| 1801 | { | 
|---|
| 1802 | if (uFlags & SVSI_DESELECTOTHERS) | 
|---|
| 1803 | lvItem.state &= ~LVIS_SELECTED; | 
|---|
| 1804 | } | 
|---|
| 1805 | ListView_SetItemA(This->hWndList, &lvItem); | 
|---|
| 1806 | lvItem.iItem++; | 
|---|
| 1807 | } | 
|---|
| 1808 |  | 
|---|
| 1809 |  | 
|---|
| 1810 | if(uFlags & SVSI_EDIT) | 
|---|
| 1811 | ListView_EditLabelA(This->hWndList, i); | 
|---|
| 1812 |  | 
|---|
| 1813 | } | 
|---|
| 1814 | return S_OK; | 
|---|
| 1815 | } | 
|---|
| 1816 |  | 
|---|
| 1817 | static HRESULT WINAPI IShellView_fnGetItemObject(IShellView * iface, UINT uItem, REFIID riid, LPVOID *ppvOut) | 
|---|
| 1818 | { | 
|---|
| 1819 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1820 |  | 
|---|
| 1821 | TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n",This, uItem, debugstr_guid(riid), ppvOut); | 
|---|
| 1822 |  | 
|---|
| 1823 | *ppvOut = NULL; | 
|---|
| 1824 |  | 
|---|
| 1825 | switch(uItem) | 
|---|
| 1826 | { | 
|---|
| 1827 | case SVGIO_BACKGROUND: | 
|---|
| 1828 | *ppvOut = ISvBgCm_Constructor(This->pSFParent); | 
|---|
| 1829 | break; | 
|---|
| 1830 |  | 
|---|
| 1831 | case SVGIO_SELECTION: | 
|---|
| 1832 | ShellView_GetSelections(This); | 
|---|
| 1833 | IShellFolder_GetUIObjectOf(This->pSFParent, This->hWnd, This->cidl, This->apidl, riid, 0, ppvOut); | 
|---|
| 1834 | break; | 
|---|
| 1835 | } | 
|---|
| 1836 | TRACE("-- (%p)->(interface=%p)\n",This, *ppvOut); | 
|---|
| 1837 |  | 
|---|
| 1838 | if(!*ppvOut) return E_OUTOFMEMORY; | 
|---|
| 1839 |  | 
|---|
| 1840 | return S_OK; | 
|---|
| 1841 | } | 
|---|
| 1842 |  | 
|---|
| 1843 | static HRESULT WINAPI IShellView_fnEditItem( | 
|---|
| 1844 | IShellView * iface, | 
|---|
| 1845 | LPITEMIDLIST pidl) | 
|---|
| 1846 | { | 
|---|
| 1847 | ICOM_THIS(IShellViewImpl, iface); | 
|---|
| 1848 | int i; | 
|---|
| 1849 |  | 
|---|
| 1850 | TRACE("(%p)->(pidl=%p)\n",This, pidl); | 
|---|
| 1851 |  | 
|---|
| 1852 | i = LV_FindItemByPidl(This, pidl); | 
|---|
| 1853 | if (i != -1) | 
|---|
| 1854 | { | 
|---|
| 1855 | SetFocus(This->hWndList); | 
|---|
| 1856 | ListView_EditLabelA(This->hWndList, i); | 
|---|
| 1857 | } | 
|---|
| 1858 | return S_OK; | 
|---|
| 1859 | } | 
|---|
| 1860 |  | 
|---|
| 1861 | static struct ICOM_VTABLE(IShellView) svvt = | 
|---|
| 1862 | { | 
|---|
| 1863 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE | 
|---|
| 1864 | IShellView_fnQueryInterface, | 
|---|
| 1865 | IShellView_fnAddRef, | 
|---|
| 1866 | IShellView_fnRelease, | 
|---|
| 1867 | IShellView_fnGetWindow, | 
|---|
| 1868 | IShellView_fnContextSensitiveHelp, | 
|---|
| 1869 | IShellView_fnTranslateAccelerator, | 
|---|
| 1870 | IShellView_fnEnableModeless, | 
|---|
| 1871 | IShellView_fnUIActivate, | 
|---|
| 1872 | IShellView_fnRefresh, | 
|---|
| 1873 | IShellView_fnCreateViewWindow, | 
|---|
| 1874 | IShellView_fnDestroyViewWindow, | 
|---|
| 1875 | IShellView_fnGetCurrentInfo, | 
|---|
| 1876 | IShellView_fnAddPropertySheetPages, | 
|---|
| 1877 | IShellView_fnSaveViewState, | 
|---|
| 1878 | IShellView_fnSelectItem, | 
|---|
| 1879 | IShellView_fnGetItemObject, | 
|---|
| 1880 | IShellView_fnEditItem | 
|---|
| 1881 | }; | 
|---|
| 1882 |  | 
|---|
| 1883 |  | 
|---|
| 1884 | /********************************************************** | 
|---|
| 1885 | * ISVOleCmdTarget_QueryInterface (IUnknown) | 
|---|
| 1886 | */ | 
|---|
| 1887 | static HRESULT WINAPI ISVOleCmdTarget_QueryInterface( | 
|---|
| 1888 | IOleCommandTarget *     iface, | 
|---|
| 1889 | REFIID                  iid, | 
|---|
| 1890 | LPVOID*                 ppvObj) | 
|---|
| 1891 | { | 
|---|
| 1892 | _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface); | 
|---|
| 1893 |  | 
|---|
| 1894 | return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj); | 
|---|
| 1895 | } | 
|---|
| 1896 |  | 
|---|
| 1897 | /********************************************************** | 
|---|
| 1898 | * ISVOleCmdTarget_AddRef (IUnknown) | 
|---|
| 1899 | */ | 
|---|
| 1900 | static ULONG WINAPI ISVOleCmdTarget_AddRef( | 
|---|
| 1901 | IOleCommandTarget *     iface) | 
|---|
| 1902 | { | 
|---|
| 1903 | _ICOM_THIS_From_IOleCommandTarget(IShellFolder, iface); | 
|---|
| 1904 |  | 
|---|
| 1905 | return IShellFolder_AddRef((IShellFolder*)This); | 
|---|
| 1906 | } | 
|---|
| 1907 |  | 
|---|
| 1908 | /********************************************************** | 
|---|
| 1909 | * ISVOleCmdTarget_Release (IUnknown) | 
|---|
| 1910 | */ | 
|---|
| 1911 | static ULONG WINAPI ISVOleCmdTarget_Release( | 
|---|
| 1912 | IOleCommandTarget *     iface) | 
|---|
| 1913 | { | 
|---|
| 1914 | _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface); | 
|---|
| 1915 |  | 
|---|
| 1916 | return IShellFolder_Release((IShellFolder*)This); | 
|---|
| 1917 | } | 
|---|
| 1918 |  | 
|---|
| 1919 | /********************************************************** | 
|---|
| 1920 | * ISVOleCmdTarget_QueryStatus (IOleCommandTarget) | 
|---|
| 1921 | */ | 
|---|
| 1922 | static HRESULT WINAPI ISVOleCmdTarget_QueryStatus( | 
|---|
| 1923 | IOleCommandTarget *iface, | 
|---|
| 1924 | const GUID* pguidCmdGroup, | 
|---|
| 1925 | ULONG cCmds, | 
|---|
| 1926 | OLECMD * prgCmds, | 
|---|
| 1927 | OLECMDTEXT* pCmdText) | 
|---|
| 1928 | { | 
|---|
| 1929 | _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface); | 
|---|
| 1930 |  | 
|---|
| 1931 | FIXME("(%p)->(%p(%s) 0x%08lx %p %p\n", | 
|---|
| 1932 | This, pguidCmdGroup, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText); | 
|---|
| 1933 | return E_NOTIMPL; | 
|---|
| 1934 | } | 
|---|
| 1935 |  | 
|---|
| 1936 | /********************************************************** | 
|---|
| 1937 | * ISVOleCmdTarget_Exec (IOleCommandTarget) | 
|---|
| 1938 | * | 
|---|
| 1939 | * nCmdID is the OLECMDID_* enumeration | 
|---|
| 1940 | */ | 
|---|
| 1941 | static HRESULT WINAPI ISVOleCmdTarget_Exec( | 
|---|
| 1942 | IOleCommandTarget *iface, | 
|---|
| 1943 | const GUID* pguidCmdGroup, | 
|---|
| 1944 | DWORD nCmdID, | 
|---|
| 1945 | DWORD nCmdexecopt, | 
|---|
| 1946 | VARIANT* pvaIn, | 
|---|
| 1947 | VARIANT* pvaOut) | 
|---|
| 1948 | { | 
|---|
| 1949 | _ICOM_THIS_From_IOleCommandTarget(IShellViewImpl, iface); | 
|---|
| 1950 |  | 
|---|
| 1951 | FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08lx Opt:0x%08lx %p %p)\n", | 
|---|
| 1952 | This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, pvaIn, pvaOut); | 
|---|
| 1953 | return E_NOTIMPL; | 
|---|
| 1954 | } | 
|---|
| 1955 |  | 
|---|
| 1956 | static ICOM_VTABLE(IOleCommandTarget) ctvt = | 
|---|
| 1957 | { | 
|---|
| 1958 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE | 
|---|
| 1959 | ISVOleCmdTarget_QueryInterface, | 
|---|
| 1960 | ISVOleCmdTarget_AddRef, | 
|---|
| 1961 | ISVOleCmdTarget_Release, | 
|---|
| 1962 | ISVOleCmdTarget_QueryStatus, | 
|---|
| 1963 | ISVOleCmdTarget_Exec | 
|---|
| 1964 | }; | 
|---|
| 1965 |  | 
|---|
| 1966 | /********************************************************** | 
|---|
| 1967 | * ISVDropTarget implementation | 
|---|
| 1968 | */ | 
|---|
| 1969 |  | 
|---|
| 1970 | static HRESULT WINAPI ISVDropTarget_QueryInterface( | 
|---|
| 1971 | IDropTarget *iface, | 
|---|
| 1972 | REFIID riid, | 
|---|
| 1973 | LPVOID *ppvObj) | 
|---|
| 1974 | { | 
|---|
| 1975 | _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface); | 
|---|
| 1976 |  | 
|---|
| 1977 | TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); | 
|---|
| 1978 |  | 
|---|
| 1979 | return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj); | 
|---|
| 1980 | } | 
|---|
| 1981 |  | 
|---|
| 1982 | static ULONG WINAPI ISVDropTarget_AddRef( IDropTarget *iface) | 
|---|
| 1983 | { | 
|---|
| 1984 | _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface); | 
|---|
| 1985 |  | 
|---|
| 1986 | TRACE("(%p)->(count=%lu)\n",This,This->ref); | 
|---|
| 1987 |  | 
|---|
| 1988 | return IShellFolder_AddRef((IShellFolder*)This); | 
|---|
| 1989 | } | 
|---|
| 1990 |  | 
|---|
| 1991 | static ULONG WINAPI ISVDropTarget_Release( IDropTarget *iface) | 
|---|
| 1992 | { | 
|---|
| 1993 | _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface); | 
|---|
| 1994 |  | 
|---|
| 1995 | TRACE("(%p)->(count=%lu)\n",This,This->ref); | 
|---|
| 1996 |  | 
|---|
| 1997 | return IShellFolder_Release((IShellFolder*)This); | 
|---|
| 1998 | } | 
|---|
| 1999 |  | 
|---|
| 2000 | static HRESULT WINAPI ISVDropTarget_DragEnter( | 
|---|
| 2001 | IDropTarget     *iface, | 
|---|
| 2002 | IDataObject     *pDataObject, | 
|---|
| 2003 | DWORD           grfKeyState, | 
|---|
| 2004 | POINTL          pt, | 
|---|
| 2005 | DWORD           *pdwEffect) | 
|---|
| 2006 | { | 
|---|
| 2007 |  | 
|---|
| 2008 | _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface); | 
|---|
| 2009 |  | 
|---|
| 2010 | FIXME("Stub: This=%p, DataObject=%p\n",This,pDataObject); | 
|---|
| 2011 |  | 
|---|
| 2012 | return E_NOTIMPL; | 
|---|
| 2013 | } | 
|---|
| 2014 |  | 
|---|
| 2015 | static HRESULT WINAPI ISVDropTarget_DragOver( | 
|---|
| 2016 | IDropTarget     *iface, | 
|---|
| 2017 | DWORD           grfKeyState, | 
|---|
| 2018 | POINTL          pt, | 
|---|
| 2019 | DWORD           *pdwEffect) | 
|---|
| 2020 | { | 
|---|
| 2021 | _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface); | 
|---|
| 2022 |  | 
|---|
| 2023 | FIXME("Stub: This=%p\n",This); | 
|---|
| 2024 |  | 
|---|
| 2025 | return E_NOTIMPL; | 
|---|
| 2026 | } | 
|---|
| 2027 |  | 
|---|
| 2028 | static HRESULT WINAPI ISVDropTarget_DragLeave( | 
|---|
| 2029 | IDropTarget     *iface) | 
|---|
| 2030 | { | 
|---|
| 2031 | _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface); | 
|---|
| 2032 |  | 
|---|
| 2033 | FIXME("Stub: This=%p\n",This); | 
|---|
| 2034 |  | 
|---|
| 2035 | return E_NOTIMPL; | 
|---|
| 2036 | } | 
|---|
| 2037 |  | 
|---|
| 2038 | static HRESULT WINAPI ISVDropTarget_Drop( | 
|---|
| 2039 | IDropTarget     *iface, | 
|---|
| 2040 | IDataObject*    pDataObject, | 
|---|
| 2041 | DWORD           grfKeyState, | 
|---|
| 2042 | POINTL          pt, | 
|---|
| 2043 | DWORD           *pdwEffect) | 
|---|
| 2044 | { | 
|---|
| 2045 | _ICOM_THIS_From_IDropTarget(IShellViewImpl, iface); | 
|---|
| 2046 |  | 
|---|
| 2047 | FIXME("Stub: This=%p\n",This); | 
|---|
| 2048 |  | 
|---|
| 2049 | return E_NOTIMPL; | 
|---|
| 2050 | } | 
|---|
| 2051 |  | 
|---|
| 2052 | static struct ICOM_VTABLE(IDropTarget) dtvt = | 
|---|
| 2053 | { | 
|---|
| 2054 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE | 
|---|
| 2055 | ISVDropTarget_QueryInterface, | 
|---|
| 2056 | ISVDropTarget_AddRef, | 
|---|
| 2057 | ISVDropTarget_Release, | 
|---|
| 2058 | ISVDropTarget_DragEnter, | 
|---|
| 2059 | ISVDropTarget_DragOver, | 
|---|
| 2060 | ISVDropTarget_DragLeave, | 
|---|
| 2061 | ISVDropTarget_Drop | 
|---|
| 2062 | }; | 
|---|
| 2063 |  | 
|---|
| 2064 | /********************************************************** | 
|---|
| 2065 | * ISVDropSource implementation | 
|---|
| 2066 | */ | 
|---|
| 2067 |  | 
|---|
| 2068 | static HRESULT WINAPI ISVDropSource_QueryInterface( | 
|---|
| 2069 | IDropSource *iface, | 
|---|
| 2070 | REFIID riid, | 
|---|
| 2071 | LPVOID *ppvObj) | 
|---|
| 2072 | { | 
|---|
| 2073 | _ICOM_THIS_From_IDropSource(IShellViewImpl, iface); | 
|---|
| 2074 |  | 
|---|
| 2075 | TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); | 
|---|
| 2076 |  | 
|---|
| 2077 | return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj); | 
|---|
| 2078 | } | 
|---|
| 2079 |  | 
|---|
| 2080 | static ULONG WINAPI ISVDropSource_AddRef( IDropSource *iface) | 
|---|
| 2081 | { | 
|---|
| 2082 | _ICOM_THIS_From_IDropSource(IShellViewImpl, iface); | 
|---|
| 2083 |  | 
|---|
| 2084 | TRACE("(%p)->(count=%lu)\n",This,This->ref); | 
|---|
| 2085 |  | 
|---|
| 2086 | return IShellFolder_AddRef((IShellFolder*)This); | 
|---|
| 2087 | } | 
|---|
| 2088 |  | 
|---|
| 2089 | static ULONG WINAPI ISVDropSource_Release( IDropSource *iface) | 
|---|
| 2090 | { | 
|---|
| 2091 | _ICOM_THIS_From_IDropSource(IShellViewImpl, iface); | 
|---|
| 2092 |  | 
|---|
| 2093 | TRACE("(%p)->(count=%lu)\n",This,This->ref); | 
|---|
| 2094 |  | 
|---|
| 2095 | return IShellFolder_Release((IShellFolder*)This); | 
|---|
| 2096 | } | 
|---|
| 2097 | static HRESULT WINAPI ISVDropSource_QueryContinueDrag( | 
|---|
| 2098 | IDropSource *iface, | 
|---|
| 2099 | BOOL fEscapePressed, | 
|---|
| 2100 | DWORD grfKeyState) | 
|---|
| 2101 | { | 
|---|
| 2102 | _ICOM_THIS_From_IDropSource(IShellViewImpl, iface); | 
|---|
| 2103 | TRACE("(%p)\n",This); | 
|---|
| 2104 |  | 
|---|
| 2105 | if (fEscapePressed) | 
|---|
| 2106 | return DRAGDROP_S_CANCEL; | 
|---|
| 2107 | else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON)) | 
|---|
| 2108 | return DRAGDROP_S_DROP; | 
|---|
| 2109 | else | 
|---|
| 2110 | return NOERROR; | 
|---|
| 2111 | } | 
|---|
| 2112 |  | 
|---|
| 2113 | static HRESULT WINAPI ISVDropSource_GiveFeedback( | 
|---|
| 2114 | IDropSource *iface, | 
|---|
| 2115 | DWORD dwEffect) | 
|---|
| 2116 | { | 
|---|
| 2117 | _ICOM_THIS_From_IDropSource(IShellViewImpl, iface); | 
|---|
| 2118 | TRACE("(%p)\n",This); | 
|---|
| 2119 |  | 
|---|
| 2120 | return DRAGDROP_S_USEDEFAULTCURSORS; | 
|---|
| 2121 | } | 
|---|
| 2122 |  | 
|---|
| 2123 | static struct ICOM_VTABLE(IDropSource) dsvt = | 
|---|
| 2124 | { | 
|---|
| 2125 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE | 
|---|
| 2126 | ISVDropSource_QueryInterface, | 
|---|
| 2127 | ISVDropSource_AddRef, | 
|---|
| 2128 | ISVDropSource_Release, | 
|---|
| 2129 | ISVDropSource_QueryContinueDrag, | 
|---|
| 2130 | ISVDropSource_GiveFeedback | 
|---|
| 2131 | }; | 
|---|
| 2132 | /********************************************************** | 
|---|
| 2133 | * ISVViewObject implementation | 
|---|
| 2134 | */ | 
|---|
| 2135 |  | 
|---|
| 2136 | static HRESULT WINAPI ISVViewObject_QueryInterface( | 
|---|
| 2137 | IViewObject *iface, | 
|---|
| 2138 | REFIID riid, | 
|---|
| 2139 | LPVOID *ppvObj) | 
|---|
| 2140 | { | 
|---|
| 2141 | _ICOM_THIS_From_IViewObject(IShellViewImpl, iface); | 
|---|
| 2142 |  | 
|---|
| 2143 | TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj); | 
|---|
| 2144 |  | 
|---|
| 2145 | return IShellFolder_QueryInterface((IShellFolder*)This, riid, ppvObj); | 
|---|
| 2146 | } | 
|---|
| 2147 |  | 
|---|
| 2148 | static ULONG WINAPI ISVViewObject_AddRef( IViewObject *iface) | 
|---|
| 2149 | { | 
|---|
| 2150 | _ICOM_THIS_From_IViewObject(IShellViewImpl, iface); | 
|---|
| 2151 |  | 
|---|
| 2152 | TRACE("(%p)->(count=%lu)\n",This,This->ref); | 
|---|
| 2153 |  | 
|---|
| 2154 | return IShellFolder_AddRef((IShellFolder*)This); | 
|---|
| 2155 | } | 
|---|
| 2156 |  | 
|---|
| 2157 | static ULONG WINAPI ISVViewObject_Release( IViewObject *iface) | 
|---|
| 2158 | { | 
|---|
| 2159 | _ICOM_THIS_From_IViewObject(IShellViewImpl, iface); | 
|---|
| 2160 |  | 
|---|
| 2161 | TRACE("(%p)->(count=%lu)\n",This,This->ref); | 
|---|
| 2162 |  | 
|---|
| 2163 | return IShellFolder_Release((IShellFolder*)This); | 
|---|
| 2164 | } | 
|---|
| 2165 |  | 
|---|
| 2166 | static HRESULT WINAPI ISVViewObject_Draw( | 
|---|
| 2167 | IViewObject     *iface, | 
|---|
| 2168 | DWORD dwDrawAspect, | 
|---|
| 2169 | LONG lindex, | 
|---|
| 2170 | void* pvAspect, | 
|---|
| 2171 | DVTARGETDEVICE* ptd, | 
|---|
| 2172 | HDC hdcTargetDev, | 
|---|
| 2173 | HDC hdcDraw, | 
|---|
| 2174 | LPCRECTL lprcBounds, | 
|---|
| 2175 | LPCRECTL lprcWBounds, | 
|---|
| 2176 | IVO_ContCallback pfnContinue, | 
|---|
| 2177 | DWORD dwContinue) | 
|---|
| 2178 | { | 
|---|
| 2179 |  | 
|---|
| 2180 | _ICOM_THIS_From_IViewObject(IShellViewImpl, iface); | 
|---|
| 2181 |  | 
|---|
| 2182 | FIXME("Stub: This=%p\n",This); | 
|---|
| 2183 |  | 
|---|
| 2184 | return E_NOTIMPL; | 
|---|
| 2185 | } | 
|---|
| 2186 | static HRESULT WINAPI ISVViewObject_GetColorSet( | 
|---|
| 2187 | IViewObject     *iface, | 
|---|
| 2188 | DWORD dwDrawAspect, | 
|---|
| 2189 | LONG lindex, | 
|---|
| 2190 | void *pvAspect, | 
|---|
| 2191 | DVTARGETDEVICE* ptd, | 
|---|
| 2192 | HDC hicTargetDevice, | 
|---|
| 2193 | LOGPALETTE** ppColorSet) | 
|---|
| 2194 | { | 
|---|
| 2195 |  | 
|---|
| 2196 | _ICOM_THIS_From_IViewObject(IShellViewImpl, iface); | 
|---|
| 2197 |  | 
|---|
| 2198 | FIXME("Stub: This=%p\n",This); | 
|---|
| 2199 |  | 
|---|
| 2200 | return E_NOTIMPL; | 
|---|
| 2201 | } | 
|---|
| 2202 | static HRESULT WINAPI ISVViewObject_Freeze( | 
|---|
| 2203 | IViewObject     *iface, | 
|---|
| 2204 | DWORD dwDrawAspect, | 
|---|
| 2205 | LONG lindex, | 
|---|
| 2206 | void* pvAspect, | 
|---|
| 2207 | DWORD* pdwFreeze) | 
|---|
| 2208 | { | 
|---|
| 2209 |  | 
|---|
| 2210 | _ICOM_THIS_From_IViewObject(IShellViewImpl, iface); | 
|---|
| 2211 |  | 
|---|
| 2212 | FIXME("Stub: This=%p\n",This); | 
|---|
| 2213 |  | 
|---|
| 2214 | return E_NOTIMPL; | 
|---|
| 2215 | } | 
|---|
| 2216 | static HRESULT WINAPI ISVViewObject_Unfreeze( | 
|---|
| 2217 | IViewObject     *iface, | 
|---|
| 2218 | DWORD dwFreeze) | 
|---|
| 2219 | { | 
|---|
| 2220 |  | 
|---|
| 2221 | _ICOM_THIS_From_IViewObject(IShellViewImpl, iface); | 
|---|
| 2222 |  | 
|---|
| 2223 | FIXME("Stub: This=%p\n",This); | 
|---|
| 2224 |  | 
|---|
| 2225 | return E_NOTIMPL; | 
|---|
| 2226 | } | 
|---|
| 2227 | static HRESULT WINAPI ISVViewObject_SetAdvise( | 
|---|
| 2228 | IViewObject     *iface, | 
|---|
| 2229 | DWORD aspects, | 
|---|
| 2230 | DWORD advf, | 
|---|
| 2231 | IAdviseSink* pAdvSink) | 
|---|
| 2232 | { | 
|---|
| 2233 |  | 
|---|
| 2234 | _ICOM_THIS_From_IViewObject(IShellViewImpl, iface); | 
|---|
| 2235 |  | 
|---|
| 2236 | FIXME("Stub: This=%p\n",This); | 
|---|
| 2237 |  | 
|---|
| 2238 | return E_NOTIMPL; | 
|---|
| 2239 | } | 
|---|
| 2240 | static HRESULT WINAPI ISVViewObject_GetAdvise( | 
|---|
| 2241 | IViewObject     *iface, | 
|---|
| 2242 | DWORD* pAspects, | 
|---|
| 2243 | DWORD* pAdvf, | 
|---|
| 2244 | IAdviseSink** ppAdvSink) | 
|---|
| 2245 | { | 
|---|
| 2246 |  | 
|---|
| 2247 | _ICOM_THIS_From_IViewObject(IShellViewImpl, iface); | 
|---|
| 2248 |  | 
|---|
| 2249 | FIXME("Stub: This=%p\n",This); | 
|---|
| 2250 |  | 
|---|
| 2251 | return E_NOTIMPL; | 
|---|
| 2252 | } | 
|---|
| 2253 |  | 
|---|
| 2254 |  | 
|---|
| 2255 | static struct ICOM_VTABLE(IViewObject) vovt = | 
|---|
| 2256 | { | 
|---|
| 2257 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE | 
|---|
| 2258 | ISVViewObject_QueryInterface, | 
|---|
| 2259 | ISVViewObject_AddRef, | 
|---|
| 2260 | ISVViewObject_Release, | 
|---|
| 2261 | ISVViewObject_Draw, | 
|---|
| 2262 | ISVViewObject_GetColorSet, | 
|---|
| 2263 | ISVViewObject_Freeze, | 
|---|
| 2264 | ISVViewObject_Unfreeze, | 
|---|
| 2265 | ISVViewObject_SetAdvise, | 
|---|
| 2266 | ISVViewObject_GetAdvise | 
|---|
| 2267 | }; | 
|---|
| 2268 |  | 
|---|