ReactOS  0.4.15-dev-425-gc40b086
CDefView.cpp
Go to the documentation of this file.
1 /*
2  * ShellView
3  *
4  * Copyright 1998,1999 <juergen.schmied@debitel.net>
5  *
6  * This is the view visualizing the data provided by the shellfolder.
7  * No direct access to data from pidls should be done from here.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  *
23  * FIXME: CheckToolbar: handle the "new folder" and "folder up" button
24  */
25 
26 /*
27 TODO:
28 - Load/Save the view state from/into the stream provided by the ShellBrowser.
29 - When editing starts on item, set edit text to for editing value.
30 - Fix shell view to handle view mode popup exec.
31 - The background context menu should have a pidl just like foreground menus. This
32  causes crashes when dynamic handlers try to use the NULL pidl.
33 - Reorder of columns doesn't work - might be bug in comctl32
34 */
35 
36 #include "precomp.h"
37 
38 #include <atlwin.h>
39 #include <rosctrls.h>
40 
42 
43 #undef SV_CLASS_NAME
44 
45 static const WCHAR SV_CLASS_NAME[] = {'S', 'H', 'E', 'L', 'L', 'D', 'L', 'L', '_', 'D', 'e', 'f', 'V', 'i', 'e', 'w', 0};
46 
47 typedef struct
48 {
53 
54 #define SHV_CHANGE_NOTIFY WM_USER + 0x1111
55 
56 /* For the context menu of the def view, the id of the items are based on 1 because we need
57  to call TrackPopupMenu and let it use the 0 value as an indication that the menu was canceled */
58 #define CONTEXT_MENU_BASE_ID 1
59 
60 class CDefView :
61  public CWindowImpl<CDefView, CWindow, CControlWinTraits>,
62  public CComObjectRootEx<CComMultiThreadModelNoCS>,
63  public IShellView2,
64  public IFolderView,
65  public IShellFolderView,
66  public IOleCommandTarget,
67  public IDropTarget,
68  public IDropSource,
69  public IViewObject,
70  public IServiceProvider
71 {
72  private:
82  HMENU m_hMenu; /* Handle to the menu bar of the browser */
83  HMENU m_hMenuArrangeModes; /* Handle to the popup menu with the arrange modes */
84  HMENU m_hMenuViewModes; /* Handle to the popup menu with the view modes */
85  HMENU m_hContextMenu; /* Handle to the open context menu */
92  ULONG m_hNotify; /* Change notification handle */
93  HACCEL m_hAccel;
97  // for drag and drop
99  CComPtr<IDropTarget> m_pCurDropTarget; /* The sub-item, which is currently dragged over */
100  CComPtr<IDataObject> m_pCurDataObject; /* The dragged data-object */
101  LONG m_iDragOverItem; /* Dragged over item's index, iff m_pCurDropTarget != NULL */
102  UINT m_cScrollDelay; /* Send a WM_*SCROLL msg every 250 ms during drag-scroll */
103  POINT m_ptLastMousePos; /* Mouse position at last DragOver call */
104  POINT m_ptFirstMousePos; /* Mouse position when the drag operation started */
106  //
108 
110 
114 
115  private:
117  BOOL _Sort();
120 
121  public:
122  CDefView();
123  ~CDefView();
124  HRESULT WINAPI Initialize(IShellFolder *shellFolder);
128  void UpdateStatusbar();
129  void CheckToolbar();
130  BOOL CreateList();
131  void UpdateListColors();
132  BOOL InitList();
134  static INT CALLBACK ListViewCompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData);
135 
139  int LV_AddItem(PCUITEMID_CHILD pidl);
144  HRESULT FillList();
148  HRESULT FillArrangeAsMenu(HMENU hmenuArrange);
149  HRESULT CheckViewMode(HMENU hmenuView);
152  void OnDeactivate();
153  void DoActivate(UINT uState);
154  HRESULT drag_notify_subitem(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
156  LRESULT OnExplorerCommand(UINT uCommand, BOOL bUseSelection);
157 
158  // *** IOleWindow methods ***
159  virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *lphwnd);
161 
162  // *** IShellView methods ***
164  virtual HRESULT STDMETHODCALLTYPE EnableModeless(BOOL fEnable);
165  virtual HRESULT STDMETHODCALLTYPE UIActivate(UINT uState);
167  virtual HRESULT STDMETHODCALLTYPE CreateViewWindow(IShellView *psvPrevious, LPCFOLDERSETTINGS pfs, IShellBrowser *psb, RECT *prcView, HWND *phWnd);
173  virtual HRESULT STDMETHODCALLTYPE GetItemObject(UINT uItem, REFIID riid, void **ppv);
174 
175  // *** IShellView2 methods ***
180 
181  // *** IShellView3 methods ***
182  virtual HRESULT STDMETHODCALLTYPE CreateViewWindow3(IShellBrowser *psb, IShellView *psvPrevious, SV3CVW3_FLAGS view_flags, FOLDERFLAGS mask, FOLDERFLAGS flags, FOLDERVIEWMODE mode, const SHELLVIEWID *view_id, RECT *prcView, HWND *hwnd);
183 
184  // *** IFolderView methods ***
185  virtual HRESULT STDMETHODCALLTYPE GetCurrentViewMode(UINT *pViewMode);
188  virtual HRESULT STDMETHODCALLTYPE Item(int iItemIndex, PITEMID_CHILD *ppidl);
191  virtual HRESULT STDMETHODCALLTYPE GetSelectionMarkedItem(int *piItem);
192  virtual HRESULT STDMETHODCALLTYPE GetFocusedItem(int *piItem);
197  virtual HRESULT STDMETHODCALLTYPE SelectItem(int iItem, DWORD dwFlags);
199 
200  // *** IShellFolderView methods ***
215  virtual HRESULT STDMETHODCALLTYPE IsDropOnSource(IDropTarget *drop_target);
220  virtual HRESULT STDMETHODCALLTYPE IsBkDropTarget(IDropTarget *drop_target);
224  virtual HRESULT STDMETHODCALLTYPE SetCallback(IShellFolderViewCB *new_cb, IShellFolderViewCB **old_cb);
226  virtual HRESULT STDMETHODCALLTYPE QuerySupport(UINT *support);
228 
229  // *** IOleCommandTarget methods ***
230  virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT *pCmdText);
231  virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut);
232 
233  // *** IDropTarget methods ***
234  virtual HRESULT STDMETHODCALLTYPE DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
235  virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
237  virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
238 
239  // *** IDropSource methods ***
240  virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState);
241  virtual HRESULT STDMETHODCALLTYPE GiveFeedback(DWORD dwEffect);
242 
243  // *** IViewObject methods ***
244  virtual HRESULT STDMETHODCALLTYPE Draw(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd,
245  HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds,
246  BOOL ( STDMETHODCALLTYPE *pfnContinue )(ULONG_PTR dwContinue), ULONG_PTR dwContinue);
247  virtual HRESULT STDMETHODCALLTYPE GetColorSet(DWORD dwDrawAspect, LONG lindex, void *pvAspect,
248  DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet);
249  virtual HRESULT STDMETHODCALLTYPE Freeze(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze);
250  virtual HRESULT STDMETHODCALLTYPE Unfreeze(DWORD dwFreeze);
251  virtual HRESULT STDMETHODCALLTYPE SetAdvise(DWORD aspects, DWORD advf, IAdviseSink *pAdvSink);
252  virtual HRESULT STDMETHODCALLTYPE GetAdvise(DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink);
253 
254  // *** IServiceProvider methods ***
255  virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject);
256 
257  // Message handlers
258  LRESULT OnShowWindow(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
259  LRESULT OnGetDlgCode(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
260  LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
265  LRESULT OnNCCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
266  LRESULT OnNCDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
267  LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
269  LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
270  LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
271  LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
272  LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
273  LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
274  LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
276  LRESULT OnCustomItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
279 
281  {
282  static ATL::CWndClassInfo wc =
283  {
285  0, 0, NULL, NULL,
287  },
288  NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
289  };
290  return wc;
291  }
292 
294  {
295  return WindowProc;
296  }
297 
299  {
300  CDefView *pThis;
301  LRESULT result;
302 
303  // Must hold a reference during message handling
304  pThis = reinterpret_cast<CDefView *>(hWnd);
305  pThis->AddRef();
307  pThis->Release();
308  return result;
309  }
310 
334  END_MSG_MAP()
335 
337  // Windows returns E_NOINTERFACE for IOleWindow
338  // COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IOleWindow)
339  COM_INTERFACE_ENTRY_IID(IID_IShellView, IShellView)
340  COM_INTERFACE_ENTRY_IID(IID_CDefView, IShellView)
341  COM_INTERFACE_ENTRY_IID(IID_IShellView2, IShellView2)
342  COM_INTERFACE_ENTRY_IID(IID_IFolderView, IFolderView)
343  COM_INTERFACE_ENTRY_IID(IID_IShellFolderView, IShellFolderView)
344  COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
345  COM_INTERFACE_ENTRY_IID(IID_IDropTarget, IDropTarget)
346  COM_INTERFACE_ENTRY_IID(IID_IDropSource, IDropSource)
348  COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
349  END_COM_MAP()
350 };
351 
352 /*menu items */
353 #define IDM_VIEW_FILES (FCIDM_SHVIEWFIRST + 0x500)
354 #define IDM_VIEW_IDW (FCIDM_SHVIEWFIRST + 0x501)
355 #define IDM_MYFILEITEM (FCIDM_SHVIEWFIRST + 0x502)
356 
357 #define ID_LISTVIEW 1
358 
359 /*windowsx.h */
360 #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
361 #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
362 #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
363 
365 
367  m_ListView(),
369  m_hMenu(NULL),
374  m_uState(0),
375  m_cidl(0),
376  m_apidl(NULL),
378  m_hNotify(0),
379  m_hAccel(NULL),
380  m_dwAspects(0),
381  m_dwAdvf(0),
382  m_iDragOverItem(0),
383  m_cScrollDelay(0),
386 {
388  ZeroMemory(&m_sortInfo, sizeof(m_sortInfo));
390  ZeroMemory(&m_Category, sizeof(m_Category));
394 }
395 
397 {
398  TRACE(" destroying IShellView(%p)\n", this);
399 
401  {
404  }
405 
406  if (m_hWnd)
407  {
409  }
410 
411  SHFree(m_apidl);
412 }
413 
415 {
416  m_pSFParent = shellFolder;
418 
419  return S_OK;
420 }
421 
422 /**********************************************************
423  *
424  * ##### helperfunctions for communication with ICommDlgBrowser #####
425  */
427 {
428  HRESULT ret = S_OK;
429 
430  if (m_pCommDlgBrowser.p != NULL)
431  {
432  TRACE("ICommDlgBrowser::IncludeObject pidl=%p\n", pidl);
433  ret = m_pCommDlgBrowser->IncludeObject(this, pidl);
434  TRACE("-- returns 0x%08x\n", ret);
435  }
436 
437  return ret;
438 }
439 
441 {
442  HRESULT ret = S_FALSE;
443 
444  if (m_pCommDlgBrowser.p != NULL)
445  {
446  TRACE("ICommDlgBrowser::OnDefaultCommand\n");
447  ret = m_pCommDlgBrowser->OnDefaultCommand(this);
448  TRACE("-- returns 0x%08x\n", ret);
449  }
450 
451  return ret;
452 }
453 
455 {
456  HRESULT ret = S_FALSE;
457 
458  if (m_pCommDlgBrowser.p != NULL)
459  {
460  TRACE("ICommDlgBrowser::OnStateChange flags=%x\n", uFlags);
461  ret = m_pCommDlgBrowser->OnStateChange(this, uFlags);
462  TRACE("--\n");
463  }
464 
465  return ret;
466 }
467 /**********************************************************
468  * set the toolbar of the filedialog buttons
469  *
470  * - activates the buttons from the shellbrowser according to
471  * the view state
472  */
474 {
475  LRESULT result;
476 
477  TRACE("\n");
478 
479  if (m_pCommDlgBrowser != NULL)
480  {
481  m_pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_CHECKBUTTON,
483  m_pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_CHECKBUTTON,
485  m_pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_ENABLEBUTTON,
487  m_pShellBrowser->SendControlMsg(FCW_TOOLBAR, TB_ENABLEBUTTON,
489  }
490 }
491 
493 {
494  WCHAR szFormat[MAX_PATH] = {0};
495  WCHAR szObjects[MAX_PATH] = {0};
496  UINT cSelectedItems;
497 
498  cSelectedItems = m_ListView.GetSelectedCount();
499  if (cSelectedItems)
500  {
502  StringCchPrintfW(szObjects, MAX_PATH, szFormat, cSelectedItems);
503  }
504  else
505  {
506  LoadStringW(shell32_hInstance, IDS_OBJECTS, szFormat, _countof(szFormat));
507  StringCchPrintfW(szObjects, MAX_PATH, szFormat, m_ListView.GetItemCount());
508  }
509  m_pShellBrowser->SetStatusTextSB(szObjects);
510 }
511 
512 /**********************************************************
513  *
514  * ##### helperfunctions for initializing the view #####
515  */
516 
517 /**********************************************************
518 * ShellView_CreateList()
519 *
520 * - creates the list view window
521 */
523 {
524  HRESULT hr;
525  DWORD dwStyle, dwExStyle;
526  UINT ViewMode;
527 
528  TRACE("%p\n", this);
529 
532  dwExStyle = WS_EX_CLIENTEDGE;
533 
535  dwStyle |= LVS_ALIGNLEFT;
536  else
537  dwStyle |= LVS_ALIGNTOP | LVS_SHOWSELALWAYS;
538 
539  ViewMode = m_FolderSettings.ViewMode;
541  if (SUCCEEDED(hr))
542  {
543  if (ViewMode >= FVM_FIRST && ViewMode <= FVM_LAST)
544  m_FolderSettings.ViewMode = ViewMode;
545  else
546  ERR("Ignoring invalid ViewMode from SFVM_DEFVIEWMODE: %u (was: %u)\n", ViewMode, m_FolderSettings.ViewMode);
547  }
548 
549  switch (m_FolderSettings.ViewMode)
550  {
551  case FVM_ICON:
552  dwStyle |= LVS_ICON;
553  break;
554 
555  case FVM_DETAILS:
556  dwStyle |= LVS_REPORT;
557  break;
558 
559  case FVM_SMALLICON:
560  dwStyle |= LVS_SMALLICON;
561  break;
562 
563  case FVM_LIST:
564  dwStyle |= LVS_LIST;
565  break;
566 
567  default:
568  dwStyle |= LVS_LIST;
569  break;
570  }
571 
573  dwStyle |= LVS_AUTOARRANGE;
574 
576  dwExStyle |= LVS_EX_SNAPTOGRID;
577 
580 
582  dwStyle |= LVS_SINGLESEL;
583 
585  dwExStyle &= ~WS_EX_CLIENTEDGE;
586 
587  RECT rcListView = {0,0,0,0};
588  m_ListView.Create(m_hWnd, rcListView, L"FolderView", dwStyle, dwExStyle, ID_LISTVIEW);
589 
590  if (!m_ListView)
591  return FALSE;
592 
594  m_sortInfo.nHeaderID = -1;
596 
597  /* UpdateShellSettings(); */
598  return TRUE;
599 }
600 
602 {
604  {
605  /* Check if drop shadows option is enabled */
606  BOOL bDropShadow = FALSE;
607  DWORD cbDropShadow = sizeof(bDropShadow);
608 
609  /*
610  * The desktop ListView always take the default desktop colours, by
611  * remaining transparent and letting user32/win32k paint itself the
612  * desktop background color, if any.
613  */
615 
616  SHGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
617  L"ListviewShadow", NULL, &bDropShadow, &cbDropShadow);
618  if (bDropShadow)
619  {
620  /* Set the icon background transparent */
622  m_ListView.SetTextColor(RGB(255, 255, 255));
623  m_ListView.SetExtendedListViewStyle(LVS_EX_TRANSPARENTSHADOWTEXT, LVS_EX_TRANSPARENTSHADOWTEXT);
624  }
625  else
626  {
627  /* Set the icon background as the same colour as the desktop */
628  COLORREF crDesktop = GetSysColor(COLOR_DESKTOP);
629  m_ListView.SetTextBkColor(crDesktop);
630  if (GetRValue(crDesktop) + GetGValue(crDesktop) + GetBValue(crDesktop) > 128 * 3)
631  m_ListView.SetTextColor(RGB(0, 0, 0));
632  else
633  m_ListView.SetTextColor(RGB(255, 255, 255));
634  m_ListView.SetExtendedListViewStyle(0, LVS_EX_TRANSPARENTSHADOWTEXT);
635  }
636  }
637  else
638  {
639  // text background color
640  COLORREF clrTextBack = m_viewinfo_data.clrTextBack;
641  m_ListView.SetTextBkColor(clrTextBack);
642 
643  // text color
644  COLORREF clrText;
646  clrText = m_viewinfo_data.clrText;
647  else
648  clrText = GetSysColor(COLOR_WINDOWTEXT);
649 
650  m_ListView.SetTextColor(clrText);
651 
652  // Background is painted by the parent via WM_PRINTCLIENT.
653  m_ListView.SetExtendedListViewStyle(LVS_EX_TRANSPARENTBKGND, LVS_EX_TRANSPARENTBKGND);
654  }
655 }
656 
657 /**********************************************************
658 * ShellView_InitList()
659 *
660 * - adds all needed columns to the shellview
661 */
663 {
665  WCHAR szTemp[50];
666  HIMAGELIST big_icons, small_icons;
667 
668  TRACE("%p\n", this);
669 
671 
673 
674  if (m_pSF2Parent)
675  {
676  for (int i = 0; 1; i++)
677  {
678  if (FAILED(m_pSF2Parent->GetDetailsOf(NULL, i, &sd)))
679  break;
680  StrRetToStrNW( szTemp, 50, &sd.str, NULL);
681  m_ListView.InsertColumn(i, szTemp, sd.fmt, sd.cxChar * 8);
682 
683  InsertMenuW(m_hMenuArrangeModes, -1, MF_STRING, 0x30 + i, szTemp);
684  }
685 
687  }
688  else
689  {
690  FIXME("no m_pSF2Parent\n");
691  }
692 
693  Shell_GetImageLists(&big_icons, &small_icons);
695  m_ListView.SetImageList(small_icons, LVSIL_SMALL);
696 
697  return TRUE;
698 }
699 
700 /*************************************************************************
701  * ShellView_ListViewCompareItems
702  *
703  * Compare Function for the Listview (FileOpen Dialog)
704  *
705  * PARAMS
706  * lParam1 [I] the first ItemIdList to compare with
707  * lParam2 [I] the second ItemIdList to compare with
708  * lpData [I] The column ID for the header Ctrl to process
709  *
710  * RETURNS
711  * A negative value if the first item should precede the second,
712  * a positive value if the first item should follow the second,
713  * or zero if the two items are equivalent
714  */
716 {
717  PCUIDLIST_RELATIVE pidl1 = reinterpret_cast<PCUIDLIST_RELATIVE>(lParam1);
718  PCUIDLIST_RELATIVE pidl2 = reinterpret_cast<PCUIDLIST_RELATIVE>(lParam2);
719  CDefView *pThis = reinterpret_cast<CDefView*>(lpData);
720 
721  HRESULT hres = pThis->m_pSFParent->CompareIDs(pThis->m_sortInfo.nHeaderID, pidl1, pidl2);
723  return 0;
724 
725  SHORT nDiff = HRESULT_CODE(hres);
726  if (!pThis->m_sortInfo.bIsAscending)
727  nDiff = -nDiff;
728  return nDiff;
729 }
730 
732 {
733  HWND hHeader;
734  HDITEM hColumn;
735 
736  if (m_ListView.GetWindowLongPtr(GWL_STYLE) & LVS_NOSORTHEADER)
737  return TRUE;
738 
739  hHeader = (HWND)m_ListView.SendMessage(LVM_GETHEADER, 0, 0);
740  ZeroMemory(&hColumn, sizeof(hColumn));
741 
742  /* If the sorting column changed, remove the sorting style from the old column */
743  if ( (m_sortInfo.nLastHeaderID != -1) &&
745  {
746  hColumn.mask = HDI_FORMAT;
747  Header_GetItem(hHeader, m_sortInfo.nLastHeaderID, &hColumn);
748  hColumn.fmt &= ~(HDF_SORTUP | HDF_SORTDOWN);
749  Header_SetItem(hHeader, m_sortInfo.nLastHeaderID, &hColumn);
750  }
751 
752  /* Set the sorting style to the new column */
753  hColumn.mask = HDI_FORMAT;
754  Header_GetItem(hHeader, m_sortInfo.nHeaderID, &hColumn);
755 
756  hColumn.fmt &= (m_sortInfo.bIsAscending ? ~HDF_SORTDOWN : ~HDF_SORTUP );
757  hColumn.fmt |= (m_sortInfo.bIsAscending ? HDF_SORTUP : HDF_SORTDOWN);
758  Header_SetItem(hHeader, m_sortInfo.nHeaderID, &hColumn);
759 
760  /* Sort the list, using the current values of nHeaderID and bIsAscending */
763 }
764 
766 {
767  return reinterpret_cast<PCUITEMID_CHILD>(m_ListView.GetItemData(i));
768 }
769 
771 {
772  return reinterpret_cast<PCUITEMID_CHILD>(lvItem.lParam);
773 }
774 
775 /**********************************************************
776 * LV_FindItemByPidl()
777 */
779 {
780  int cItems = m_ListView.GetItemCount();
781 
782  for (int i = 0; i<cItems; i++)
783  {
784  PCUITEMID_CHILD currentpidl = _PidlByItem(i);
785  if (ILIsEqual(pidl, currentpidl))
786  return i;
787  }
788  return -1;
789 }
790 
791 /**********************************************************
792 * LV_AddItem()
793 */
795 {
796  LVITEMW lvItem;
797 
798  TRACE("(%p)(pidl=%p)\n", this, pidl);
799 
800  lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; /*set the mask*/
801  lvItem.iItem = m_ListView.GetItemCount(); /*add the item to the end of the list*/
802  lvItem.iSubItem = 0;
803  lvItem.lParam = reinterpret_cast<LPARAM>(ILClone(pidl)); /*set the item's data*/
804  lvItem.pszText = LPSTR_TEXTCALLBACKW; /*get text on a callback basis*/
805  lvItem.iImage = I_IMAGECALLBACK; /*get the image on a callback basis*/
806  lvItem.stateMask = LVIS_CUT;
807 
808  return m_ListView.InsertItem(&lvItem);
809 }
810 
811 /**********************************************************
812 * LV_DeleteItem()
813 */
815 {
816  int nIndex;
817 
818  TRACE("(%p)(pidl=%p)\n", this, pidl);
819 
820  nIndex = LV_FindItemByPidl(pidl);
821 
822  return m_ListView.DeleteItem(nIndex);
823 }
824 
825 /**********************************************************
826 * LV_RenameItem()
827 */
829 {
830  int nItem;
831  LVITEMW lvItem;
832 
833  TRACE("(%p)(pidlold=%p pidlnew=%p)\n", this, pidlOld, pidlNew);
834 
835  nItem = LV_FindItemByPidl(pidlOld);
836 
837  if ( -1 != nItem )
838  {
839  lvItem.mask = LVIF_PARAM; /* only the pidl */
840  lvItem.iItem = nItem;
841  lvItem.iSubItem = 0;
842  m_ListView.GetItem(&lvItem);
843 
844  SHFree(reinterpret_cast<LPVOID>(lvItem.lParam));
845  lvItem.mask = LVIF_PARAM | LVIF_IMAGE | LVIF_TEXT;
846  lvItem.iItem = nItem;
847  lvItem.iSubItem = 0;
848  lvItem.lParam = reinterpret_cast<LPARAM>(ILClone(pidlNew)); /* set the item's data */
849  lvItem.pszText = LPSTR_TEXTCALLBACKW;
850  lvItem.iImage = SHMapPIDLToSystemImageListIndex(m_pSFParent, pidlNew, 0);
851  m_ListView.SetItem(&lvItem);
852  m_ListView.Update(nItem);
853  return TRUE; /* FIXME: better handling */
854  }
855 
856  return FALSE;
857 }
858 
859 /**********************************************************
860 * LV_ProdItem()
861 */
863 {
864  int nItem;
865  LVITEMW lvItem;
866 
867  TRACE("(%p)(pidl=%p)\n", this, pidl);
868 
869  nItem = LV_FindItemByPidl(pidl);
870 
871  if (-1 != nItem)
872  {
873  lvItem.mask = LVIF_IMAGE;
874  lvItem.iItem = nItem;
875  lvItem.iSubItem = 0;
877  m_ListView.SetItem(&lvItem);
878  m_ListView.Update(nItem);
879  return TRUE;
880  }
881 
882  return FALSE;
883 }
884 
885 /**********************************************************
886 * ShellView_FillList()
887 *
888 * - gets the objectlist from the shellfolder
889 * - sorts the list
890 * - fills the list into the view
891 */
893 {
894  PITEMID_CHILD pidl = static_cast<PITEMID_CHILD>(ptr);
895  CDefView *pThis = static_cast<CDefView *>(arg);
896 
897  /* in a commdlg This works as a filemask*/
898  if (pThis->IncludeObject(pidl) == S_OK)
899  pThis->LV_AddItem(pidl);
900 
901  SHFree(pidl);
902  return TRUE;
903 }
904 
906 {
907  CComPtr<IEnumIDList> pEnumIDList;
908  PITEMID_CHILD pidl;
909  DWORD dwFetched;
910  HRESULT hRes;
911  HDPA hdpa;
912  DWORD dFlags = SHCONTF_NONFOLDERS | SHCONTF_FOLDERS;
913  DWORD dwValue, cbValue;
914 
915  TRACE("%p\n", this);
916 
917  /* determine if there is a setting to show all the hidden files/folders */
918  dwValue = 1;
919  cbValue = sizeof(dwValue);
921  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
922  L"Hidden", NULL, &dwValue, &cbValue);
923  if (dwValue == 1)
924  {
925  dFlags |= SHCONTF_INCLUDEHIDDEN;
926  m_ListView.SendMessageW(LVM_SETCALLBACKMASK, LVIS_CUT, 0);
927  }
928 
929  dwValue = 0;
930  cbValue = sizeof(dwValue);
932  L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
933  L"ShowSuperHidden", NULL, &dwValue, &cbValue);
934  if (dwValue)
935  {
936  dFlags |= SHCONTF_INCLUDESUPERHIDDEN;
937  m_ListView.SendMessageW(LVM_SETCALLBACKMASK, LVIS_CUT, 0);
938  }
939 
940  /* get the itemlist from the shfolder */
941  hRes = m_pSFParent->EnumObjects(m_hWnd, dFlags, &pEnumIDList);
942  if (hRes != S_OK)
943  {
944  if (hRes == S_FALSE)
945  return(NOERROR);
946  return(hRes);
947  }
948 
949  /* create a pointer array */
950  hdpa = DPA_Create(16);
951  if (!hdpa)
952  {
953  return(E_OUTOFMEMORY);
954  }
955 
956  /* copy the items into the array*/
957  while((S_OK == pEnumIDList->Next(1, &pidl, &dwFetched)) && dwFetched)
958  {
959  if (DPA_InsertPtr(hdpa, 0x7fff, pidl) == -1)
960  {
961  SHFree(pidl);
962  }
963  }
964 
965  /*turn the listview's redrawing off*/
967 
968  DPA_DestroyCallback( hdpa, fill_list, this);
969 
970  /* sort the array */
971  if (m_pSF2Parent)
972  {
973  m_pSF2Parent->GetDefaultColumn(NULL, (ULONG*)&m_sortInfo.nHeaderID, NULL);
974  }
975  else
976  {
977  FIXME("no m_pSF2Parent\n");
978  }
980  _Sort();
981 
983  {
986  }
987 
988  // load custom background image and custom text color
991 
992  /*turn the listview's redrawing back on and force it to draw*/
994 
996 
998  {
999  // redraw now
1000  m_ListView.InvalidateRect(NULL, TRUE);
1001  }
1002 
1004 
1005  return S_OK;
1006 }
1007 
1009 {
1010  m_ListView.UpdateWindow();
1011  bHandled = FALSE;
1012  return 0;
1013 }
1014 
1016 {
1017  return m_ListView.SendMessageW(uMsg, 0, 0);
1018 }
1019 
1021 {
1022  if (!m_Destroyed)
1023  {
1024  m_Destroyed = TRUE;
1025  if (m_hMenu)
1026  {
1028  m_hMenu = NULL;
1029  }
1032  m_hNotify = NULL;
1034  m_pidlParent = NULL;
1035  }
1036  bHandled = FALSE;
1037  return 0;
1038 }
1039 
1041 {
1042  /* redirect to parent */
1045 
1046  bHandled = FALSE;
1047  return 0;
1048 }
1049 
1050 static VOID
1052 {
1053  INT x0 = prc->left, y0 = prc->top, x1 = prc->right, y1 = prc->bottom;
1054  x0 += dx;
1055  y0 += dy;
1056 
1057  HDC hMemDC = CreateCompatibleDC(hDC);
1058  HGDIOBJ hbmOld = SelectObject(hMemDC, hbm);
1059 
1060  for (INT y = y0; y < y1; y += nHeight)
1061  {
1062  for (INT x = x0; x < x1; x += nWidth)
1063  {
1064  BitBlt(hDC, x, y, nWidth, nHeight, hMemDC, 0, 0, SRCCOPY);
1065  }
1066  }
1067 
1068  SelectObject(hMemDC, hbmOld);
1069  DeleteDC(hMemDC);
1070 }
1071 
1073 {
1074  HDC hDC = (HDC)wParam;
1075 
1076  RECT rc;
1078 
1080  {
1081  BITMAP bm;
1082  if (::GetObject(m_viewinfo_data.hbmBack, sizeof(BITMAP), &bm))
1083  {
1084  INT dx = -(::GetScrollPos(m_ListView, SB_HORZ) % bm.bmWidth);
1085  INT dy = -(::GetScrollPos(m_ListView, SB_VERT) % bm.bmHeight);
1086  DrawTileBitmap(hDC, &rc, m_viewinfo_data.hbmBack, bm.bmWidth, bm.bmHeight, dx, dy);
1087  }
1088  }
1089  else
1090  {
1092  }
1093 
1094  bHandled = TRUE;
1095 
1096  return TRUE;
1097 }
1098 
1100 {
1101  /* Update desktop labels color */
1102  UpdateListColors();
1103 
1104  /* Forward WM_SYSCOLORCHANGE to common controls */
1105  return m_ListView.SendMessageW(uMsg, 0, 0);
1106 }
1107 
1109 {
1110  return reinterpret_cast<LRESULT>(m_pShellBrowser.p);
1111 }
1112 
1114 {
1115  this->AddRef();
1116  bHandled = FALSE;
1117  return 0;
1118 }
1119 
1121 {
1122  this->Release();
1123  bHandled = FALSE;
1124  return 0;
1125 }
1126 
1127 /**********************************************************
1128 * ShellView_OnCreate()
1129 */
1131 {
1134 
1135  TRACE("%p\n", this);
1136 
1138  {
1139  if (FAILED(RegisterDragDrop(m_hWnd, pdt)))
1140  ERR("Registering Drag Drop Failed");
1141  }
1142 
1143  /* register for receiving notifications */
1144  m_pSFParent->QueryInterface(IID_PPV_ARG(IPersistFolder2, &ppf2));
1145  if (ppf2)
1146  {
1147  ppf2->GetCurFolder(&m_pidlParent);
1148  }
1149 
1150  if (CreateList())
1151  {
1152  if (InitList())
1153  {
1154  FillList();
1155  }
1156  }
1157 
1159  {
1160  HWND hwndSB;
1161  m_pShellBrowser->GetWindow(&hwndSB);
1162  SetShellWindowEx(hwndSB, m_ListView);
1163  }
1164 
1165  INT nRegCount;
1166  SHChangeNotifyEntry ntreg[3];
1167  PIDLIST_ABSOLUTE pidls[3];
1169  {
1170  nRegCount = 3;
1174  ntreg[0].fRecursive = FALSE;
1175  ntreg[0].pidl = pidls[0];
1176  ntreg[1].fRecursive = FALSE;
1177  ntreg[1].pidl = pidls[1];
1178  ntreg[2].fRecursive = FALSE;
1179  ntreg[2].pidl = pidls[2];
1180  }
1181  else
1182  {
1183  nRegCount = 1;
1184  ntreg[0].fRecursive = FALSE;
1185  ntreg[0].pidl = m_pidlParent;
1186  }
1191  nRegCount, ntreg);
1192  if (nRegCount == 3)
1193  {
1194  ILFree(pidls[0]);
1195  ILFree(pidls[1]);
1196  ILFree(pidls[2]);
1197  }
1198 
1199  /* _DoFolderViewCB(SFVM_GETNOTIFY, ?? ??) */
1200 
1202 
1203  UpdateStatusbar();
1204 
1205  return S_OK;
1206 }
1207 
1208 /**********************************************************
1209  * #### Handling of the menus ####
1210  */
1211 
1212 extern "C" DWORD WINAPI SHMenuIndexFromID(HMENU hMenu, UINT uID);
1213 
1215 {
1216  MENUITEMINFOW mii = {sizeof(mii), MIIM_SUBMENU};
1217  if (::GetMenuItemInfoW(hmenu, id, FALSE, &mii))
1218  return mii.hSubMenu;
1219 
1220  return NULL;
1221 }
1222 
1223 /* ReallyGetMenuItemID returns the id of an item even if it opens a submenu,
1224  GetMenuItemID returns -1 if the specified item opens a submenu */
1226 {
1227  MENUITEMINFOW mii = {sizeof(mii), MIIM_ID};
1228  if (::GetMenuItemInfoW(hmenu, i, TRUE, &mii))
1229  return mii.wID;
1230 
1231  return UINT_MAX;
1232 }
1233 
1235 {
1237  if (!hFileMenu)
1238  return E_FAIL;
1239 
1240  /* Cleanup the items added previously */
1241  for (int i = GetMenuItemCount(hFileMenu) - 1; i >= 0; i--)
1242  {
1243  UINT id = GetMenuItemID(hFileMenu, i);
1245  DeleteMenu(hFileMenu, i, MF_BYPOSITION);
1246  }
1247 
1249 
1250  /* Store the context menu in m_pCM and keep it in order to invoke the selected command later on */
1253  if (FAILED_UNEXPECTEDLY(hr))
1254  return hr;
1255 
1257 
1258  hr = m_pCM->QueryContextMenu(hmenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, 0);
1259  if (FAILED_UNEXPECTEDLY(hr))
1260  return hr;
1261 
1262  // TODO: filter or something
1263 
1264  Shell_MergeMenus(hFileMenu, hmenu, 0, 0, 0xFFFF, MM_ADDSEPARATOR | MM_SUBMENUSHAVEIDS);
1265 
1267 
1268  return S_OK;
1269 }
1270 
1272 {
1274  if (!hEditMenu)
1275  return E_FAIL;
1276 
1277  HMENU hmenuContents = ::LoadMenuW(shell32_hInstance, L"MENU_003");
1278  if (!hmenuContents)
1279  return E_FAIL;
1280 
1281  Shell_MergeMenus(hEditMenu, hmenuContents, 0, 0, 0xFFFF, 0);
1282 
1283  ::DestroyMenu(hmenuContents);
1284 
1285  return S_OK;
1286 }
1287 
1289 {
1291  if (!hViewMenu)
1292  return E_FAIL;
1293 
1295  if (!m_hMenuViewModes)
1296  return E_FAIL;
1297 
1300 
1301  return S_OK;
1302 }
1303 
1305 {
1306  /* We only need to fill this once */
1307  if (GetMenuItemID(hmenuArrange, 0) == FCIDM_SHVIEW_AUTOARRANGE)
1308  {
1309  Shell_MergeMenus(hmenuArrange, m_hMenuArrangeModes, 0, 0, 0xFFFF,0);
1310  }
1311 
1312  /* Also check the menu item according to which we sort */
1313  CheckMenuRadioItem(hmenuArrange,
1314  0x30,
1315  0x100,
1316  m_sortInfo.nHeaderID + 0x30,
1317  MF_BYCOMMAND);
1318 
1320  {
1323  }
1324  else
1325  {
1328 
1329  if (GetAutoArrange() == S_OK)
1331  else
1333 
1334  if (_GetSnapToGrid() == S_OK)
1336  else
1338  }
1339 
1340 
1341  return S_OK;
1342 }
1343 
1345 {
1347  {
1348  UINT iItemFirst = FCIDM_SHVIEW_BIGICON;
1349  UINT iItemLast = iItemFirst + FVM_LAST - FVM_FIRST;
1350  UINT iItem = iItemFirst + m_FolderSettings.ViewMode - FVM_FIRST;
1351  CheckMenuRadioItem(hmenuView, iItemFirst, iItemLast, iItem, MF_BYCOMMAND);
1352  }
1353 
1354  return S_OK;
1355 }
1356 
1357 /**********************************************************
1358 * ShellView_GetSelections()
1359 *
1360 * - fills the m_apidl list with the selected objects
1361 *
1362 * RETURNS
1363 * number of selected items
1364 */
1366 {
1367  SHFree(m_apidl);
1368 
1370  m_apidl = static_cast<PCUITEMID_CHILD*>(SHAlloc(m_cidl * sizeof(PCUITEMID_CHILD)));
1371  if (!m_apidl)
1372  {
1373  m_cidl = 0;
1374  return 0;
1375  }
1376 
1377  TRACE("-- Items selected =%u\n", m_cidl);
1378 
1379  UINT i = 0;
1380  int lvIndex = -1;
1381  while ((lvIndex = m_ListView.GetNextItem(lvIndex, LVNI_SELECTED)) > -1)
1382  {
1383  m_apidl[i] = _PidlByItem(lvIndex);
1384  i++;
1385  if (i == m_cidl)
1386  break;
1387  TRACE("-- selected Item found\n");
1388  }
1389 
1390  return m_cidl;
1391 }
1392 
1394 {
1395  CMINVOKECOMMANDINFO cmi;
1396 
1397  ZeroMemory(&cmi, sizeof(cmi));
1398  cmi.cbSize = sizeof(cmi);
1399  cmi.lpVerb = MAKEINTRESOURCEA(uCommand);
1400  cmi.hwnd = m_hWnd;
1401 
1402  if (GetKeyState(VK_SHIFT) & 0x8000)
1403  cmi.fMask |= CMIC_MASK_SHIFT_DOWN;
1404 
1405  if (GetKeyState(VK_CONTROL) & 0x8000)
1406  cmi.fMask |= CMIC_MASK_CONTROL_DOWN;
1407 
1408  HRESULT hr = m_pCM->InvokeCommand(&cmi);
1409  if (FAILED_UNEXPECTEDLY(hr))
1410  return hr;
1411 
1412  return S_OK;
1413 }
1414 
1415 /**********************************************************
1416  * ShellView_OpenSelectedItems()
1417  */
1419 {
1420  HMENU hMenu;
1421  UINT uCommand;
1422  HRESULT hResult;
1423 
1425  if (m_cidl == 0)
1426  return S_OK;
1427 
1428  hResult = OnDefaultCommand();
1429  if (hResult == S_OK)
1430  return hResult;
1431 
1432  hMenu = CreatePopupMenu();
1433  if (!hMenu)
1434  return E_FAIL;
1435 
1437  if (FAILED_UNEXPECTEDLY(hResult))
1438  goto cleanup;
1439 
1440  hResult = m_pCM->QueryContextMenu(hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, CMF_DEFAULTONLY);
1441  if (FAILED_UNEXPECTEDLY(hResult))
1442  goto cleanup;
1443 
1444  uCommand = GetMenuDefaultItem(hMenu, FALSE, 0);
1445  if (uCommand == (UINT)-1)
1446  {
1447  hResult = E_FAIL;
1448  goto cleanup;
1449  }
1450 
1451  InvokeContextMenuCommand(uCommand);
1452 
1453 cleanup:
1454 
1455  if (hMenu)
1456  DestroyMenu(hMenu);
1457 
1458  if (m_pCM)
1459  {
1461  m_pCM.Release();
1462  }
1463 
1464  return hResult;
1465 }
1466 
1467 /**********************************************************
1468  * ShellView_DoContextMenu()
1469  */
1471 {
1472  int x, y;
1473  UINT uCommand;
1474  HRESULT hResult;
1475 
1476  TRACE("(%p)\n", this);
1477 
1479  if (!m_hContextMenu)
1480  return E_FAIL;
1481 
1482  if (lParam != ~0) // unless app key (menu key) was pressed
1483  {
1484  x = GET_X_LPARAM(lParam);
1485  y = GET_Y_LPARAM(lParam);
1486 
1487  LV_HITTESTINFO hittest = { { x, y } };
1488  ScreenToClient(&hittest.pt);
1489  m_ListView.HitTest(&hittest);
1490 
1491  // Right-Clicked item is selected? If selected, no selection change.
1492  // If not selected, then reset the selection and select the item.
1493  if ((hittest.flags & LVHT_ONITEM) &&
1495  {
1496  SelectItem(hittest.iItem, SVSI_SELECT | SVSI_DESELECTOTHERS | SVSI_ENSUREVISIBLE);
1497  }
1498  }
1499 
1501 
1503  if (FAILED_UNEXPECTEDLY(hResult))
1504  goto cleanup;
1505 
1506  /* Use 1 as the first id as we want 0 the mean that the user canceled the menu */
1507  hResult = m_pCM->QueryContextMenu(m_hContextMenu, 0, CONTEXT_MENU_BASE_ID, FCIDM_SHVIEWLAST, CMF_NORMAL);
1508  if (FAILED_UNEXPECTEDLY(hResult))
1509  goto cleanup;
1510 
1511  /* There is no position requested, so try to find one */
1512  if (lParam == ~0)
1513  {
1514  HWND hFocus = ::GetFocus();
1515  int lvIndex = -1;
1516  POINT pt;
1517 
1518  if (hFocus == m_ListView.m_hWnd || m_ListView.IsChild(hFocus))
1519  {
1520  /* Is there an item focused and selected? */
1522  /* If not, find the first selected item */
1523  if (lvIndex < 0)
1524  lvIndex = m_ListView.GetNextItem(-1, LVIS_SELECTED);
1525  }
1526 
1527  /* We got something */
1528  if (lvIndex > -1)
1529  {
1530  /* Let's find the center of the icon */
1531  RECT rc = { LVIR_ICON };
1532  m_ListView.SendMessage(LVM_GETITEMRECT, lvIndex, (LPARAM)&rc);
1533  pt.x = (rc.right + rc.left) / 2;
1534  pt.y = (rc.bottom + rc.top) / 2;
1535  }
1536  else
1537  {
1538  /* We have to drop it somewhere.. */
1539  pt.x = pt.y = 0;
1540  }
1541 
1542  m_ListView.ClientToScreen(&pt);
1543  x = pt.x;
1544  y = pt.y;
1545  }
1546 
1547  uCommand = TrackPopupMenu(m_hContextMenu,
1549  x, y, 0, m_hWnd, NULL);
1550  if (uCommand == 0)
1551  goto cleanup;
1552 
1553  if (uCommand == FCIDM_SHVIEW_OPEN && OnDefaultCommand() == S_OK)
1554  goto cleanup;
1555 
1557 
1558 cleanup:
1559  if (m_pCM)
1560  {
1562  m_pCM.Release();
1563  }
1564 
1565  if (m_hContextMenu)
1566  {
1568  m_hContextMenu = NULL;
1569  }
1570 
1571  return 0;
1572 }
1573 
1575 {
1576  HRESULT hResult;
1577  HMENU hMenu;
1578 
1579  hMenu = CreatePopupMenu();
1580  if (!hMenu)
1581  return 0;
1582 
1583  hResult = GetItemObject( bUseSelection ? SVGIO_SELECTION : SVGIO_BACKGROUND, IID_PPV_ARG(IContextMenu, &m_pCM));
1584  if (FAILED_UNEXPECTEDLY( hResult))
1585  goto cleanup;
1586 
1587  hResult = m_pCM->QueryContextMenu(hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, CMF_NORMAL);
1588  if (FAILED_UNEXPECTEDLY( hResult))
1589  goto cleanup;
1590 
1591  InvokeContextMenuCommand(uCommand);
1592 
1593 cleanup:
1594  if (m_pCM)
1595  {
1597  m_pCM.Release();
1598  }
1599 
1600  if (hMenu)
1601  DestroyMenu(hMenu);
1602 
1603  return 0;
1604 }
1605 
1606 /**********************************************************
1607  * ##### message handling #####
1608  */
1609 
1610 /**********************************************************
1611 * ShellView_OnSize()
1612 */
1614 {
1615  WORD wWidth, wHeight;
1616 
1617  wWidth = LOWORD(lParam);
1618  wHeight = HIWORD(lParam);
1619 
1620  TRACE("%p width=%u height=%u\n", this, wWidth, wHeight);
1621 
1622  /* Resize the ListView to fit our window */
1623  if (m_ListView)
1624  {
1625  ::MoveWindow(m_ListView, 0, 0, wWidth, wHeight, TRUE);
1626  }
1627 
1628  _DoFolderViewCB(SFVM_SIZE, 0, 0);
1629 
1630  return 0;
1631 }
1632 
1633 /**********************************************************
1634 * ShellView_OnDeactivate()
1635 *
1636 * NOTES
1637 * internal
1638 */
1640 {
1641  TRACE("%p\n", this);
1642 
1643  if (m_uState != SVUIA_DEACTIVATE)
1644  {
1645  // TODO: cleanup menu after deactivation
1646 
1648  }
1649 }
1650 
1652 {
1653  TRACE("%p uState=%x\n", this, uState);
1654 
1655  /*don't do anything if the state isn't really changing */
1656  if (m_uState == uState)
1657  {
1658  return;
1659  }
1660 
1661  if (uState == SVUIA_DEACTIVATE)
1662  {
1663  OnDeactivate();
1664  }
1665  else
1666  {
1668  {
1669  FillEditMenu();
1670  FillViewMenu();
1671  m_pShellBrowser->SetMenuSB(m_hMenu, 0, m_hWnd);
1673  }
1674 
1675  if (SVUIA_ACTIVATE_FOCUS == uState)
1676  {
1677  m_ListView.SetFocus();
1678  }
1679  }
1680 
1681  m_uState = uState;
1682  TRACE("--\n");
1683 }
1684 
1685 /**********************************************************
1686 * ShellView_OnActivate()
1687 */
1689 {
1691  return 0;
1692 }
1693 
1694 /**********************************************************
1695 * ShellView_OnSetFocus()
1696 *
1697 */
1699 {
1700  TRACE("%p\n", this);
1701 
1702  /* Tell the browser one of our windows has received the focus. This
1703  should always be done before merging menus (OnActivate merges the
1704  menus) if one of our windows has the focus.*/
1705 
1706  m_pShellBrowser->OnViewWindowActive(this);
1708 
1709  /* Set the focus to the listview */
1710  m_ListView.SetFocus();
1711 
1712  /* Notify the ICommDlgBrowser interface */
1713  OnStateChange(CDBOSC_SETFOCUS);
1714 
1715  return 0;
1716 }
1717 
1718 /**********************************************************
1719 * ShellView_OnKillFocus()
1720 */
1722 {
1723  TRACE("(%p) stub\n", this);
1724 
1726  /* Notify the ICommDlgBrowser */
1727  OnStateChange(CDBOSC_KILLFOCUS);
1728 
1729  return 0;
1730 }
1731 
1732 /**********************************************************
1733 * ShellView_OnCommand()
1734 *
1735 * NOTES
1736 * the CmdID's are the ones from the context menu
1737 */
1739 {
1740  DWORD dwCmdID;
1741  DWORD dwCmd;
1742  HWND hwndCmd;
1743  int nCount;
1744 
1745  dwCmdID = GET_WM_COMMAND_ID(wParam, lParam);
1746  dwCmd = GET_WM_COMMAND_CMD(wParam, lParam);
1747  hwndCmd = GET_WM_COMMAND_HWND(wParam, lParam);
1748 
1749  TRACE("(%p)->(0x%08x 0x%08x %p) stub\n", this, dwCmdID, dwCmd, hwndCmd);
1750 
1751  switch (dwCmdID)
1752  {
1755  m_ListView.ModifyStyle(LVS_TYPEMASK, LVS_SMALLICON);
1756  CheckToolbar();
1757  break;
1758 
1759  case FCIDM_SHVIEW_BIGICON:
1761  m_ListView.ModifyStyle(LVS_TYPEMASK, LVS_ICON);
1762  CheckToolbar();
1763  break;
1764 
1765  case FCIDM_SHVIEW_LISTVIEW:
1767  m_ListView.ModifyStyle(LVS_TYPEMASK, LVS_LIST);
1768  CheckToolbar();
1769  break;
1770 
1773  m_ListView.ModifyStyle(LVS_TYPEMASK, LVS_REPORT);
1774  CheckToolbar();
1775  break;
1776 
1777  /* the menu-ID's for sorting are 0x30... see shrec.rc */
1778  case 0x30:
1779  case 0x31:
1780  case 0x32:
1781  case 0x33:
1782  m_sortInfo.nHeaderID = dwCmdID - 0x30;
1784  _Sort();
1785  break;
1786 
1789  break;
1791  if (_GetSnapToGrid() == S_OK)
1793  else
1794  ArrangeGrid();
1795  break;
1797  if (GetAutoArrange() == S_OK)
1798  m_ListView.ModifyStyle(LVS_AUTOARRANGE, 0);
1799  else
1800  AutoArrange();
1801  break;
1804  break;
1805 
1807  nCount = m_ListView.GetItemCount();
1808  for (int i=0; i < nCount; i++)
1810  break;
1811 
1812  case FCIDM_SHVIEW_REFRESH:
1813  Refresh();
1814  break;
1815 
1816  case FCIDM_SHVIEW_DELETE:
1817  case FCIDM_SHVIEW_CUT:
1818  case FCIDM_SHVIEW_COPY:
1819  case FCIDM_SHVIEW_RENAME:
1821  return OnExplorerCommand(dwCmdID, TRUE);
1822 
1823  case FCIDM_SHVIEW_INSERT:
1824  case FCIDM_SHVIEW_UNDO:
1827  return OnExplorerCommand(dwCmdID, FALSE);
1828  default:
1829  /* WM_COMMAND messages from the file menu are routed to the CDefView so as to let m_pCM handle the command */
1830  if (m_pCM && dwCmd == 0)
1831  {
1832  InvokeContextMenuCommand(dwCmdID);
1833  }
1834  }
1835 
1836  return 0;
1837 }
1838 
1839 static BOOL
1841 {
1842  HKEY hKey;
1843  LONG error;
1844  DWORD dwValue = FALSE, cbValue;
1845 
1847  L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer",
1848  0, KEY_READ, &hKey);
1849  if (error)
1850  return dwValue;
1851 
1852  cbValue = sizeof(dwValue);
1853  RegQueryValueExW(hKey, L"SelectExtOnRename", NULL, NULL, (LPBYTE)&dwValue, &cbValue);
1854 
1855  RegCloseKey(hKey);
1856  return !!dwValue;
1857 }
1858 
1859 /**********************************************************
1860 * ShellView_OnNotify()
1861 */
1862 
1864 {
1865  UINT CtlID;
1866  LPNMHDR lpnmh;
1867  LPNMLISTVIEW lpnmlv;
1868  NMLVDISPINFOW *lpdi;
1869  PCUITEMID_CHILD pidl;
1870  BOOL unused;
1871 
1872  CtlID = wParam;
1873  lpnmh = (LPNMHDR)lParam;
1874  lpnmlv = (LPNMLISTVIEW)lpnmh;
1875  lpdi = (NMLVDISPINFOW *)lpnmh;
1876 
1877  TRACE("%p CtlID=%u lpnmh->code=%x\n", this, CtlID, lpnmh->code);
1878 
1879  switch (lpnmh->code)
1880  {
1881  case NM_SETFOCUS:
1882  TRACE("-- NM_SETFOCUS %p\n", this);
1883  OnSetFocus(0, 0, 0, unused);
1884  break;
1885 
1886  case NM_KILLFOCUS:
1887  TRACE("-- NM_KILLFOCUS %p\n", this);
1888  OnDeactivate();
1889  /* Notify the ICommDlgBrowser interface */
1890  OnStateChange(CDBOSC_KILLFOCUS);
1891  break;
1892 
1893  case NM_CUSTOMDRAW:
1894  TRACE("-- NM_CUSTOMDRAW %p\n", this);
1895  return CDRF_DODEFAULT;
1896 
1897  case NM_RELEASEDCAPTURE:
1898  TRACE("-- NM_RELEASEDCAPTURE %p\n", this);
1899  break;
1900 
1901  case NM_CLICK:
1902  TRACE("-- NM_CLICK %p\n", this);
1903  break;
1904 
1905  case NM_RCLICK:
1906  TRACE("-- NM_RCLICK %p\n", this);
1907  break;
1908 
1909  case NM_DBLCLK:
1910  TRACE("-- NM_DBLCLK %p\n", this);
1912  break;
1913 
1914  case NM_RETURN:
1915  TRACE("-- NM_RETURN %p\n", this);
1917  break;
1918 
1919  case HDN_ENDTRACKW:
1920  TRACE("-- HDN_ENDTRACKW %p\n", this);
1921  /*nColumn1 = m_ListView.GetColumnWidth(0);
1922  nColumn2 = m_ListView.GetColumnWidth(1);*/
1923  break;
1924 
1925  case LVN_DELETEITEM:
1926  TRACE("-- LVN_DELETEITEM %p\n", this);
1927 
1928  /*delete the pidl because we made a copy of it*/
1929  SHFree(reinterpret_cast<LPVOID>(lpnmlv->lParam));
1930 
1931  break;
1932 
1933  case LVN_DELETEALLITEMS:
1934  TRACE("-- LVN_DELETEALLITEMS %p\n", this);
1935  return FALSE;
1936 
1937  case LVN_INSERTITEM:
1938  TRACE("-- LVN_INSERTITEM (STUB)%p\n", this);
1939  break;
1940 
1941  case LVN_ITEMACTIVATE:
1942  TRACE("-- LVN_ITEMACTIVATE %p\n", this);
1943  OnStateChange(CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
1944  break;
1945 
1946  case LVN_COLUMNCLICK:
1947  m_sortInfo.nHeaderID = lpnmlv->iSubItem;
1950  else
1952  _Sort();
1953  break;
1954 
1955  case LVN_GETDISPINFOA:
1956  case LVN_GETDISPINFOW:
1957  TRACE("-- LVN_GETDISPINFO %p\n", this);
1958  pidl = _PidlByItem(lpdi->item);
1959 
1960  if (lpdi->item.mask & LVIF_TEXT) /* text requested */
1961  {
1962  if (m_pSF2Parent)
1963  {
1964  SHELLDETAILS sd;
1965  if (FAILED_UNEXPECTEDLY(m_pSF2Parent->GetDetailsOf(pidl, lpdi->item.iSubItem, &sd)))
1966  break;
1967 
1968  if (lpnmh->code == LVN_GETDISPINFOA)
1969  {
1970  /* shouldn't happen */
1971  NMLVDISPINFOA *lpdiA = (NMLVDISPINFOA *)lpnmh;
1972  StrRetToStrNA( lpdiA->item.pszText, lpdiA->item.cchTextMax, &sd.str, NULL);
1973  TRACE("-- text=%s\n", lpdiA->item.pszText);
1974  }
1975  else /* LVN_GETDISPINFOW */
1976  {
1977  StrRetToStrNW( lpdi->item.pszText, lpdi->item.cchTextMax, &sd.str, NULL);
1978  TRACE("-- text=%s\n", debugstr_w(lpdi->item.pszText));
1979  }
1980  }
1981  else
1982  {
1983  FIXME("no m_pSF2Parent\n");
1984  }
1985  }
1986  if(lpdi->item.mask & LVIF_IMAGE) /* image requested */
1987  {
1989  }
1990  if(lpdi->item.mask & LVIF_STATE)
1991  {
1992  ULONG attributes = SFGAO_HIDDEN;
1993  if (SUCCEEDED(m_pSFParent->GetAttributesOf(1, &pidl, &attributes)))
1994  {
1995  if (attributes & SFGAO_HIDDEN)
1996  {
1997  lpdi->item.state |= LVIS_CUT;
1998  }
1999  }
2000  }
2001  lpdi->item.mask |= LVIF_DI_SETITEM;
2002  break;
2003 
2004  case LVN_ITEMCHANGED:
2005  TRACE("-- LVN_ITEMCHANGED %p\n", this);
2006  OnStateChange(CDBOSC_SELCHANGE); /* the browser will get the IDataObject now */
2007  UpdateStatusbar();
2008  _DoFolderViewCB(SFVM_SELECTIONCHANGED, NULL/* FIXME */, NULL/* FIXME */);
2009  break;
2010 
2011  case LVN_BEGINDRAG:
2012  case LVN_BEGINRDRAG:
2013  TRACE("-- LVN_BEGINDRAG\n");
2014 
2015  if (GetSelections())
2016  {
2018  DWORD dwAttributes = SFGAO_CANCOPY | SFGAO_CANLINK;
2019  DWORD dwEffect = DROPEFFECT_MOVE;
2020 
2021  if (SUCCEEDED(m_pSFParent->GetUIObjectOf(m_hWnd, m_cidl, m_apidl, IID_NULL_PPV_ARG(IDataObject, &pda))))
2022  {
2024 
2025  if (SUCCEEDED(m_pSFParent->GetAttributesOf(m_cidl, m_apidl, &dwAttributes)))
2026  {
2027  dwEffect |= dwAttributes & (SFGAO_CANCOPY | SFGAO_CANLINK);
2028  }
2029 
2031  if (SUCCEEDED(pda->QueryInterface(IID_PPV_ARG(IAsyncOperation, &piaso))))
2032  {
2033  piaso->SetAsyncMode(TRUE);
2034  }
2035 
2036  DWORD dwEffect2;
2037 
2038  m_pSourceDataObject = pda;
2039  m_ptFirstMousePos = params->ptAction;
2041 
2042  HIMAGELIST big_icons, small_icons;
2043  Shell_GetImageLists(&big_icons, &small_icons);
2044  PCUITEMID_CHILD pidl = _PidlByItem(params->iItem);
2045  int iIcon = SHMapPIDLToSystemImageListIndex(m_pSFParent, pidl, 0);
2046  POINT ptItem;
2047  m_ListView.GetItemPosition(params->iItem, &ptItem);
2048 
2049  ImageList_BeginDrag(big_icons, iIcon, params->ptAction.x - ptItem.x, params->ptAction.y - ptItem.y);
2050 
2051  DoDragDrop(pda, this, dwEffect, &dwEffect2);
2052 
2054  }
2055  }
2056  break;
2057 
2058  case LVN_BEGINLABELEDITW:
2059  {
2060  DWORD dwAttr = SFGAO_CANRENAME;
2061  pidl = _PidlByItem(lpdi->item);
2062 
2063  TRACE("-- LVN_BEGINLABELEDITW %p\n", this);
2064 
2065  m_pSFParent->GetAttributesOf(1, &pidl, &dwAttr);
2066  if (SFGAO_CANRENAME & dwAttr)
2067  {
2068  HWND hEdit = reinterpret_cast<HWND>(m_ListView.SendMessage(LVM_GETEDITCONTROL));
2070 
2071  if (!(dwAttr & SFGAO_LINK) && (lpdi->item.mask & LVIF_TEXT) && !SelectExtOnRename())
2072  {
2073  LPWSTR pszText = lpdi->item.pszText;
2074  LPWSTR pchDotExt = PathFindExtensionW(pszText);
2075  ::PostMessageW(hEdit, EM_SETSEL, 0, pchDotExt - pszText);
2077  }
2078 
2079  m_isEditing = TRUE;
2080  return FALSE;
2081  }
2082 
2083  return TRUE;
2084  }
2085 
2086  case LVN_ENDLABELEDITW:
2087  {
2088  TRACE("-- LVN_ENDLABELEDITW %p\n", this);
2089 
2090  m_isEditing = FALSE;
2091 
2092  if (lpdi->item.pszText)
2093  {
2094  HRESULT hr;
2095  LVITEMW lvItem;
2096 
2097  pidl = _PidlByItem(lpdi->item);
2098  PITEMID_CHILD pidlNew = NULL;
2099  hr = m_pSFParent->SetNameOf(0, pidl, lpdi->item.pszText, SHGDN_INFOLDER, &pidlNew);
2100 
2101  if (SUCCEEDED(hr) && pidlNew)
2102  {
2103  lvItem.mask = LVIF_PARAM|LVIF_IMAGE;
2104  lvItem.iItem = lpdi->item.iItem;
2105  lvItem.iSubItem = 0;
2106  lvItem.lParam = reinterpret_cast<LPARAM>(pidlNew);
2107  lvItem.iImage = SHMapPIDLToSystemImageListIndex(m_pSFParent, pidlNew, 0);
2108  m_ListView.SetItem(&lvItem);
2109  m_ListView.Update(lpdi->item.iItem);
2110  return TRUE;
2111  }
2112  }
2113 
2114  return FALSE;
2115  }
2116 
2117  default:
2118  TRACE("-- %p WM_COMMAND %x unhandled\n", this, lpnmh->code);
2119  break;
2120  }
2121 
2122  return 0;
2123 }
2124 
2125 /*
2126  * This is just a quick hack to make the desktop work correctly.
2127  * ITranslateShellChangeNotify's IsChildID is undocumented, but most likely the way that
2128  * a folder should know if it should update upon a change notification.
2129  * It is exported by merged folders at a minimum.
2130  */
2132 {
2133  if (!pidl1 || !pidl2)
2134  return FALSE;
2135  if (ILIsParent(pidl1, pidl2, TRUE))
2136  return TRUE;
2137 
2138  if (_ILIsDesktop(pidl1))
2139  {
2140  PIDLIST_ABSOLUTE deskpidl;
2142  if (ILIsParent(deskpidl, pidl2, TRUE))
2143  {
2144  ILFree(deskpidl);
2145  return TRUE;
2146  }
2147  ILFree(deskpidl);
2149  if (ILIsParent(deskpidl, pidl2, TRUE))
2150  {
2151  ILFree(deskpidl);
2152  return TRUE;
2153  }
2154  ILFree(deskpidl);
2155  }
2156 
2157  WCHAR szPath1[MAX_PATH], szPath2[MAX_PATH];
2158  LPITEMIDLIST pidl2Clone = ILClone(pidl2);
2159  ILRemoveLastID(pidl2Clone);
2160  if (SHGetPathFromIDListW(pidl1, szPath1) &&
2161  SHGetPathFromIDListW(pidl2Clone, szPath2))
2162  {
2163  if (lstrcmpiW(szPath1, szPath2) == 0)
2164  {
2165  ILFree(pidl2Clone);
2166  return TRUE;
2167  }
2168  }
2169  ILFree(pidl2Clone);
2170 
2171  return FALSE;
2172 }
2173 
2174 /**********************************************************
2175 * ShellView_OnChange()
2176 */
2178 {
2179  HANDLE hChange = (HANDLE)wParam;
2180  DWORD dwProcID = (DWORD)lParam;
2181  PIDLIST_ABSOLUTE *Pidls;
2182  LONG lEvent;
2183  HANDLE hLock = SHChangeNotification_Lock(hChange, dwProcID, &Pidls, &lEvent);
2184  if (hLock == NULL)
2185  {
2186  ERR("hLock == NULL\n");
2187  return FALSE;
2188  }
2189 
2190  BOOL bParent0 = ILIsParentOrSpecialParent(m_pidlParent, Pidls[0]);
2191  BOOL bParent1 = ILIsParentOrSpecialParent(m_pidlParent, Pidls[1]);
2192 
2193  TRACE("(%p)(%p,%p,0x%08x)\n", this, Pidls[0], Pidls[1], lParam);
2194 
2195  lEvent &= ~SHCNE_INTERRUPT;
2196  switch (lEvent)
2197  {
2198  case SHCNE_MKDIR:
2199  case SHCNE_CREATE:
2200  if (bParent0)
2201  {
2202  if (LV_FindItemByPidl(ILFindLastID(Pidls[0])) == -1)
2203  {
2204  LV_AddItem(ILFindLastID(Pidls[0]));
2205  }
2206  else
2207  {
2208  LV_ProdItem(ILFindLastID(Pidls[0]));
2209  }
2210  }
2211  break;
2212 
2213  case SHCNE_RMDIR:
2214  case SHCNE_DELETE:
2215  if (bParent0)
2216  LV_DeleteItem(ILFindLastID(Pidls[0]));
2217  break;
2218 
2219  case SHCNE_RENAMEFOLDER:
2220  case SHCNE_RENAMEITEM:
2221  if (bParent0 && bParent1)
2222  LV_RenameItem(ILFindLastID(Pidls[0]), ILFindLastID(Pidls[1]));
2223  else if (bParent0)
2224  LV_DeleteItem(ILFindLastID(Pidls[0]));
2225  else if (bParent1)
2226  LV_AddItem(ILFindLastID(Pidls[1]));
2227  break;
2228 
2229  case SHCNE_UPDATEITEM:
2230  if (bParent0)
2231  LV_RenameItem(ILFindLastID(Pidls[0]), ILFindLastID(Pidls[0]));
2232  break;
2233 
2234  case SHCNE_UPDATEDIR:
2235  Refresh();
2236  break;
2237  }
2238 
2240  return TRUE;
2241 }
2242 
2245 
2246 /**********************************************************
2247 * CDefView::OnCustomItem
2248 */
2250 {
2251  if (!m_pCM.p)
2252  {
2253  /* no menu */
2254  ERR("no menu!!!\n");
2255  return FALSE;
2256  }
2257 
2258  /* The lParam of WM_DRAWITEM WM_MEASUREITEM contain a menu id and this also needs to
2259  be changed to a menu identifier offset */
2260  UINT CmdID;
2261  HRESULT hres = SHGetMenuIdFromMenuMsg(uMsg, lParam, &CmdID);
2262  if (SUCCEEDED(hres))
2264 
2265  /* Forward the message to the IContextMenu2 */
2266  LRESULT result;
2268 
2269  return (SUCCEEDED(hres));
2270 }
2271 
2273 {
2274  /* Wallpaper setting affects drop shadows effect */
2275  if (wParam == SPI_SETDESKWALLPAPER || wParam == 0)
2276  UpdateListColors();
2277 
2278  return S_OK;
2279 }
2280 
2281 /**********************************************************
2282 * CDefView::OnInitMenuPopup
2283 */
2285 {
2286  HMENU hmenu = (HMENU) wParam;
2287  int nPos = LOWORD(lParam);
2288  UINT menuItemId;
2289 
2290  OnCustomItem(uMsg, wParam, lParam, bHandled);
2291 
2293 
2294  /* Lets try to find out what the hell wParam is */
2295  if (hmenu == GetSubMenu(m_hMenu, nPos))
2296  menuItemId = ReallyGetMenuItemID(m_hMenu, nPos);
2297  else if (hViewMenu && hmenu == GetSubMenu(hViewMenu, nPos))
2298  menuItemId = ReallyGetMenuItemID(hViewMenu, nPos);
2299  else if (m_hContextMenu && hmenu == GetSubMenu(m_hContextMenu, nPos))
2300  menuItemId = ReallyGetMenuItemID(m_hContextMenu, nPos);
2301  else
2302  return FALSE;
2303 
2304  switch (menuItemId)
2305  {
2306  case FCIDM_MENU_FILE:
2307  FillFileMenu();
2308  break;
2309  case FCIDM_MENU_VIEW:
2310  case FCIDM_SHVIEW_VIEW:
2312  break;
2313  case FCIDM_SHVIEW_ARRANGE:
2315  break;
2316  }
2317 
2318  return FALSE;
2319 }
2320 
2321 /**********************************************************
2322 *
2323 *
2324 * The INTERFACE of the IShellView object
2325 *
2326 *
2327 **********************************************************
2328 */
2329 
2330 /**********************************************************
2331 * ShellView_GetWindow
2332 */
2334 {
2335  TRACE("(%p)\n", this);
2336 
2337  *phWnd = m_hWnd;
2338 
2339  return S_OK;
2340 }
2341 
2343 {
2344  FIXME("(%p) stub\n", this);
2345 
2346  return E_NOTIMPL;
2347 }
2348 
2349 /**********************************************************
2350 * IShellView_TranslateAccelerator
2351 *
2352 * FIXME:
2353 * use the accel functions
2354 */
2356 {
2357  if (m_isEditing)
2358  return S_FALSE;
2359 
2360  if (lpmsg->message >= WM_KEYFIRST && lpmsg->message <= WM_KEYLAST)
2361  {
2362  if (::TranslateAcceleratorW(m_hWnd, m_hAccel, lpmsg) != 0)
2363  return S_OK;
2364 
2365  TRACE("-- key=0x%04lx\n", lpmsg->wParam) ;
2366  }
2367 
2368  return m_pShellBrowser->TranslateAcceleratorSB(lpmsg, 0);
2369 }
2370 
2372 {
2373  FIXME("(%p) stub\n", this);
2374 
2375  return E_NOTIMPL;
2376 }
2377 
2379 {
2380  // CHAR szName[MAX_PATH];
2381  LRESULT lResult;
2382  int nPartArray[1] = { -1};
2383 
2384  TRACE("(%p)->(state=%x) stub\n", this, uState);
2385 
2386  /* don't do anything if the state isn't really changing */
2387  if (m_uState == uState)
2388  {
2389  return S_OK;
2390  }
2391 
2392  /* OnActivate handles the menu merging and internal state */
2393  DoActivate(uState);
2394 
2395  /* only do This if we are active */
2396  if (uState != SVUIA_DEACTIVATE)
2397  {
2398 
2399  /*
2400  GetFolderPath is not a method of IShellFolder
2401  IShellFolder_GetFolderPath( m_pSFParent, szName, sizeof(szName) );
2402  */
2403  /* set the number of parts */
2404  m_pShellBrowser->SendControlMsg(FCW_STATUS, SB_SETPARTS, 1, (LPARAM)nPartArray, &lResult);
2405 
2406  /* set the text for the parts */
2407  /*
2408  m_pShellBrowser->SendControlMsg(FCW_STATUS, SB_SETTEXTA, 0, (LPARAM)szName, &lResult);
2409  */
2410  }
2411 
2412  return S_OK;
2413 }
2414 
2416 {
2417  TRACE("(%p)\n", this);
2418 
2420  FillList();
2421 
2422  return S_OK;
2423 }
2424 
2426 {
2427  return CreateViewWindow3(psb, lpPrevView, SV3CVW3_DEFAULT,
2428  (FOLDERFLAGS)lpfs->fFlags, (FOLDERFLAGS)lpfs->fFlags, (FOLDERVIEWMODE)lpfs->ViewMode, NULL, prcView, phWnd);
2429 }
2430 
2432 {
2433  TRACE("(%p)\n", this);
2434 
2435  /* Make absolutely sure all our UI is cleaned up */
2437 
2438  if (m_hAccel)
2439  {
2440  // "Accelerator tables loaded from resources are freed automatically when the application terminates." -- MSDN
2441  m_hAccel = NULL;
2442  }
2443 
2444  if (m_hMenuArrangeModes)
2445  {
2448  }
2449 
2450  if (m_hMenuViewModes)
2451  {
2454  }
2455 
2456  if (m_hMenu)
2457  {
2459  m_hMenu = NULL;
2460  }
2461 
2462  if (m_ListView)
2463  {
2464  m_ListView.DestroyWindow();
2465  }
2466 
2467  if (m_hWnd)
2468  {
2469  DestroyWindow();
2470  }
2471 
2474 
2475  return S_OK;
2476 }
2477 
2479 {
2480  TRACE("(%p)->(%p) vmode=%x flags=%x\n", this, lpfs,
2482 
2483  if (!lpfs)
2484  return E_INVALIDARG;
2485 
2486  *lpfs = m_FolderSettings;
2487  return S_OK;
2488 }
2489 
2491 {
2492  FIXME("(%p) stub\n", this);
2493 
2494  return E_NOTIMPL;
2495 }
2496 
2498 {
2499  FIXME("(%p) stub\n", this);
2500 
2501  return S_OK;
2502 }
2503 
2505 {
2506  int i;
2507 
2508  TRACE("(%p)->(pidl=%p, 0x%08x) stub\n", this, pidl, uFlags);
2509 
2510  i = LV_FindItemByPidl(pidl);
2511  if (i == -1)
2512  return S_OK;
2513 
2514  LVITEMW lvItem = {0};
2515  lvItem.mask = LVIF_STATE;
2517 
2518  while (m_ListView.GetItem(&lvItem))
2519  {
2520  if (lvItem.iItem == i)
2521  {
2522  if (uFlags & SVSI_SELECT)
2523  lvItem.state |= LVIS_SELECTED;
2524  else
2525  lvItem.state &= ~LVIS_SELECTED;
2526 
2527  if (uFlags & SVSI_FOCUSED)
2528  lvItem.state |= LVIS_FOCUSED;
2529  else
2530  lvItem.state &= ~LVIS_FOCUSED;
2531  }
2532  else
2533  {
2534  if (uFlags & SVSI_DESELECTOTHERS)
2535  {
2536  lvItem.state &= ~LVIS_SELECTED;
2537  }
2538  lvItem.state &= ~LVIS_FOCUSED;
2539  }
2540 
2541  m_ListView.SetItem(&lvItem);
2542  lvItem.iItem++;
2543  }
2544 
2545  if (uFlags & SVSI_ENSUREVISIBLE)
2547 
2548  if((uFlags & SVSI_EDIT) == SVSI_EDIT)
2550 
2551  return S_OK;
2552 }
2553 
2555 {
2557 
2558  TRACE("(%p)->(uItem=0x%08x,\n\tIID=%s, ppv=%p)\n", this, uItem, debugstr_guid(&riid), ppvOut);
2559 
2560  if (!ppvOut)
2561  return E_INVALIDARG;
2562 
2563  *ppvOut = NULL;
2564 
2565  switch (uItem)
2566  {
2567  case SVGIO_BACKGROUND:
2568  if (IsEqualIID(riid, IID_IContextMenu))
2569  {
2571  if (FAILED_UNEXPECTEDLY(hr))
2572  return hr;
2573 
2574  IUnknown_SetSite(*((IUnknown**)ppvOut), (IShellView *)this);
2575  }
2576  else if (IsEqualIID(riid, IID_IDispatch))
2577  {
2579  {
2581  if (FAILED_UNEXPECTEDLY(hr))
2582  return hr;
2583  }
2584  hr = m_pShellFolderViewDual->QueryInterface(riid, ppvOut);
2585  }
2586  break;
2587 
2588  case SVGIO_SELECTION:
2589  GetSelections();
2590  hr = m_pSFParent->GetUIObjectOf(m_hWnd, m_cidl, m_apidl, riid, 0, ppvOut);
2591  if (FAILED_UNEXPECTEDLY(hr))
2592  return hr;
2593 
2594  if (IsEqualIID(riid, IID_IContextMenu))
2595  IUnknown_SetSite(*((IUnknown**)ppvOut), (IShellView *)this);
2596 
2597  break;
2598  }
2599 
2600  TRACE("-- (%p)->(interface=%p)\n", this, *ppvOut);
2601 
2602  return hr;
2603 }
2604 
2606 {
2607  TRACE("(%p)->(%p), stub\n", this, pViewMode);
2608 
2609  if (!pViewMode)
2610  return E_INVALIDARG;
2611 
2612  *pViewMode = m_FolderSettings.ViewMode;
2613  return S_OK;
2614 }
2615 
2617 {
2618  DWORD dwStyle;
2619  TRACE("(%p)->(%u), stub\n", this, ViewMode);
2620 
2621  /* It's not redundant to check FVM_AUTO because it's a (UINT)-1 */
2622  if (((INT)ViewMode < FVM_FIRST || (INT)ViewMode > FVM_LAST) && ((INT)ViewMode != FVM_AUTO))
2623  return E_INVALIDARG;
2624 
2625  /* Windows before Vista uses LVM_SETVIEW and possibly
2626  LVM_SETEXTENDEDLISTVIEWSTYLE to set the style of the listview,
2627  while later versions seem to accomplish this through other
2628  means. */
2629  switch (ViewMode)
2630  {
2631  case FVM_ICON:
2632  dwStyle = LVS_ICON;
2633  break;
2634  case FVM_DETAILS:
2635  dwStyle = LVS_REPORT;
2636  break;
2637  case FVM_SMALLICON:
2638  dwStyle = LVS_SMALLICON;
2639  break;
2640  case FVM_LIST:
2641  dwStyle = LVS_LIST;
2642  break;
2643  default:
2644  {
2645  FIXME("ViewMode %d not implemented\n", ViewMode);
2646  dwStyle = LVS_LIST;
2647  break;
2648  }
2649  }
2650 
2651  m_ListView.ModifyStyle(LVS_TYPEMASK, dwStyle);
2652 
2653  /* This will not necessarily be the actual mode set above.
2654  This mimics the behavior of Windows XP. */
2655  m_FolderSettings.ViewMode = ViewMode;
2656 
2657  return S_OK;
2658 }
2659 
2661 {
2662  if (m_pSFParent == NULL)
2663  return E_FAIL;
2664 
2665  return m_pSFParent->QueryInterface(riid, ppv);
2666 }
2667 
2669 {
2670  PCUITEMID_CHILD pidl = _PidlByItem(iItemIndex);
2671  if (pidl)
2672  {
2673  *ppidl = ILClone(pidl);
2674  return S_OK;
2675  }
2676 
2677  *ppidl = 0;
2678  return E_INVALIDARG;
2679 }
2680 
2682 {
2683  TRACE("(%p)->(%u %p)\n", this, uFlags, pcItems);
2684 
2685  if (uFlags != SVGIO_ALLVIEW)
2686  FIXME("some flags unsupported, %x\n", uFlags & ~SVGIO_ALLVIEW);
2687 
2689 
2690  return S_OK;
2691 }
2692 
2694 {
2695  return E_NOTIMPL;
2696 }
2697 
2699 {
2700  TRACE("(%p)->(%p)\n", this, piItem);
2701 
2702  *piItem = m_ListView.GetSelectionMark();
2703 
2704  return S_OK;
2705 }
2706 
2708 {
2709  TRACE("(%p)->(%p)\n", this, piItem);
2710 
2711  *piItem = m_ListView.GetNextItem(-1, LVNI_FOCUSED);
2712 
2713  return S_OK;
2714 }
2715 
2717 {
2718  int lvIndex = LV_FindItemByPidl(pidl);
2719  if (lvIndex == -1 || ppt == NULL)
2720  return E_INVALIDARG;
2721 
2722  m_ListView.GetItemPosition(lvIndex, ppt);
2723  return S_OK;
2724 }
2725 
2727 {
2728  TRACE("(%p)->(%p)\n", this, ppt);
2729 
2730  if (!m_ListView)
2731  return S_FALSE;
2732 
2733  if (ppt)
2734  {
2735  SIZE spacing;
2736  m_ListView.GetItemSpacing(spacing);
2737 
2738  ppt->x = spacing.cx;
2739  ppt->y = spacing.cy;
2740  }
2741 
2742  return S_OK;
2743 }
2744 
2746 {
2747  return E_NOTIMPL;
2748 }
2749 
2751 {
2752  return ((m_ListView.GetStyle() & LVS_AUTOARRANGE) ? S_OK : S_FALSE);
2753 }
2754 
2756 {
2757  DWORD dwExStyle = (DWORD)m_ListView.SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
2758  return ((dwExStyle & LVS_EX_SNAPTOGRID) ? S_OK : S_FALSE);
2759 }
2760 
2762 {
2763  LVITEMW lvItem;
2764 
2765  TRACE("(%p)->(%d, %x)\n", this, iItem, dwFlags);
2766 
2767  lvItem.state = 0;
2768  lvItem.stateMask = LVIS_SELECTED;
2769 
2770  if (dwFlags & SVSI_ENSUREVISIBLE)
2771  m_ListView.EnsureVisible(iItem, 0);
2772 
2773  /* all items */
2774  if (dwFlags & SVSI_DESELECTOTHERS)
2776 
2777  /* this item */
2778  if (dwFlags & SVSI_SELECT)
2779  lvItem.state |= LVIS_SELECTED;
2780 
2781  if (dwFlags & SVSI_FOCUSED)
2782  lvItem.stateMask |= LVIS_FOCUSED;
2783 
2784  m_ListView.SetItemState(iItem, lvItem.state, lvItem.stateMask);
2785 
2786  if ((dwFlags & SVSI_EDIT) == SVSI_EDIT)
2787  m_ListView.EditLabel(iItem);
2788 
2789  return S_OK;
2790 }
2791 
2793 {
2794  /* Reset the selection */
2796 
2797  int lvIndex;
2798  for (UINT i = 0 ; i < m_cidl; i++)
2799  {
2800  lvIndex = LV_FindItemByPidl(apidl[i]);
2801  if (lvIndex != -1)
2802  {
2803  SelectItem(lvIndex, dwFlags);
2804  m_ListView.SetItemPosition(lvIndex, &apt[i]);
2805  }
2806  }
2807 
2808  return S_OK;
2809 }
2810 
2811 /**********************************************************
2812  * IShellView2 implementation
2813  */
2814 
2816 {
2817  FIXME("(%p)->(%p, %lu) stub\n", this, view_guid, view_type);
2818  return E_NOTIMPL;
2819 }
2820 
2822 {
2823  return CreateViewWindow3(view_params->psbOwner, view_params->psvPrev,
2824  SV3CVW3_DEFAULT, (FOLDERFLAGS)view_params->pfs->fFlags, (FOLDERFLAGS)view_params->pfs->fFlags,
2825  (FOLDERVIEWMODE)view_params->pfs->ViewMode, view_params->pvid, view_params->prcView, &view_params->hwndView);
2826 }
2827 
2829 {
2830  OLEMENUGROUPWIDTHS omw = { { 0, 0, 0, 0, 0, 0 } };
2831 
2832  *hwnd = NULL;
2833 
2834  TRACE("(%p)->(shlview=%p shlbrs=%p rec=%p hwnd=%p vmode=%x flags=%x)\n", this, psvPrevious, psb, prcView, hwnd, mode, flags);
2835  if (prcView != NULL)
2836  TRACE("-- left=%i top=%i right=%i bottom=%i\n", prcView->left, prcView->top, prcView->right, prcView->bottom);
2837 
2838  /* Validate the Shell Browser */
2839  if (psb == NULL || m_hWnd)
2840  return E_UNEXPECTED;
2841 
2842  if (view_flags != SV3CVW3_DEFAULT)
2843  FIXME("unsupported view flags 0x%08x\n", view_flags);
2844 
2845  /* Set up the member variables */
2846  m_pShellBrowser = psb;
2849 
2850  if (view_id)
2851  {
2852  if (IsEqualIID(*view_id, VID_LargeIcons))
2854  else if (IsEqualIID(*view_id, VID_SmallIcons))
2856  else if (IsEqualIID(*view_id, VID_List))
2858  else if (IsEqualIID(*view_id, VID_Details))
2860  else if (IsEqualIID(*view_id, VID_Thumbnails))
2862  else if (IsEqualIID(*view_id, VID_Tile))
2864  else if (IsEqualIID(*view_id, VID_ThumbStrip))
2866  else
2867  FIXME("Ignoring unrecognized VID %s\n", debugstr_guid(view_id));
2868  }
2869 
2870  /* Get our parent window */
2871  m_pShellBrowser->GetWindow(&m_hWndParent);
2872 
2873  /* Try to get the ICommDlgBrowserInterface, adds a reference !!! */
2876  {
2877  TRACE("-- CommDlgBrowser\n");
2878  }
2879 
2881  if (m_hWnd == NULL)
2882  return E_FAIL;
2883 
2884  *hwnd = m_hWnd;
2885 
2886  CheckToolbar();
2887 
2888  if (!*hwnd)
2889  return E_FAIL;
2890 
2892 
2894  UpdateWindow();
2895 
2896  if (!m_hMenu)
2897  {
2898  m_hMenu = CreateMenu();
2899  m_pShellBrowser->InsertMenusSB(m_hMenu, &omw);
2900  TRACE("-- after fnInsertMenusSB\n");
2901  }
2902 
2903  _MergeToolbar();
2904 
2905  return S_OK;
2906 }
2907 
2909 {
2910  FIXME("(%p)->(%p) stub\n", this, new_pidl);
2911  return E_NOTIMPL;
2912 }
2913 
2915 {
2916  FIXME("(%p)->(%p, %u, %p) stub\n", this, item, flags, point);
2917  return E_NOTIMPL;
2918 }
2919 
2920 /**********************************************************
2921  * IShellFolderView implementation
2922  */
2924 {
2925  FIXME("(%p)->(%ld) stub\n", this, sort);
2926  return E_NOTIMPL;
2927 }
2928 
2930 {
2931  FIXME("(%p)->(%p) stub\n", this, sort);
2932  return E_NOTIMPL;
2933 }
2934 
2936 {
2938  return S_OK;
2939 }
2940 
2942 {
2943  m_ListView.ModifyStyle(0, LVS_AUTOARRANGE);
2945  return S_OK;
2946 }
2947 
2949 {
2950  TRACE("(%p)->(%p %p)\n", this, pidl, item);
2951  *item = LV_AddItem(pidl);
2952  return (int)*item >= 0 ? S_OK : E_OUTOFMEMORY;
2953 }
2954 
2956 {
2957  TRACE("(%p)->(%p %d)\n", this, pidl, item);
2958  return Item(item, pidl);
2959 }
2960 
2962 {
2963 
2964  TRACE("(%p)->(%p %p)\n", this, pidl, item);
2965 
2966  if (pidl)
2967  {
2970  }
2971  else
2972  {
2973  *item = 0;
2975  }
2976 
2977  return S_OK;
2978 }
2979 
2981 {
2982  TRACE("(%p)->(%p)\n", this, count);
2984  return S_OK;
2985 }
2986 
2988 {
2989  FIXME("(%p)->(%d %x) stub\n", this, count, flags);
2990  return E_NOTIMPL;
2991 }
2992 
2994 {
2995  FIXME("(%p)->(%p %p %p) stub\n", this, pidl_old, pidl_new, item);
2996  return E_NOTIMPL;
2997 }
2998 
3000 {
3001  FIXME("(%p)->(%p %p) stub\n", this, pidl, item);
3002  return E_NOTIMPL;
3003 }
3004 
3006 {
3007  TRACE("(%p)->(%d)\n", this, redraw);
3009  return S_OK;
3010 }
3011 
3013 {
3014  FIXME("(%p)->(%p) stub\n", this, count);
3015  return E_NOTIMPL;
3016 }
3017 
3019 {
3020  TRACE("(%p)->(%p %p)\n", this, pidl, items);
3021 
3022  *items = GetSelections();
3023 
3024  if (*items)
3025  {
3026  *pidl = static_cast<PCUITEMID_CHILD *>(LocalAlloc(0, *items * sizeof(PCUITEMID_CHILD)));
3027  if (!*pidl)
3028  {
3029  return E_OUTOFMEMORY;
3030  }
3031 
3032  /* it's documented that caller shouldn't PIDLs, only array itself */
3033  memcpy(*pidl, m_apidl, *items * sizeof(PCUITEMID_CHILD));
3034  }
3035 
3036  return S_OK;
3037 }
3038 
3040 {
3041  if ((m_iDragOverItem == -1 || m_pCurDropTarget == NULL) &&
3043  {
3044  return S_OK;
3045  }
3046 
3047  return S_FALSE;
3048 }
3049 
3051 {
3052  if (!pt)
3053  return E_INVALIDARG;
3054 
3055  *pt = m_ptFirstMousePos;
3056  return S_OK;
3057 }
3058 
3060 {
3061  FIXME("(%p)->(%p) stub\n", this, pt);
3062  return E_NOTIMPL;
3063 }
3064 
3066 {
3067  TRACE("(%p)->(%p)\n", this, obj);
3068  return E_NOTIMPL;
3069 }
3070 
3072 {
3073  FIXME("(%p)->(%p %p) stub\n", this, pidl, pt);
3074  return E_NOTIMPL;
3075 }
3076 
3078 {
3079  FIXME("(%p)->(%p) stub\n", this, drop_target);
3080  return E_NOTIMPL;
3081 }
3082 
3084 {
3085  FIXME("(%p)->(%d) stub\n", this, move);
3086  return E_NOTIMPL;
3087 }
3088 
3090 {
3091  FIXME("(%p)->(%p) stub\n", this, obj);
3092  return E_NOTIMPL;
3093 }
3094 
3096 {
3097  FIXME("(%p)->(%p) stub\n", this, spacing);
3098  return E_NOTIMPL;
3099 }
3100 
3101 HRESULT STDMETHODCALLTYPE CDefView::SetCallback(IShellFolderViewCB *new_cb, IShellFolderViewCB **old_cb)
3102 {
3103  if (old_cb)
3104  *old_cb = m_pShellFolderViewCB.Detach();
3105 
3106  m_pShellFolderViewCB = new_cb;
3107  return S_OK;
3108 }
3109 
3111 {
3112  FIXME("(%p)->(%d) stub\n", this, flags);
3113  return E_NOTIMPL;
3114 }
3115 
3117 {
3118  TRACE("(%p)->(%p)\n", this, support);
3119  return S_OK;
3120 }
3121 
3123 {
3124  FIXME("(%p)->(%p) stub\n", this, disp);
3125  return E_NOTIMPL;
3126 }
3127 
3128 /**********************************************************
3129  * ISVOleCmdTarget_QueryStatus (IOleCommandTarget)
3130  */
3131 HRESULT WINAPI CDefView::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD *prgCmds, OLECMDTEXT *pCmdText)
3132 {
3133  FIXME("(%p)->(%p(%s) 0x%08x %p %p\n",
3134  this, pguidCmdGroup, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
3135 
3136  if (!prgCmds)
3137  return E_INVALIDARG;
3138 
3139  for (UINT i = 0; i < cCmds; i++)
3140  {
3141  FIXME("\tprgCmds[%d].cmdID = %d\n", i, prgCmds[i].cmdID);
3142  prgCmds[i].cmdf = 0;
3143  }
3144 
3145  return OLECMDERR_E_UNKNOWNGROUP;
3146 }
3147 
3148 /**********************************************************
3149  * ISVOleCmdTarget_Exec (IOleCommandTarget)
3150  *
3151  * nCmdID is the OLECMDID_* enumeration
3152  */
3153 HRESULT WINAPI CDefView::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
3154 {
3155  FIXME("(%p)->(\n\tTarget GUID:%s Command:0x%08x Opt:0x%08x %p %p)\n",
3156  this, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt, pvaIn, pvaOut);
3157 
3158  if (!pguidCmdGroup)
3159  return OLECMDERR_E_UNKNOWNGROUP;
3160 
3161  if (IsEqualCLSID(*pguidCmdGroup, m_Category))
3162  {
3163  if (nCmdID == FCIDM_SHVIEW_AUTOARRANGE)
3164  {
3165  if (V_VT(pvaIn) != VT_INT_PTR)
3166  return OLECMDERR_E_NOTSUPPORTED;
3167 
3168  TPMPARAMS params;
3169  params.cbSize = sizeof(params);
3170  params.rcExclude = *(RECT*) V_INTREF(pvaIn);
3171 
3172  if (m_hMenuViewModes)
3173  {
3174  /* Duplicate all but the last two items of the view modes menu */
3175  HMENU hmenuViewPopup = CreatePopupMenu();
3176  Shell_MergeMenus(hmenuViewPopup, m_hMenuViewModes, 0, 0, 0xFFFF, 0);
3177  DeleteMenu(hmenuViewPopup, GetMenuItemCount(hmenuViewPopup) - 1, MF_BYPOSITION);
3178  DeleteMenu(hmenuViewPopup, GetMenuItemCount(hmenuViewPopup) - 1, MF_BYPOSITION);
3179  CheckViewMode(hmenuViewPopup);
3180  TrackPopupMenuEx(hmenuViewPopup, TPM_LEFTALIGN | TPM_TOPALIGN, params.rcExclude.left, params.rcExclude.bottom, m_hWndParent, &params);
3181  ::DestroyMenu(hmenuViewPopup);
3182  }
3183 
3184  // pvaOut is VT_I4 with value 0x403 (cmd id of the new mode maybe?)
3185  V_VT(pvaOut) = VT_I4;
3186  V_I4(pvaOut) = 0x403;
3187  }
3188  }
3189 
3190  if (IsEqualIID(*pguidCmdGroup, CGID_Explorer) &&
3191  (nCmdID == 0x29) &&
3192  (nCmdexecopt == 4) && pvaOut)
3193  return S_OK;
3194 
3195  if (IsEqualIID(*pguidCmdGroup, CGID_ShellDocView) &&
3196  (nCmdID == 9) &&
3197  (nCmdexecopt == 0))
3198  return 1;
3199 
3200  return OLECMDERR_E_UNKNOWNGROUP;
3201 }
3202 
3203 /**********************************************************
3204  * ISVDropTarget implementation
3205  */
3206 
3207 /******************************************************************************
3208  * drag_notify_subitem [Internal]
3209  *
3210  * Figure out the shellfolder object, which is currently under the mouse cursor
3211  * and notify it via the IDropTarget interface.
3212  */
3213 
3214 #define SCROLLAREAWIDTH 20
3215 
3217 {
3218  LONG lResult;
3219  HRESULT hr;
3220  RECT clientRect;
3221 
3222  /* The key state on drop doesn't have MK_LBUTTON or MK_RBUTTON because it
3223  reflects the key state after the user released the button, so we need
3224  to remember the last key state when the button was pressed */
3225  m_grfKeyState = grfKeyState;
3226 
3227  /* Map from global to client coordinates and query the index of the listview-item, which is
3228  * currently under the mouse cursor. */
3229  LVHITTESTINFO htinfo = {{pt.x, pt.y}, LVHT_ONITEM};
3230  ScreenToClient(&htinfo.pt);
3231  lResult = m_ListView.HitTest(&htinfo);
3232 
3233  /* Send WM_*SCROLL messages every 250 ms during drag-scrolling */
3234  ::GetClientRect(m_ListView, &clientRect);
3235  if (htinfo.pt.x == m_ptLastMousePos.x && htinfo.pt.y == m_ptLastMousePos.y &&
3236  (htinfo.pt.x < SCROLLAREAWIDTH || htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH ||
3237  htinfo.pt.y < SCROLLAREAWIDTH || htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH ))
3238  {
3239  m_cScrollDelay = (m_cScrollDelay + 1) % 5; /* DragOver is called every 50 ms */
3240  if (m_cScrollDelay == 0)
3241  {
3242  /* Mouse did hover another 250 ms over the scroll-area */
3243  if (htinfo.pt.x < SCROLLAREAWIDTH)
3244  m_ListView.SendMessageW(WM_HSCROLL, SB_LINEUP, 0);
3245 
3246  if (htinfo.pt.x > clientRect.right - SCROLLAREAWIDTH)
3247  m_ListView.SendMessageW(WM_HSCROLL, SB_LINEDOWN, 0);
3248 
3249  if (htinfo.pt.y < SCROLLAREAWIDTH)
3250  m_ListView.SendMessageW(WM_VSCROLL, SB_LINEUP, 0);
3251 
3252  if (htinfo.pt.y > clientRect.bottom - SCROLLAREAWIDTH)
3253  m_ListView.SendMessageW(WM_VSCROLL, SB_LINEDOWN, 0);
3254  }
3255  }
3256  else
3257  {
3258  m_cScrollDelay = 0; /* Reset, if the cursor is not over the listview's scroll-area */
3259  }
3260 
3261  m_ptLastMousePos = htinfo.pt;
3262 
3263  /* We need to check if we drag the selection over itself */
3264  if (lResult != -1 && m_pSourceDataObject.p != NULL)
3265  {
3266  PCUITEMID_CHILD pidl = _PidlByItem(lResult);
3267 
3268  for (UINT i = 0; i < m_cidl; i++)
3269  {
3270  if (pidl == m_apidl[i])
3271  {
3272  /* The item that is being draged is hovering itself. */
3273  lResult = -1;
3274  break;
3275  }
3276  }
3277  }
3278 
3279  /* If we are still over the previous sub-item, notify it via DragOver and return. */
3280  if (m_pCurDropTarget && lResult == m_iDragOverItem)
3281  return m_pCurDropTarget->DragOver(grfKeyState, pt, pdwEffect);
3282 
3283  /* We've left the previous sub-item, notify it via DragLeave and Release it. */
3284  if (m_pCurDropTarget)
3285  {
3287  if (pidl)
3288  SelectItem(pidl, 0);
3289 
3290  m_pCurDropTarget->DragLeave();
3292  }
3293 
3294  m_iDragOverItem = lResult;
3295 
3296  if (lResult == -1)
3297  {
3298  /* We are not above one of the listview's subitems. Bind to the parent folder's
3299  * DropTarget interface. */
3300  hr = m_pSFParent->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget,&m_pCurDropTarget));
3301  }
3302  else
3303  {
3304  /* Query the relative PIDL of the shellfolder object represented by the currently
3305  * dragged over listview-item ... */
3306  PCUITEMID_CHILD pidl = _PidlByItem(lResult);
3307 
3308  /* ... and bind m_pCurDropTarget to the IDropTarget interface of an UIObject of this object */
3309  hr = m_pSFParent->GetUIObjectOf(m_ListView, 1, &pidl, IID_NULL_PPV_ARG(IDropTarget, &m_pCurDropTarget));
3310  }
3311 
3313 
3314  /* If anything failed, m_pCurDropTarget should be NULL now, which ought to be a save state. */
3315  if (FAILED(hr))
3316  {
3317  *pdwEffect = DROPEFFECT_NONE;
3318  return hr;
3319  }
3320 
3321  if (m_iDragOverItem != -1)
3322  {
3323  SelectItem(m_iDragOverItem, SVSI_SELECT);
3324  }
3325 
3326  /* Notify the item just entered via DragEnter. */
3327  return m_pCurDropTarget->DragEnter(m_pCurDataObject, grfKeyState, pt, pdwEffect);
3328 }
3329 
3330 HRESULT WINAPI CDefView::DragEnter(IDataObject *pDataObject, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
3331 {
3332  if (*pdwEffect == DROPEFFECT_NONE)
3333  return S_OK;
3334 
3335  /* Get a hold on the data object for later calls to DragEnter on the sub-folders */
3336  m_pCurDataObject = pDataObject;
3337 
3338  HRESULT hr = drag_notify_subitem(grfKeyState, pt, pdwEffect);
3339  if (SUCCEEDED(hr))
3340  {
3341  POINT ptClient = {pt.x, pt.y};
3342  ScreenToClient(&ptClient);
3343  ImageList_DragEnter(m_hWnd, ptClient.x, ptClient.y);
3344  }
3345 
3346  return hr;
3347 }
3348 
3350 {
3351  POINT ptClient = {pt.x, pt.y};
3352  ScreenToClient(&ptClient);
3353  ImageList_DragMove(ptClient.x, ptClient.y);
3354  return drag_notify_subitem(grfKeyState, pt, pdwEffect);
3355 }
3356 
3358 {
3360 
3361  if (m_pCurDropTarget)
3362  {
3363  m_pCurDropTarget->DragLeave();
3365  }
3366 
3367  if (m_pCurDataObject != NULL)
3368  {
3370  }
3371 
3372  m_iDragOverItem = 0;
3373 
3374  return S_OK;
3375 }
3376 
3377 HRESULT WINAPI CDefView::Drop(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
3378 {
3381 
3382  if ((IsDropOnSource(NULL) == S_OK) &&
3383  (*pdwEffect & DROPEFFECT_MOVE) &&
3385  {
3386  if (m_pCurDropTarget)
3387  {
3388  m_pCurDropTarget->DragLeave();
3390  }
3391 
3392  /* Restore the selection */
3394  for (UINT i = 0 ; i < m_cidl; i++)
3395  SelectItem(m_apidl[i], SVSI_SELECT);
3396 
3397  /* Reposition the items */
3398  int lvIndex = -1;
3399  while ((lvIndex = m_ListView.GetNextItem(lvIndex, LVNI_SELECTED)) > -1)
3400  {
3401  POINT ptItem;
3402  if (m_ListView.GetItemPosition(lvIndex, &ptItem))
3403  {
3404  ptItem.x += pt.x - m_ptFirstMousePos.x;
3405  ptItem.y += pt.y - m_ptFirstMousePos.y;
3406  m_ListView.SetItemPosition(lvIndex, &ptItem);
3407  }
3408  }
3409  }
3410  else if (m_pCurDropTarget)
3411  {
3412  m_pCurDropTarget->Drop(pDataObject, grfKeyState, pt, pdwEffect);
3414  }
3415 
3417  m_iDragOverItem = 0;
3418  return S_OK;
3419 }
3420 
3421 /**********************************************************
3422  * ISVDropSource implementation
3423  */
3424 
3426 {
3427  TRACE("(%p)\n", this);
3428 
3429  if (fEscapePressed)
3430  return DRAGDROP_S_CANCEL;
3431  else if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON))
3432  return DRAGDROP_S_DROP;
3433  else
3434  return S_OK;
3435 }
3436 
3438 {
3439  TRACE("(%p)\n", this);
3440 
3442 }
3443 
3444 /**********************************************************
3445  * ISVViewObject implementation
3446  */
3447 
3448 HRESULT WINAPI CDefView::Draw(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, BOOL (CALLBACK *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
3449 {
3450  FIXME("Stub: this=%p\n", this);
3451 
3452  return E_NOTIMPL;
3453 }
3454 
3455 HRESULT WINAPI CDefView::GetColorSet(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDevice, LOGPALETTE **ppColorSet)
3456 {
3457  FIXME("Stub: this=%p\n", this);
3458 
3459  return E_NOTIMPL;
3460 }
3461 
3462 HRESULT WINAPI CDefView::Freeze(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze)
3463 {
3464  FIXME("Stub: this=%p\n", this);
3465 
3466  return E_NOTIMPL;
3467 }
3468 
3470 {
3471  FIXME("Stub: this=%p\n", this);
3472 
3473  return E_NOTIMPL;
3474 }
3475 
3477 {
3478  FIXME("partial stub: %p 0x%08x 0x%08x %p\n", this, aspects, advf, pAdvSink);
3479 
3480  /* FIXME: we set the AdviseSink, but never use it to send any advice */
3481  m_pAdvSink = pAdvSink;
3482  m_dwAspects = aspects;
3483  m_dwAdvf = advf;
3484 
3485  return S_OK;
3486 }
3487 
3488 HRESULT WINAPI CDefView::GetAdvise(DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
3489 {
3490  TRACE("this=%p pAspects=%p pAdvf=%p ppAdvSink=%p\n", this, pAspects, pAdvf, ppAdvSink);
3491 
3492  if (ppAdvSink)
3493  {
3494  *ppAdvSink = m_pAdvSink;
3495  m_pAdvSink.p->AddRef();
3496  }
3497 
3498  if (pAspects)
3499  *pAspects = m_dwAspects;
3500 
3501  if (pAdvf)
3502  *pAdvf = m_dwAdvf;
3503 
3504  return S_OK;
3505 }
3506 
3508 {
3509  if (IsEqualIID(guidService, SID_IShellBrowser))
3510  return m_pShellBrowser->QueryInterface(riid, ppvObject);
3511  else if(IsEqualIID(guidService, SID_IFolderView))
3512  return QueryInterface(riid, ppvObject);
3513 
3514  return E_NOINTERFACE;
3515 }
3516 
3518 {
3520  HRESULT hr = S_OK;
3521 
3522  hr = IUnknown_QueryService(m_pShellBrowser, IID_IExplorerToolbar, IID_PPV_ARG(IExplorerToolbar, &ptb));
3523  if (FAILED(hr))
3524  return hr;
3525 
3526  m_Category = CGID_DefViewFrame;
3527 
3528  hr = ptb->SetCommandTarget(static_cast<IOleCommandTarget*>(this), &m_Category, 0);
3529  if (FAILED(hr))
3530  return hr;
3531 
3532  if (hr == S_FALSE)
3533  return S_OK;
3534 
3535 #if 0
3536  hr = ptb->AddButtons(&m_Category, buttonsCount, buttons);
3537  if (FAILED(hr))
3538  return hr;
3539 #endif
3540 
3541  return S_OK;
3542 }
3543 
3544 // The default processing of IShellFolderView callbacks
3546 {
3547  // TODO: SFVM_GET_CUSTOMVIEWINFO, SFVM_WINDOWCREATED
3548  TRACE("CDefView::DefMessageSFVCB uMsg=%u\n", uMsg);
3549  return E_NOTIMPL;
3550 }
3551 
3553 {
3554  HRESULT hr = E_NOTIMPL;
3555 
3557  {
3558  hr = m_pShellFolderViewCB->MessageSFVCB(uMsg, wParam, lParam);
3559  }
3560 
3561  if (hr == E_NOTIMPL)
3562  {
3563  hr = DefMessageSFVCB(uMsg, wParam, lParam);
3564  }
3565 
3566  return hr;
3567 }
3568 
3570 {
3571  return ShellObjectCreatorInit<CDefView>(pFolder, riid, ppvOut);
3572 }
3573 
3575  LPCSFV psvcbi, /* [in] shelltemplate struct */
3576  IShellView **ppsv) /* [out] IShellView pointer */
3577 {
3578  CComPtr<IShellView> psv;
3579  HRESULT hRes;
3580 
3581  TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n",
3582  psvcbi->pshf, psvcbi->pidl, psvcbi->pfnCallback,
3583  psvcbi->fvm, psvcbi->psvOuter);
3584 
3585  *ppsv = NULL;
3586  hRes = CDefView_CreateInstance(psvcbi->pshf, IID_PPV_ARG(IShellView, &psv));
3587  if (FAILED_UNEXPECTEDLY(hRes))
3588  return hRes;
3589 
3590  *ppsv = psv.Detach();
3591  return hRes;
3592 }
3593 
3595  IShellView **ppsv)
3596 {
3597  CComPtr<IShellView> psv;
3598  HRESULT hRes;
3599 
3600  if (!ppsv)
3601  return E_INVALIDARG;
3602 
3603  *ppsv = NULL;
3604 
3605  if (!pcsfv || pcsfv->cbSize != sizeof(*pcsfv))
3606  return E_INVALIDARG;
3607 
3608  TRACE("sf=%p outer=%p callback=%p\n",
3609  pcsfv->pshf, pcsfv->psvOuter, pcsfv->psfvcb);
3610 
3611  hRes = CDefView_CreateInstance(pcsfv->pshf, IID_PPV_ARG(IShellView, &psv));
3612  if (FAILED(hRes))
3613  return hRes;
3614 
3615  if (pcsfv->psfvcb)
3616  {
3618  if (SUCCEEDED(psv->QueryInterface(IID_PPV_ARG(IShellFolderView, &sfv))))
3619  {
3620  sfv->SetCallback(pcsfv->psfvcb, NULL);
3621  }
3622  }
3623 
3624  *ppsv = psv.Detach();
3625  return hRes;
3626 }
#define SHCNE_MKDIR
Definition: shlobj.h:1732
HRESULT FillViewMenu()
Definition: CDefView.cpp:1288
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3706
HMENU m_hMenuArrangeModes
Definition: CDefView.cpp:83
HRESULT CDefView_CreateInstance(IShellFolder *pFolder, REFIID riid, LPVOID *ppvOut)
Definition: CDefView.cpp:3569
HRESULT FillEditMenu()
Definition: CDefView.cpp:1271
POINT m_ptFirstMousePos
Definition: CDefView.cpp:104
#define FCIDM_SHVIEW_UNDO
Definition: shresdef.h:753
virtual HRESULT STDMETHODCALLTYPE SetItemPos(PCUITEMID_CHILD pidl, POINT *pt)
Definition: CDefView.cpp:3071
int LV_FindItemByPidl(PCUITEMID_CHILD pidl)
Definition: CDefView.cpp:778
HRESULT FillArrangeAsMenu(HMENU hmenuArrange)
Definition: CDefView.cpp:1304
DWORD_PTR GetItemData(int i)
Definition: rosctrls.h:204
disp
Definition: i386-dis.c:3181
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define NM_KILLFOCUS
Definition: commctrl.h:136
HMENU WINAPI CreateMenu(void)
Definition: menu.c:837
virtual HRESULT STDMETHODCALLTYPE SetAdvise(DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
Definition: CDefView.cpp:3476
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1608
virtual HRESULT STDMETHODCALLTYPE DestroyViewWindow()
Definition: CDefView.cpp:2431
void WINAPI DPA_DestroyCallback(HDPA hdpa, PFNDPAENUMCALLBACK enumProc, LPVOID lParam)
Definition: dpa.c:1003
BOOL GetScrollPos(int nBar)
Definition: atlwin.h:666
#define LVN_BEGINRDRAG
Definition: commctrl.h:3137
int iImage
Definition: commctrl.h:2363
#define FCIDM_SHVIEW_INVERTSELECTION
Definition: shresdef.h:758
int LV_AddItem(PCUITEMID_CHILD pidl)
Definition: CDefView.cpp:794
#define FCIDM_SHVIEW_LISTVIEW
Definition: shresdef.h:762
BOOL m_Destroyed
Definition: CDefView.cpp:112
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
WINE_DEFAULT_DEBUG_CHANNEL(shell)
HACCEL m_hAccel
Definition: CDefView.cpp:93
#define SHCNE_RMDIR
Definition: shlobj.h:1733
#define FCIDM_TB_REPORTVIEW
Definition: shresdef.h:782
UINT m_cScrollDelay
Definition: CDefView.cpp:102
virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
Definition: CDefView.cpp:3349
const GUID IID_IViewObject
BOOL MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint=TRUE)
Definition: atlwin.h:958
virtual HRESULT STDMETHODCALLTYPE GetAutoArrange()
Definition: CDefView.cpp:2750
virtual HRESULT STDMETHODCALLTYPE Refresh()
Definition: CDefView.cpp:2415
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define E_NOINTERFACE
Definition: winerror.h:2364
HDPA WINAPI DPA_Create(INT nGrow)
Definition: dpa.c:950
Definition: compat.h:1948
#define LVN_BEGINDRAG
Definition: commctrl.h:3136
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
HRESULT _GetSnapToGrid()
Definition: CDefView.cpp:2755
#define MF_BYCOMMAND
Definition: winuser.h:202
HRESULT WINAPI CDefViewDual_Constructor(REFIID riid, LPVOID *ppvOut)
HRESULT WINAPI SHLimitInputEdit(HWND hWnd, IShellFolder *psf)
Definition: shellord.c:2689
#define LVSIL_SMALL
Definition: commctrl.h:2295
virtual HRESULT STDMETHODCALLTYPE Select(UINT flags)
Definition: CDefView.cpp:3110
virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
Definition: CDefView.cpp:3507
long y
Definition: polytest.cpp:48
#define FCIDM_SHVIEW_SNAPTOGRID
Definition: shresdef.h:766
#define WM_GETDLGCODE
Definition: winuser.h:1671
#define LVM_GETEDITCONTROL
Definition: commctrl.h:2538
UINT WINAPI Shell_MergeMenus(HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags)
Definition: shlmenu.c:857
#define WM_CONTEXTMENU
Definition: richedit.h:64
HRESULT OpenSelectedItems()
Definition: CDefView.cpp:1418
LRESULT OnPrintClient(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: CDefView.cpp:1072
#define FCIDM_SHVIEW_AUTOARRANGE
Definition: shresdef.h:765
#define IDS_OBJECTS_SELECTED
Definition: shresdef.h:258
HRESULT hr
Definition: shlfolder.c:183
#define error(str)
Definition: mkdosfs.c:1605
GLint x0
Definition: linetemp.h:95
static HMENU hmenu
Definition: win.c:66
IShellFolderViewCB * psfvcb
Definition: shlobj.h:1285
Definition: scsiwmi.h:51
#define RGB(r, g, b)
Definition: precomp.h:62
#define NOERROR
Definition: winerror.h:2354
HRESULT WINAPI Initialize(IShellFolder *shellFolder)
Definition: CDefView.cpp:414
BOOL WINAPI InsertMenuW(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
static const WCHAR SV_CLASS_NAME[]
Definition: CDefView.cpp:45
#define MK_LBUTTON
Definition: winuser.h:2342
long x
Definition: polytest.cpp:48
EXTERN_C BOOL WINAPI SHChangeNotification_Unlock(HANDLE hLock)
BOOL m_isEditing
Definition: CDefView.cpp:109
#define LVIR_ICON
Definition: commctrl.h:2469
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2036
#define LVS_SHOWSELALWAYS
Definition: commctrl.h:2263
virtual HRESULT STDMETHODCALLTYPE CreateViewWindow2(LPSV2CVW2_PARAMS view_params)
Definition: CDefView.cpp:2821
int GetSelectionMark()
Definition: rosctrls.h:156
#define SB_VERT
Definition: winuser.h:553
FOLDERSETTINGS m_FolderSettings
Definition: CDefView.cpp:81
LPFNVIEWCALLBACK pfnCallback
Definition: shlobj.h:1208
#define FCIDM_MENU_VIEW_SEP_OPTIONS
Definition: shlobj.h:560
#define KEY_READ
Definition: nt_native.h:1023
virtual HRESULT STDMETHODCALLTYPE MoveIcons(IDataObject *obj)
Definition: CDefView.cpp:3065
struct LISTVIEW_SORT_INFO * LPLISTVIEW_SORT_INFO
LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: CDefView.cpp:1688
#define pt(x, y)
Definition: drawing.c:79
#define TPM_LEFTALIGN
Definition: winuser.h:2352
#define GET_WM_COMMAND_ID(wp, lp)
Definition: CDefView.cpp:360
virtual HRESULT STDMETHODCALLTYPE GetSelectedCount(UINT *count)
Definition: CDefView.cpp:3012
#define WM_INITMENUPOPUP
Definition: winuser.h:1728
REFIID riid
Definition: precomp.h:44
#define SPI_SETDESKWALLPAPER
Definition: winuser.h:1351
static BOOL ILIsParentOrSpecialParent(PCIDLIST_ABSOLUTE pidl1, PCIDLIST_ABSOLUTE pidl2)
Definition: CDefView.cpp:2131
#define LVS_REPORT
Definition: commctrl.h:2258
virtual WNDPROC GetWindowProc()
Definition: CDefView.cpp:293
HWND Create(HWND hWndParent, _U_RECT rect=NULL, LPCTSTR szWindowName=NULL, DWORD dwStyle=0, DWORD dwExStyle=0, _U_MENUorID MenuOrID=0U, LPVOID lpCreateParam=NULL)
Definition: atlwin.h:1637
#define LVN_GETDISPINFOA
Definition: commctrl.h:3149
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)
#define TPM_RETURNCMD
Definition: winuser.h:2362
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
Definition: _algo.c:993
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define HKEY_CURRENT_USER
Definition: winreg.h:11
GLint dy
Definition: linetemp.h:97
virtual HRESULT STDMETHODCALLTYPE GetView(SHELLVIEWID *view_guid, ULONG view_type)
Definition: CDefView.cpp:2815
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
PCUITEMID_CHILD _PidlByItem(int i)
Definition: CDefView.cpp:765
#define SB_HORZ
Definition: winuser.h:552
#define U(x)
Definition: wordpad.c:45
Definition: shlobj.h:1201
LRESULT OnShowWindow(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: CDefView.cpp:1008
#define LVN_ITEMCHANGED
Definition: commctrl.h:3127
#define NM_RELEASEDCAPTURE
Definition: commctrl.h:141
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
BOOL WINAPI ImageList_DragMove(INT x, INT y)
Definition: imagelist.c:1070
void SetRedraw(BOOL redraw)
Definition: rosctrls.h:27
#define FCIDM_SHVIEW_OPEN
Definition: shresdef.h:777
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1746
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1288
IShellBrowser * psbOwner
Definition: shobjidl.idl:789
static HDC
Definition: imagelist.c:92
CComPtr< ICommDlgBrowser > m_pCommDlgBrowser
Definition: CDefView.cpp:77
#define CALLBACK
Definition: compat.h:27
#define SHCNE_INTERRUPT
Definition: shlobj.h:1754
#define MF_STRING
Definition: winuser.h:138
#define CLR_INVALID
Definition: wingdi.h:882
HWND hWnd
Definition: settings.c:17
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT FillList()
Definition: CDefView.cpp:905
BOOL SetWindowPos(HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags)
Definition: atlwin.h:1220
LONG top
Definition: windef.h:307
static INT CALLBACK ListViewCompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
Definition: CDefView.cpp:715
#define LVN_GETDISPINFOW
Definition: commctrl.h:3150
HANDLE HWND
Definition: compat.h:13
IShellView * psvOuter
Definition: shlobj.h:1284
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
virtual HRESULT STDMETHODCALLTYPE GetDefaultSpacing(POINT *ppt)
Definition: CDefView.cpp:2745
int GetNextItem(int i, WORD flags)
Definition: rosctrls.h:161
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define WM_SHOWWINDOW
Definition: winuser.h:1610
virtual HRESULT STDMETHODCALLTYPE SetCurrentViewMode(UINT ViewMode)
Definition: CDefView.cpp:2616
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70
#define GetRValue(quad)
Definition: precomp.h:64
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define LVIS_CUT
Definition: commctrl.h:2316
#define HWND_TOP
Definition: winuser.h:1193
CComPtr< IShellFolderViewDual > m_pShellFolderViewDual
Definition: CDefView.cpp:78
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
#define HDF_SORTUP
Definition: commctrl.h:720
#define FCIDM_SHVIEWFIRST
Definition: shlobj.h:507
WPARAM wParam
Definition: winuser.h:3091
LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: CDefView.cpp:1721
BOOL(CALLBACK * LPFNADDPROPSHEETPAGE)(HPROPSHEETPAGE, LPARAM)
Definition: prsht.h:327
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define COLOR_DESKTOP
Definition: winuser.h:904
#define CSIDL_BITBUCKET
Definition: shlobj.h:2022
HRESULT WINAPI RegisterDragDrop(HWND hwnd, LPDROPTARGET pDropTarget)
Definition: ole2.c:557
#define LVHT_ONITEM
Definition: commctrl.h:2493
virtual HRESULT STDMETHODCALLTYPE Item(int iItemIndex, PITEMID_CHILD *ppidl)
Definition: CDefView.cpp:2668
static int int const SCRIPT_CONTROL const SCRIPT_STATE SCRIPT_ITEM ULONG int * pcItems
Definition: usp10.c:62
BOOL EnsureVisible(int i, BOOL fPartialOK)
Definition: rosctrls.h:146
#define LVNI_SELECTED
Definition: commctrl.h:2420
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:535
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:212
view_type
HRESULT FillFileMenu()
Definition: CDefView.cpp:1234
#define WS_CHILD
Definition: pedump.c:617
HMENU m_hMenu
Definition: CDefView.cpp:82
virtual HRESULT STDMETHODCALLTYPE Rearrange(LPARAM sort)
Definition: CDefView.cpp:2923
LONG left
Definition: windef.h:306
virtual HRESULT STDMETHODCALLTYPE GetSpacing(POINT *ppt)
Definition: CDefView.cpp:2726
virtual HRESULT STDMETHODCALLTYPE GetItemObject(UINT uItem, REFIID riid, void **ppv)
Definition: CDefView.cpp:2554
UINT uFlags
Definition: api.c:59
#define LVM_SETCALLBACKMASK
Definition: commctrl.h:2415
int GetItemCount()
Definition: rosctrls.h:121
#define WS_CLIPCHILDREN
Definition: pedump.c:619
virtual HRESULT STDMETHODCALLTYPE GetFocusedItem(int *piItem)
Definition: CDefView.cpp:2707
virtual HRESULT STDMETHODCALLTYPE RemoveObject(PITEMID_CHILD pidl, UINT *item)
Definition: CDefView.cpp:2961
#define SID_IFolderView
virtual HRESULT STDMETHODCALLTYPE EnableModeless(BOOL fEnable)
Definition: CDefView.cpp:2371
LONG right
Definition: windef.h:308
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1729
#define HDITEM
Definition: commctrl.h:693
HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv, IShellView **ppsv)
Definition: CDefView.cpp:3594
VOID WINAPI ImageList_EndDrag(void)
Definition: imagelist.c:1847
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
#define WM_NCCREATE
Definition: winuser.h:1665
HWND Create(HWND hWndParent, _U_RECT rect, LPCTSTR szWindowName=NULL, DWORD dwStyle=0, DWORD dwExStyle=0, _U_MENUorID MenuOrID=0U, LPVOID lpCreateParam=NULL)
Definition: rosctrls.h:8
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define COLOR_WINDOW
Definition: winuser.h:908
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:57
#define FCIDM_SHVIEW_PROPERTIES
Definition: shresdef.h:749
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1494
HRESULT WINAPI RevokeDragDrop(HWND hwnd)
Definition: ole2.c:639
virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator(MSG *pmsg)
Definition: CDefView.cpp:2355
DWORD WINAPI GetSysColor(_In_ int)
POINTL point
Definition: edittest.c:50
WPARAM wParam
Definition: combotst.c:138
#define LVS_SHAREIMAGELISTS
Definition: commctrl.h:2266
#define SFVM_GET_CUSTOMVIEWINFO
#define FCIDM_MENU_EDIT
Definition: shlobj.h:558
UINT stateMask
Definition: commctrl.h:2360
#define DRAGDROP_S_CANCEL
Definition: winerror.h:2647
DWORD dwAttributes
Definition: vdmdbg.h:34
virtual HRESULT STDMETHODCALLTYPE GetObject(PITEMID_CHILD *pidl, UINT item)
Definition: CDefView.cpp:2955
struct tagNMHDR * LPNMHDR
#define SFVM_SIZE
Definition: shlobj.h:1264
#define WM_SETTINGCHANGE
Definition: winuser.h:1611
#define WM_PRINTCLIENT
Definition: richedit.h:70
#define V_I4(A)
Definition: oleauto.h:247
virtual HRESULT STDMETHODCALLTYPE DragLeave()
Definition: CDefView.cpp:3357
CComPtr< IShellFolder2 > m_pSF2Parent
Definition: CDefView.cpp:74
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
Definition: CDefView.cpp:3377
BOOL SetTextColor(COLORREF cr)
Definition: rosctrls.h:42
DWORD SetExtendedListViewStyle(DWORD dw, DWORD dwMask=0)
Definition: rosctrls.h:47
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define LVIF_TEXT
Definition: commctrl.h:2305
int cchTextMax
Definition: commctrl.h:2362
#define FCIDM_SHVIEW_INSERTLINK
Definition: shresdef.h:754
SHELLVIEWID const * pvid
Definition: shobjidl.idl:791
UINT code
Definition: winuser.h:3134
virtual HRESULT STDMETHODCALLTYPE UIActivate(UINT uState)
Definition: CDefView.cpp:2378
#define FCIDM_SHVIEW_REFRESH
Definition: shresdef.h:775
#define FCIDM_BROWSERLAST
Definition: shlobj.h:550
IShellView * psvOuter
Definition: shlobj.h:1205
WORD unused[29]
Definition: crypt.c:1155
const DWORD DROPEFFECT_NONE
Definition: oleidl.idl:929
#define TPM_RIGHTBUTTON
Definition: winuser.h:2355
HRESULT WINAPI SHForwardContextMenuMsg(IUnknown *pUnk, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pResult, BOOL useIContextMenu2)
Definition: rosordinal.c:11
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define MIIM_SUBMENU
Definition: winuser.h:718
LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: CDefView.cpp:1863
#define FCIDM_SHVIEW_ARRANGE
Definition: shresdef.h:746
BOOL WINAPI ImageList_DragEnter(HWND hwndLock, INT x, INT y)
Definition: imagelist.c:958
#define WM_KEYFIRST
Definition: winuser.h:1696
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
GLenum GLint GLuint mask
Definition: glext.h:6028
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
CComPtr< IShellFolderViewCB > m_pShellFolderViewCB
Definition: CDefView.cpp:75
BOOL DeleteAllItems()
Definition: rosctrls.h:126
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
BOOL CreateList()
Definition: CDefView.cpp:522
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
#define SHV_CHANGE_NOTIFY
Definition: CDefView.cpp:54
const PCUITEMID_CHILD * PCUITEMID_CHILD_ARRAY
Definition: shtypes.idl:71
GLenum const GLfloat * params
Definition: glext.h:5645
SFVM_CUSTOMVIEWINFO_DATA m_viewinfo_data
Definition: CDefView.cpp:113
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
virtual HRESULT STDMETHODCALLTYPE HandleRename(LPCITEMIDLIST new_pidl)
Definition: CDefView.cpp:2908
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SHCNE_ALLEVENTS
Definition: shlobj.h:1753
long LONG
Definition: pedump.c:60
CComPtr< IDataObject > m_pCurDataObject
Definition: CDefView.cpp:100
#define LVN_ITEMACTIVATE
Definition: commctrl.h:3143
BOOL GetItemPosition(int nItem, POINT *pPoint)
Definition: rosctrls.h:231
virtual HRESULT STDMETHODCALLTYPE SelectItem(PCUITEMID_CHILD pidlItem, SVSIF uFlags)
HRESULT OnStateChange(UINT uFlags)
Definition: CDefView.cpp:454
short SHORT
Definition: pedump.c:59
#define FCIDM_SHVIEW_INSERT
Definition: shresdef.h:752
LRESULT OnSettingChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: CDefView.cpp:2272
#define MF_BYPOSITION
Definition: winuser.h:203
#define LVS_EX_SNAPTOGRID
Definition: commctrl.h:2744
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
int iSubItem
Definition: commctrl.h:2358
DWORD WINAPI SHMenuIndexFromID(HMENU hMenu, UINT uID)
Definition: ordinal.c:4391
HRESULT CDefViewBckgrndMenu_CreateInstance(IShellFolder *psf, REFIID riid, void **ppv)
#define debugstr_w
Definition: kernel32.h:32
#define TPM_TOPALIGN
Definition: winuser.h:2358
#define HDI_FORMAT
Definition: commctrl.h:701
HRESULT WINAPI IUnknown_SetSite(IUnknown *obj, IUnknown *site)
Definition: ordinal.c:1404
BOOL GetClientRect(LPRECT lpRect) const
Definition: atlwin.h:507
LPARAM lParam
Definition: commctrl.h:2364
#define FIXME(fmt,...)
Definition: debug.h:111
#define Header_GetItem(hwndHD, i, phdi)
Definition: commctrl.h:747
static PVOID ptr
Definition: dispmode.c:27
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
HMENU m_hContextMenu
Definition: CDefView.cpp:85
PIDLIST_ABSOLUTE m_pidlParent
Definition: CDefView.cpp:90
#define SFVM_LISTREFRESHED
BOOL Arrange(UINT nCode)
Definition: rosctrls.h:241
#define LVS_ALIGNLEFT
Definition: commctrl.h:2276
ULONG Release()
#define TB_ENABLEBUTTON
Definition: commctrl.h:1038
#define S_FALSE
Definition: winerror.h:2357
#define VK_SHIFT
Definition: winuser.h:2177
#define E_INVALIDARG
Definition: ddrawi.h:101
LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: CDefView.cpp:1698
HRESULT CheckViewMode(HMENU hmenuView)
Definition: CDefView.cpp:1344
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
CComPtr< IAdviseSink > m_pAdvSink
Definition: CDefView.cpp:96
unsigned char BOOLEAN
static INT CALLBACK fill_list(LPVOID ptr, LPVOID arg)
Definition: CDefView.cpp:892
#define SHCNRF_InterruptLevel
Definition: shlobj.h:1774
static VOID NTAPI BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_ PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:49
smooth NULL
Definition: ftsmooth.c:416
#define LVA_SNAPTOGRID
Definition: commctrl.h:2526
HRESULT InvokeContextMenuCommand(UINT uCommand)
Definition: CDefView.cpp:1393
#define LVIS_SELECTED
Definition: commctrl.h:2315
BOOL GetItem(LV_ITEM *pitem)
Definition: rosctrls.h:106
ULONG m_hNotify
Definition: CDefView.cpp:92
HRESULT WINAPI SHCreateShellFolderViewEx(LPCSFV psvcbi, IShellView **ppsv)
Definition: CDefView.cpp:3574
HRESULT DefMessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CDefView.cpp:3545
LONG cx
Definition: windef.h:334
#define MF_SEPARATOR
Definition: winuser.h:137
LONG_PTR LPARAM
Definition: windef.h:208
#define LVS_AUTOARRANGE
Definition: commctrl.h:2268
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
#define GetBValue(quad)
Definition: precomp.h:66
CListView m_ListView
Definition: CDefView.cpp:79
virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
Definition: CDefView.cpp:3425
#define IDS_OBJECTS
Definition: shresdef.h:257
virtual HRESULT STDMETHODCALLTYPE AddObject(PITEMID_CHILD pidl, UINT *item)
Definition: CDefView.cpp:2948
#define LVNI_FOCUSED
Definition: commctrl.h:2419
#define SCROLLAREAWIDTH
Definition: CDefView.cpp:3214
#define CLR_NONE
Definition: commctrl.h:315
HRESULT _MergeToolbar()
Definition: CDefView.cpp:3517
FOLDERVIEWMODE
Definition: shobjidl.idl:663
#define LVS_LIST
Definition: commctrl.h:2260
#define WS_CHILDWINDOW
Definition: pedump.c:639
LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: CDefView.cpp:1738
BOOLEAN LV_RenameItem(PCUITEMID_CHILD pidlOld, PCUITEMID_CHILD pidlNew)
Definition: CDefView.cpp:828
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
#define debugstr_guid
Definition: kernel32.h:35
#define GetGValue(quad)
Definition: precomp.h:65
#define MK_RBUTTON
Definition: winuser.h:2343
#define V_INTREF(A)
Definition: oleauto.h:252
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: fontsub.cpp:1519
CComPtr< IDataObject > m_pSourceDataObject
Definition: CDefView.cpp:98
virtual HRESULT STDMETHODCALLTYPE QuerySupport(UINT *support)
Definition: CDefView.cpp:3116
virtual HRESULT STDMETHODCALLTYPE Freeze(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze)
Definition: CDefView.cpp:3462
#define FCIDM_SHVIEWLAST
Definition: shlobj.h:541
#define WM_DESTROY
Definition: winuser.h:1591
UINT GetSelections()
Definition: CDefView.cpp:1365
HWND EditLabel(int i)
Definition: rosctrls.h:151
#define FCIDM_SHVIEW_NEWFOLDER
Definition: shresdef.h:773
#define MIIM_ID
Definition: winuser.h:717
PCIDLIST_ABSOLUTE pidl
Definition: shlobj.h:1206
virtual HRESULT STDMETHODCALLTYPE Draw(DWORD dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds, BOOL(STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue), ULONG_PTR dwContinue)
Definition: CDefVi