ReactOS  0.4.13-dev-455-g28ed234
shellbrowser.h
Go to the documentation of this file.
1 /*
2  * Copyright 2003, 2004, 2005 Martin Fuchs
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 
20  //
21  // Explorer clone
22  //
23  // shellbrowser.h
24  //
25  // Martin Fuchs, 23.07.2003
26  //
27 
28 #include "../utility/treedroptarget.h"
29 #include "../utility/shellbrowserimpl.h"
30 
31 #include <memory>
32 
35 {
37 
42  {
43  }
44 
47 
48  int _open_mode; //OPEN_WINDOW_MODE
49 };
50 
51 
53 {
54  virtual ~BrowserCallback() {}
55  virtual void entry_selected(Entry* entry) = 0;
56 };
57 
58 
60 struct ShellBrowser : public IShellBrowserImpl,
61  public IComSrvBase<IShellFolderViewCB, ShellBrowser>, public SimpleComObject
62 {
63  ShellBrowser(HWND hwnd, HWND hwndFrame, HWND left_hwnd, WindowHandle& right_hwnd, ShellPathInfo& create_info,
65  virtual ~ShellBrowser();
66 
67  //IOleWindow
69  {
70  *lphwnd = _hwnd;
71  return S_OK;
72  }
73 
74  //IShellBrowser
76  {
78  *ppshv = _pShellView;
79  return S_OK;
80  }
81 
83  {
84  if (!lphwnd)
85  return E_POINTER;
86 
87  if (id == FCW_TREE) {
88  *lphwnd = _left_hwnd;
89  return S_OK;
90  }
91 
93 
94  if (hwnd) {
95  *lphwnd = hwnd;
96  return S_OK;
97  }
98 
99  return E_NOTIMPL;
100  }
101 
103  {
104  if (!pret)
105  return E_POINTER;
106 
107  HWND hstatusbar = (HWND)SendMessage(_hwndFrame, PM_GET_CONTROLWINDOW, id, 0);
108 
109  if (hstatusbar) {
110  *pret = ::SendMessage(hstatusbar, uMsg, wParam, lParam);
111  return S_OK;
112  }
113 
114  return E_NOTIMPL;
115  }
116 
117  const Root& get_root() const {return _root;}
118 
119  void OnTreeGetDispInfo(int idCtrl, LPNMHDR pnmh);
120  void OnTreeItemExpanding(int idCtrl, LPNMTREEVIEW pnmtv);
121  void OnTreeItemRClick(int idCtrl, LPNMHDR pnmh);
122  void OnTreeItemSelected(int idCtrl, LPNMTREEVIEW pnmtv);
123 
124  void Init();
125 
126  int InsertSubitems(HTREEITEM hParentItem, Entry* entry, IShellFolder* pParentFolder);
127 
128  bool jump_to_pidl(LPCITEMIDLIST pidl);
129 
131 
133  HTREEITEM select_entry(HTREEITEM hitem, Entry* entry, bool expand=true);
134 
135  bool select_folder(Entry* entry, bool expand);
136 
137  // for SDIMainFrame
138  void jump_to(LPCITEMIDLIST pidl);
139 
140  void invalidate_cache();
141 
142  bool TranslateAccelerator(LPMSG lpmsg);
143 
144 protected:
148  WindowHandle& _right_hwnd;
153 
155 
156  IShellView* _pShellView; // current hosted shellview
158 
160 
163 
165 
166  void InitializeTree();
167  bool InitDragDrop();
168 
170 
171  // IShellFolderViewCB
173 
175 
176  int get_image_idx(int icon_id);
177 
178  void refresh();
179 };
180 
181 
182 #define C_DRIVE_STR TEXT("C:\\")
183 
184  // work around GCC's wide string constant bug
185 #ifdef __GNUC__
186 extern const LPCTSTR C_DRIVE;
187 #else
188 #define C_DRIVE C_DRIVE_STR
189 #endif
190 
191 template<typename BASE> struct ShellBrowserChildT
192  : public BASE, public BrowserCallback
193 {
194  typedef BASE super;
195 
196  // constructor for SDIMainFrame
198  : super(hwnd)
199  {
200  }
201 
202  // constructor for MDIShellBrowserChild
204  : super(hwnd, info)
205  {
206  }
207 
208 protected:
210 
212  {
213  switch(nmsg) {
215  return (LRESULT)&*_shellBrowser;
216 
217  case WM_GETISHELLBROWSER: // for Registry Explorer Plugin
218  return (LRESULT)static_cast<IShellBrowser*>(&*_shellBrowser);
219 
220  default:
221  return super::WndProc(nmsg, wparam, lparam);
222  }
223 
224  return 0;
225  }
226 
227  int Notify(int id, NMHDR* pnmh)
228  {
229  if (_shellBrowser.get())
230  switch(pnmh->code) {
231  case TVN_GETDISPINFO: _shellBrowser->OnTreeGetDispInfo(id, pnmh); break;
234  case NM_RCLICK: _shellBrowser->OnTreeItemRClick(id, pnmh); break;
235  default: return super::Notify(id, pnmh);
236  }
237  else
238  return super::Notify(id, pnmh);
239 
240  return 0;
241  }
242 };
243 
244 
245 #ifndef _NO_MDI
246 
248  ShellBrowserChildT<ChildWindow>
249  >
250 {
251  typedef ExtContextMenuHandlerT<
253  > super;
254 
256 
258 
260 
261  virtual String jump_to_int(LPCTSTR url);
262 
263 protected:
266 
268 
269  void update_shell_browser();
270 
271  // interface BrowserCallback
272  virtual void entry_selected(Entry* entry);
273 };
274 
275 #endif
information structure for creation of MDIShellBrowserChild
Definition: filechild.h:44
ShellBrowserChildT(HWND hwnd, const ShellChildWndInfo &info)
Definition: shellbrowser.h:203
BOOL WINAPI SHIM_OBJ_NAME() Notify(DWORD fdwReason, PVOID ptr)
bool TranslateAccelerator(LPMSG lpmsg)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT OnDefaultCommand(LPIDA pida)
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
Definition: fci.c:115
static MDIShellBrowserChild * create(const ShellChildWndInfo &info)
virtual HRESULT STDMETHODCALLTYPE MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam)
shell view callback
WindowHandle & _right_hwnd
Definition: shellbrowser.h:148
HIMAGELIST _himl_old
Definition: shellbrowser.h:151
ShellPathInfo(const ShellChildWndInfo &info)
Definition: shellbrowser.h:38
LRESULT Init(LPCREATESTRUCT)
Implementation of IShellBrowserImpl interface in explorer child windows.
Definition: ieframe.h:84
information structure to hold current shell folder information
Definition: shellbrowser.h:34
HTREEITEM _last_sel
Definition: shellbrowser.h:159
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
HANDLE HWND
Definition: compat.h:13
#define LPNMTREEVIEW
Definition: commctrl.h:3615
shell folder entry
Definition: shellfs.h:53
ExtContextMenuHandlerT< ShellBrowserChildT< ChildWindow > > super
Definition: shellbrowser.h:253
IShellFolder smart pointer.
Definition: shellclasses.h:593
int InsertSubitems(HTREEITEM hParentItem, Entry *entry, IShellFolder *pParentFolder)
ShellBrowserChildT(HWND hwnd)
Definition: shellbrowser.h:197
static WCHAR String[]
Definition: stringtable.c:55
UINT_PTR WPARAM
Definition: windef.h:207
virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND *lphwnd)
Definition: shellbrowser.h:68
WPARAM wParam
Definition: combotst.c:138
map< int, int > _image_map
Definition: shellbrowser.h:174
void invalidate_cache()
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
Definition: shellbrowser.h:211
UINT code
Definition: winuser.h:3112
void OnTreeItemExpanding(int idCtrl, LPNMTREEVIEW pnmtv)
CtxMenuInterfaces & _cm_ifs
Definition: shellbrowser.h:164
BrowserCallback * _callback
Definition: shellbrowser.h:152
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
virtual HRESULT STDMETHODCALLTYPE QueryActiveShellView(IShellView **ppshv)
Definition: shellbrowser.h:75
void OnTreeItemSelected(int idCtrl, LPNMTREEVIEW pnmtv)
Implementation of IShellBrowser and ICommDlgBrowser interfaces for explorer child windows (see ShellB...
LONG_PTR LPARAM
Definition: windef.h:208
void OnTreeItemRClick(int idCtrl, LPNMHDR pnmh)
bool jump_to_pidl(LPCITEMIDLIST pidl)
virtual void entry_selected(Entry *entry)
_Tp * get() const _STLP_NOTHROW
Definition: _auto_ptr.h:66
static BOOL expand(LPINT ac, LPTSTR **arg, LPCTSTR pattern)
Definition: misc.c:215
ShellPath _root_shell_path
Definition: shellbrowser.h:46
HIMAGELIST _himl
Definition: shellbrowser.h:150
OLE drop target for tree controls.
#define C_DRIVE
Definition: shellbrowser.h:188
root entry for file system trees
Definition: entries.h:148
ShellFolder _folder
Definition: shellbrowser.h:154
#define PM_GET_SHELLBROWSER_PTR
Definition: explorer.h:62
LONG HRESULT
Definition: typedefs.h:77
bool select_folder(Entry *entry, bool expand)
static const WCHAR url[]
Definition: encode.c:1432
#define TVN_GETDISPINFO
Definition: commctrl.h:3708
#define TVN_SELCHANGED
Definition: commctrl.h:3707
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
static DWORD cb
Definition: integrity.c:41
ShellChildWndInfo _create_info
Definition: shellbrowser.h:264
ULONG AddRef()
#define BASE
Definition: adler32.c:10
void UpdateFolderView(IShellFolder *folder)
#define PM_GET_CONTROLWINDOW
Definition: explorer.h:64
ShellPath _shell_path
Definition: shellbrowser.h:45
int Notify(int id, NMHDR *pnmh)
Definition: shellbrowser.h:227
uint32_t entry
Definition: isohybrid.c:63
void OnTreeGetDispInfo(int idCtrl, LPNMHDR pnmh)
IComSrvBase< IShellFolderViewCB, ShellBrowser > super
Definition: shellbrowser.h:169
#define WM_GETISHELLBROWSER
Definition: filedlg.c:127
GLenum mode
Definition: glext.h:6217
IShellView * _pShellView
Definition: shellbrowser.h:156
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
const Root & get_root() const
Definition: shellbrowser.h:117
virtual void entry_selected(Entry *entry)=0
MDIShellBrowserChild(HWND hwnd, const ShellChildWndInfo &info)
virtual HRESULT STDMETHODCALLTYPE SendControlMsg(UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pret)
Definition: shellbrowser.h:102
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
Definition: solitaire.cpp:598
virtual ~BrowserCallback()
Definition: shellbrowser.h:54
#define TVN_ITEMEXPANDING
Definition: commctrl.h:3710
#define S_OK
Definition: intsafe.h:59
HTREEITEM select_entry(HTREEITEM hitem, Entry *entry, bool expand=true)
ShellPathInfo _shellpath_info
Definition: shellbrowser.h:265
virtual ~ShellBrowser()
#define NM_RCLICK
Definition: commctrl.h:133
void InitializeTree()
#define E_NOTIMPL
Definition: ddrawi.h:99
unsigned int UINT
Definition: ndis.h:50
ShellBrowser(HWND hwnd, HWND hwndFrame, HWND left_hwnd, WindowHandle &right_hwnd, ShellPathInfo &create_info, BrowserCallback *cb, CtxMenuInterfaces &cm_ifs)
ShellPathInfo & _create_info
Definition: shellbrowser.h:149
ShellDirectory * _cur_dir
Definition: shellbrowser.h:162
#define SendMessage
Definition: winuser.h:5709
bool InitDragDrop()
virtual HRESULT STDMETHODCALLTYPE GetControlWindow(UINT id, HWND *lphwnd)
Definition: shellbrowser.h:82
TreeDropTarget * _pDropTarget
Definition: shellbrowser.h:157
void jump_to(LPCITEMIDLIST pidl)
LONG_PTR LRESULT
Definition: windef.h:209
#define E_POINTER
Definition: winerror.h:2365
LPARAM lParam
Definition: combotst.c:139
wrapper class for item ID lists
Definition: shellclasses.h:651
auto_ptr< ShellBrowser > _shellBrowser
Definition: shellbrowser.h:209
base of all file and directory entries
Definition: entries.h:82
virtual String jump_to_int(LPCTSTR url)
ShellPathInfo(int mode=0)
Definition: shellbrowser.h:36
Definition: shlobj.h:490
static UINT WPARAM wparam
Definition: combo.c:716
int get_image_idx(int icon_id)