ReactOS 0.4.15-dev-7961-gdcf9eb0
toolsband.cpp
Go to the documentation of this file.
1/*
2 * ReactOS Explorer
3 *
4 * Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22Implements the toolbar band of a cabinet window
23*/
24
25#include "precomp.h"
26
28 public CWindowImpl<CToolsBand, CWindow, CControlWinTraits>,
29 public CComObjectRootEx<CComMultiThreadModelNoCS>,
30 public IDeskBand,
31 public IObjectWithSite,
32 public IInputObject,
33 public IPersistStream
34{
35private:
39public:
40 CToolsBand();
41 virtual ~CToolsBand();
42public:
43 // *** IDeskBand methods ***
44 STDMETHOD(GetBandInfo)(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO* pdbi) override;
45
46 // *** IObjectWithSite methods ***
47 STDMETHOD(SetSite)(IUnknown* pUnkSite) override;
48 STDMETHOD(GetSite)(REFIID riid, void **ppvSite) override;
49
50 // *** IOleWindow methods ***
51 STDMETHOD(GetWindow)(HWND *lphwnd) override;
52 STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode) override;
53
54 // *** IDockingWindow methods ***
56 STDMETHOD(ResizeBorderDW)(const RECT* prcBorder, IUnknown* punkToolbarSite, BOOL fReserved) override;
57 STDMETHOD(ShowDW)(BOOL fShow) override;
58
59 // *** IInputObject methods ***
60 STDMETHOD(HasFocusIO)() override;
61 STDMETHOD(TranslateAcceleratorIO)(LPMSG lpMsg) override;
62 STDMETHOD(UIActivateIO)(BOOL fActivate, LPMSG lpMsg) override;
63
64 // *** IPersist methods ***
65 STDMETHOD(GetClassID)(CLSID *pClassID) override;
66
67 // *** IPersistStream methods ***
68 STDMETHOD(IsDirty)() override;
69 STDMETHOD(Load)(IStream *pStm) override;
70 STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty) override;
71 STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize) override;
72
73 // message handlers
74 LRESULT OnGetButtonInfo(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled);
75
77// MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
78// MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
81
86 COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDockingWindow)
87 COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject)
91};
92
95{
96}
97
99{
100}
101
103{
104 RECT actualRect;
105 POINTL actualSize;
106 POINTL idealSize;
107 POINTL maxSize;
108 POINTL itemSize;
109
110 ::GetWindowRect(m_hWnd, &actualRect);
111 actualSize.x = actualRect.right - actualRect.left;
112 actualSize.y = actualRect.bottom - actualRect.top;
113
114 /* Obtain the ideal size, to be used as min and max */
116 SendMessageW(m_hWnd, TB_GETMAXSIZE, 0, reinterpret_cast<LPARAM>(&maxSize));
117
118 idealSize = maxSize;
119 SendMessageW(m_hWnd, TB_GETIDEALSIZE, FALSE, reinterpret_cast<LPARAM>(&idealSize));
120
121 /* Obtain the button size, to be used as the integral size */
123 itemSize.x = GET_X_LPARAM(size);
124 itemSize.y = GET_Y_LPARAM(size);
125
126 if (pdbi->dwMask & DBIM_MINSIZE)
127 {
128 pdbi->ptMinSize = idealSize;
129 }
130 if (pdbi->dwMask & DBIM_MAXSIZE)
131 {
132 pdbi->ptMaxSize = maxSize;
133 }
134 if (pdbi->dwMask & DBIM_INTEGRAL)
135 {
136 pdbi->ptIntegral = itemSize;
137 }
138 if (pdbi->dwMask & DBIM_ACTUAL)
139 {
140 pdbi->ptActual = actualSize;
141 }
142 if (pdbi->dwMask & DBIM_TITLE)
143 wcscpy(pdbi->wszTitle, L"");
144 if (pdbi->dwMask & DBIM_MODEFLAGS)
145 pdbi->dwModeFlags = DBIMF_UNDELETEABLE;
146 if (pdbi->dwMask & DBIM_BKCOLOR)
147 pdbi->crBkgnd = 0;
148 return S_OK;
149}
150
151static const int backImageIndex = 0;
152static const int forwardImageIndex = 1;
153static const int favoritesImageIndex = 2;
154// 3
155// 4
156static const int cutImageIndex = 5;
157static const int copyImageIndex = 6;
158static const int pasteImageIndex = 7;
159static const int undoImageIndex = 8;
160//static const int redoImageIndex = 9;
161static const int deleteImageIndex = 10;
162// 11
163// 12
164// 13
165// 14
166static const int propertiesImageIndex = 15;
167// 16
168static const int searchImageIndex = 17;
169// 18
170// 19
171// 20
172// 21
173static const int viewsImageIndex = 22;
174// 23
175// 24
176// 25
177// 26
178// 27
179static const int upImageIndex = 28;
180static const int mapDriveImageIndex = 29;
181static const int disconnectImageIndex = 30;
182// 31
183//static const int viewsAltImageIndex = 32; // same image as viewsImageIndex
184// 33
185// 34
186// 35
187// 36
188// 37
189//static const int viewsAlt2ImageIndex = 38; // same image as viewsAltImageIndex & viewsImageIndex
190// 39
191// 40
192// 41
193// 42
194static const int foldersImageIndex = 43;
195static const int moveToImageIndex = 44;
196static const int copyToImageIndex = 45;
197static const int folderOptionsImageIndex = 46;
198
223};
224
225const int numShownButtons = 13;
226const int numHiddenButtons = 13;
228{
232 { 6, -1, TBSTATE_ENABLED, BTNS_SEP },
235 { 6, -1, TBSTATE_ENABLED, BTNS_SEP },
240 { 6, -1, TBSTATE_ENABLED, BTNS_SEP },
242
256};
257
259 HWND parentWindow;
260 HWND toolbar;
261 HRESULT hResult;
262
264
265 if (pUnkSite == NULL)
266 return S_OK;
267 hResult = pUnkSite->QueryInterface(IID_PPV_ARG(IDockingWindowSite, &fDockSite));
268 if (FAILED_UNEXPECTEDLY(hResult))
269 return hResult;
270 parentWindow = NULL;
271 hResult = IUnknown_GetWindow(pUnkSite, &parentWindow);
272 if (FAILED(hResult) || !::IsWindow(parentWindow))
273 return E_FAIL;
274
275 toolbar = CreateWindowEx(
281 0, 0, 500, 20, parentWindow, NULL, _AtlBaseModule.GetModuleInstance(), 0);
282 if (toolbar == NULL)
283 return E_FAIL;
284 SubclassWindow(toolbar);
286
291
292 m_himlNormal = ImageList_LoadImageW(_AtlBaseModule.GetResourceInstance(),
294 0, 0, RGB(255, 0, 255), IMAGE_BITMAP, LR_DEFAULTSIZE | LR_CREATEDIBSECTION);
295
296 m_himlHot = ImageList_LoadImageW(_AtlBaseModule.GetResourceInstance(),
298 0, 0, RGB(255, 0, 255), IMAGE_BITMAP, LR_DEFAULTSIZE | LR_CREATEDIBSECTION);
299
303
304 return hResult;
305}
306
308{
309 if (fDockSite == NULL)
310 return E_FAIL;
311 return fDockSite->QueryInterface(riid, ppvSite);
312}
313
315{
316 if (lphwnd == NULL)
317 return E_POINTER;
318 *lphwnd = m_hWnd;
319 return S_OK;
320}
321
323{
324 return E_NOTIMPL;
325}
326
328{
329 ShowDW(FALSE);
330
331 if (IsWindow())
333
334 m_hWnd = NULL;
335
336 if (fDockSite)
338
339 if (m_himlNormal)
341
342 if (m_himlHot)
344
345 return S_OK;
346}
347
348HRESULT STDMETHODCALLTYPE CToolsBand::ResizeBorderDW(const RECT* prcBorder, IUnknown* punkToolbarSite, BOOL fReserved)
349{
350 return E_NOTIMPL;
351}
352
354{
355 if (m_hWnd)
356 {
357 if (fShow)
359 else
361 }
362 return S_OK;
363}
364
366{
367 return S_FALSE;
368}
369
371{
372 return S_FALSE;
373}
374
376{
377 return E_NOTIMPL;
378}
379
381{
382 return E_NOTIMPL;
383}
384
386{
387 return E_NOTIMPL;
388}
389
391{
392 return E_NOTIMPL;
393}
394
396{
397 return E_NOTIMPL;
398}
399
401{
402 return E_NOTIMPL;
403}
404
405LRESULT CToolsBand::OnGetButtonInfo(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled)
406{
407 TBNOTIFYW *pTBntf = reinterpret_cast<TBNOTIFYW *>(pNMHDR);
408
409 if (pTBntf->iItem >= 0 && pTBntf->iItem < (numShownButtons + numHiddenButtons))
410 {
411 pTBntf->tbButton = tbButtonsAdd[pTBntf->iItem];
412 return TRUE;
413 }
414 else
415 return FALSE;
416 return 0;
417}
418
420{
421 return ShellObjectCreator<CToolsBand>(riid, ppv);
422}
423
#define STDMETHOD(m)
Definition: basetyps.h:62
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
void Release()
Definition: atlcomcli.h:170
BOOL DestroyWindow()
Definition: atlwin.h:462
HWND m_hWnd
Definition: atlwin.h:273
BOOL IsWindow() const
Definition: atlwin.h:947
STDMETHOD() ResizeBorderDW(const RECT *prcBorder, IUnknown *punkToolbarSite, BOOL fReserved) override
Definition: toolsband.cpp:348
virtual ~CToolsBand()
Definition: toolsband.cpp:98
STDMETHOD() ShowDW(BOOL fShow) override
Definition: toolsband.cpp:353
STDMETHOD() SetSite(IUnknown *pUnkSite) override
Definition: toolsband.cpp:258
STDMETHOD() ContextSensitiveHelp(BOOL fEnterMode) override
Definition: toolsband.cpp:322
STDMETHOD() GetSizeMax(ULARGE_INTEGER *pcbSize) override
Definition: toolsband.cpp:400
STDMETHOD() Save(IStream *pStm, BOOL fClearDirty) override
Definition: toolsband.cpp:395
HIMAGELIST m_himlHot
Definition: toolsband.cpp:38
STDMETHOD() CloseDW(DWORD dwReserved) override
Definition: toolsband.cpp:327
STDMETHOD() UIActivateIO(BOOL fActivate, LPMSG lpMsg) override
Definition: toolsband.cpp:375
HIMAGELIST m_himlNormal
Definition: toolsband.cpp:37
STDMETHOD() GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi) override
Definition: toolsband.cpp:102
STDMETHOD() Load(IStream *pStm) override
Definition: toolsband.cpp:390
STDMETHOD() GetClassID(CLSID *pClassID) override
Definition: toolsband.cpp:380
STDMETHOD() IsDirty() override
Definition: toolsband.cpp:385
STDMETHOD() TranslateAcceleratorIO(LPMSG lpMsg) override
Definition: toolsband.cpp:370
LRESULT OnGetButtonInfo(UINT idControl, NMHDR *pNMHDR, BOOL &bHandled)
Definition: toolsband.cpp:405
CComPtr< IDockingWindowSite > fDockSite
Definition: toolsband.cpp:36
STDMETHOD() GetSite(REFIID riid, void **ppvSite) override
Definition: toolsband.cpp:307
STDMETHOD() HasFocusIO() override
Definition: toolsband.cpp:365
STDMETHOD() GetWindow(HWND *lphwnd) override
Definition: toolsband.cpp:314
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDM_TOOLS_DISCONNECTNETWORKDRIVE
Definition: resource.h:54
#define IDM_TOOLS_FOLDEROPTIONS
Definition: resource.h:56
#define IDM_GOTO_UPONELEVEL
Definition: resource.h:47
#define IDM_VIEW_REFRESH
Definition: resource.h:49
#define IDM_GOTO_FORWARD
Definition: resource.h:46
#define IDM_TOOLS_MAPNETWORKDRIVE
Definition: resource.h:53
#define IDB_SHELL_EXPLORER_LG
Definition: resource.h:151
#define IDB_SHELL_EXPLORER_LG_HOT
Definition: resource.h:152
#define IDM_GOTO_BACK
Definition: resource.h:45
#define IDS_STANDARD_TOOLBAR
Definition: resource.h:125
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
HIMAGELIST WINAPI ImageList_LoadImageW(HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow, COLORREF clrMask, UINT uType, UINT uFlags)
Definition: imagelist.c:2208
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:1332
#define RGB(r, g, b)
Definition: precomp.h:71
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
static const int gFullScreenCommandID
static const int gHistoryCommandID
static const int gFoldersCommandID
static const int gDeleteCommandID
static const int gPropertiesCommandID
static const int gMoveToCommandID
static const int gCopyToCommandID
static const int gCutCommandID
static const int gUndoCommandID
static const int gViewsCommandID
static const int gCopyCommandID
static const int gSearchCommandID
static const int gHomeCommandID
static const int gStopCommandID
static const int gFavoritesCommandID
static const int gPasteCommandID
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:581
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:601
#define END_COM_MAP()
Definition: atlcom.h:592
#define BEGIN_MSG_MAP(theClass)
Definition: atlwin.h:1898
#define END_MSG_MAP()
Definition: atlwin.h:1917
#define NOTIFY_HANDLER(id, cd, func)
Definition: atlwin.h:1989
const IID IID_IObjectWithSite
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
const GUID IID_IOleWindow
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
const GUID IID_IPersist
Definition: proxy.cpp:14
const GUID IID_IPersistStream
Definition: proxy.cpp:13
#define BTNS_BUTTON
Definition: commctrl.h:998
#define TB_SETEXTENDEDSTYLE
Definition: commctrl.h:1190
#define BTNS_SHOWTEXT
Definition: commctrl.h:1006
#define TB_AUTOSIZE
Definition: commctrl.h:1137
#define TB_GETIDEALSIZE
Definition: commctrl.h:1284
#define TBSTYLE_EX_DRAWDDARROWS
Definition: commctrl.h:1009
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:989
#define BTNS_SEP
Definition: commctrl.h:999
#define TBSTYLE_LIST
Definition: commctrl.h:993
#define TBSTYLE_EX_MIXEDBUTTONS
Definition: commctrl.h:1012
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1134
#define TB_GETBUTTONSIZE
Definition: commctrl.h:1160
#define TBNOTIFYW
Definition: commctrl.h:1431
#define TBN_GETBUTTONINFOW
Definition: commctrl.h:1343
#define TB_ADDSTRINGW
Definition: commctrl.h:1132
#define TB_SETIMAGELIST
Definition: commctrl.h:1150
#define TBSTYLE_EX_HIDECLIPPEDBUTTONS
Definition: commctrl.h:1013
#define TB_GETMAXSIZE
Definition: commctrl.h:1189
#define TBSTYLE_EX_DOUBLEBUFFER
Definition: commctrl.h:1014
#define TBSTYLE_TRANSPARENT
Definition: commctrl.h:996
#define CCS_NODIVIDER
Definition: commctrl.h:2248
#define TOOLBARCLASSNAMEW
Definition: commctrl.h:943
#define CCS_TOP
Definition: commctrl.h:2242
#define TBSTYLE_REGISTERDROP
Definition: commctrl.h:995
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define TBSTYLE_FLAT
Definition: commctrl.h:992
#define BTNS_DROPDOWN
Definition: commctrl.h:1003
#define CCS_NOPARENTALIGN
Definition: commctrl.h:2246
#define CCS_NORESIZE
Definition: commctrl.h:2245
#define TB_SETHOTIMAGELIST
Definition: commctrl.h:1154
#define TB_ADDBUTTONSW
Definition: commctrl.h:1266
#define TB_SETMAXTEXTROWS
Definition: commctrl.h:1162
#define BTNS_WHOLEDROPDOWN
Definition: commctrl.h:1007
#define REFIID
Definition: guiddef.h:118
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
COLORREF crBkgnd
Definition: shobjidl.idl:2424
WCHAR wszTitle[256]
Definition: shobjidl.idl:2422
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
static const int viewsImageIndex
Definition: toolsband.cpp:173
static const int copyImageIndex
Definition: toolsband.cpp:157
static const int upImageIndex
Definition: toolsband.cpp:179
static const int favoritesImageIndex
Definition: toolsband.cpp:153
StandardToolbarButtons
Definition: toolsband.cpp:199
@ BtnIdx_Stop
Definition: toolsband.cpp:210
@ BtnIdx_Back
Definition: toolsband.cpp:200
@ BtnIdx_Search
Definition: toolsband.cpp:203
@ BtnIdx_Properties
Definition: toolsband.cpp:218
@ BtnIdx_FolderOptions
Definition: toolsband.cpp:222
@ BtnIdx_History
Definition: toolsband.cpp:216
@ BtnIdx_Favorites
Definition: toolsband.cpp:215
@ BtnIdx_Up
Definition: toolsband.cpp:202
@ BtnIdx_Cut
Definition: toolsband.cpp:219
@ BtnIdx_Paste
Definition: toolsband.cpp:221
@ BtnIdx_Disconnect
Definition: toolsband.cpp:214
@ BtnIdx_Views
Definition: toolsband.cpp:209
@ BtnIdx_Delete
Definition: toolsband.cpp:207
@ BtnIdx_Home
Definition: toolsband.cpp:212
@ BtnIdx_Forward
Definition: toolsband.cpp:201
@ BtnIdx_CopyTo
Definition: toolsband.cpp:206
@ BtnIdx_Refresh
Definition: toolsband.cpp:211
@ BtnIdx_Undo
Definition: toolsband.cpp:208
@ BtnIdx_FullScreen
Definition: toolsband.cpp:217
@ BtnIdx_Folders
Definition: toolsband.cpp:204
@ BtnIdx_Copy
Definition: toolsband.cpp:220
@ BtnIdx_MoveTo
Definition: toolsband.cpp:205
@ BtnIdx_MapDrive
Definition: toolsband.cpp:213
static const int forwardImageIndex
Definition: toolsband.cpp:152
TBBUTTON tbButtonsAdd[numShownButtons+numHiddenButtons]
Definition: toolsband.cpp:227
const int numShownButtons
Definition: toolsband.cpp:225
static const int pasteImageIndex
Definition: toolsband.cpp:158
static const int disconnectImageIndex
Definition: toolsband.cpp:181
static const int cutImageIndex
Definition: toolsband.cpp:156
static const int backImageIndex
Definition: toolsband.cpp:151
const int numHiddenButtons
Definition: toolsband.cpp:226
static const int searchImageIndex
Definition: toolsband.cpp:168
static const int deleteImageIndex
Definition: toolsband.cpp:161
static const int folderOptionsImageIndex
Definition: toolsband.cpp:197
static const int foldersImageIndex
Definition: toolsband.cpp:194
static const int moveToImageIndex
Definition: toolsband.cpp:195
static const int mapDriveImageIndex
Definition: toolsband.cpp:180
HRESULT CToolsBand_CreateInstance(REFIID riid, void **ppv)
Definition: toolsband.cpp:419
static const int propertiesImageIndex
Definition: toolsband.cpp:166
static const int copyToImageIndex
Definition: toolsband.cpp:196
static const int undoImageIndex
Definition: toolsband.cpp:159
#define GetModuleHandle
Definition: winbase.h:3827
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define SubclassWindow(hwnd, lpfn)
Definition: windowsx.h:542
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
#define S_FALSE
Definition: winerror.h:2357
#define E_POINTER
Definition: winerror.h:2365
#define CreateWindowEx
Definition: winuser.h:5755
#define SW_HIDE
Definition: winuser.h:768
#define IMAGE_BITMAP
Definition: winuser.h:211
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define SM_CXEDGE
Definition: winuser.h:1008
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define LR_CREATEDIBSECTION
Definition: winuser.h:1098
#define SendMessage
Definition: winuser.h:5843
#define WM_USER
Definition: winuser.h:1895
#define SW_SHOW
Definition: winuser.h:775
#define LR_DEFAULTSIZE
Definition: winuser.h:1094
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
int WINAPI GetSystemMetrics(_In_ int)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IID_PPV_ARG(Itype, ppType)