1f0f1e5ffSGiannis Adamopoulos /*
2f0f1e5ffSGiannis Adamopoulos * PROJECT: ReactOS shell extensions
3f0f1e5ffSGiannis Adamopoulos * LICENSE: GPL - See COPYING in the top level directory
4f0f1e5ffSGiannis Adamopoulos * FILE: dll/shellext/qcklnch/CISFBand.cpp
5f0f1e5ffSGiannis Adamopoulos * PURPOSE: Quick Launch Toolbar (Taskbar Shell Extension)
6f0f1e5ffSGiannis Adamopoulos * PROGRAMMERS: Shriraj Sawant a.k.a SR13 <sr.official@hotmail.com>
7f0f1e5ffSGiannis Adamopoulos */
8f0f1e5ffSGiannis Adamopoulos
9f0f1e5ffSGiannis Adamopoulos #include "shellbars.h"
10f0f1e5ffSGiannis Adamopoulos
11b3544fd0SAmine Khaldi #include <commoncontrols.h>
12b3544fd0SAmine Khaldi #include <shellapi.h>
134c23b78bSGiannis Adamopoulos #include <wingdi.h>
144c23b78bSGiannis Adamopoulos #include <uxtheme.h>
15f0f1e5ffSGiannis Adamopoulos
162875a70cSGiannis Adamopoulos /*
172875a70cSGiannis Adamopoulos TODO:
182875a70cSGiannis Adamopoulos ** drag and drop support
192875a70cSGiannis Adamopoulos ** tooltips
202875a70cSGiannis Adamopoulos ** handle change notifications
212875a70cSGiannis Adamopoulos ** Fix position of the items context menu
222875a70cSGiannis Adamopoulos ** Implement responding to theme change
232875a70cSGiannis Adamopoulos */
242875a70cSGiannis Adamopoulos
25f0f1e5ffSGiannis Adamopoulos //*****************************************************************************************
26f0f1e5ffSGiannis Adamopoulos // *** CISFBand ***
27f0f1e5ffSGiannis Adamopoulos
CISFBand()28f0f1e5ffSGiannis Adamopoulos CISFBand::CISFBand() :
29f0f1e5ffSGiannis Adamopoulos m_BandID(0),
30f0f1e5ffSGiannis Adamopoulos m_pidl(NULL),
31f0f1e5ffSGiannis Adamopoulos m_textFlag(true),
32ee3b7320SGiannis Adamopoulos m_iconFlag(true),
33ee3b7320SGiannis Adamopoulos m_QLaunch(false)
34f0f1e5ffSGiannis Adamopoulos {
35f0f1e5ffSGiannis Adamopoulos }
36f0f1e5ffSGiannis Adamopoulos
~CISFBand()37f0f1e5ffSGiannis Adamopoulos CISFBand::~CISFBand()
38f0f1e5ffSGiannis Adamopoulos {
39f0f1e5ffSGiannis Adamopoulos CloseDW(0);
40f0f1e5ffSGiannis Adamopoulos }
41f0f1e5ffSGiannis Adamopoulos
42f0f1e5ffSGiannis Adamopoulos // Toolbar
43f0f1e5ffSGiannis Adamopoulos /*++
44f0f1e5ffSGiannis Adamopoulos * @name CreateSimpleToolbar
45f0f1e5ffSGiannis Adamopoulos *
46f0f1e5ffSGiannis Adamopoulos * Creates a toolbar and fills it up with buttons for enumerated objects.
47f0f1e5ffSGiannis Adamopoulos *
48f0f1e5ffSGiannis Adamopoulos * @param hWndParent
49f0f1e5ffSGiannis Adamopoulos * Handle to the parent window, which receives the appropriate messages from child toolbar.
50f0f1e5ffSGiannis Adamopoulos *
51f0f1e5ffSGiannis Adamopoulos * @return The error code.
52f0f1e5ffSGiannis Adamopoulos *
53f0f1e5ffSGiannis Adamopoulos *--*/
CreateSimpleToolbar(HWND hWndParent)54f0f1e5ffSGiannis Adamopoulos HRESULT CISFBand::CreateSimpleToolbar(HWND hWndParent)
55f0f1e5ffSGiannis Adamopoulos {
56f0f1e5ffSGiannis Adamopoulos // Declare and initialize local constants.
57f0f1e5ffSGiannis Adamopoulos const DWORD buttonStyles = BTNS_AUTOSIZE;
58f0f1e5ffSGiannis Adamopoulos
59f0f1e5ffSGiannis Adamopoulos // Create the toolbar.
60f0f1e5ffSGiannis Adamopoulos m_hWnd = CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
61f0f1e5ffSGiannis Adamopoulos WS_CHILD | TBSTYLE_FLAT | TBSTYLE_LIST | CCS_NORESIZE | CCS_NODIVIDER, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0,
62f0f1e5ffSGiannis Adamopoulos hWndParent, NULL, 0, NULL);
63f0f1e5ffSGiannis Adamopoulos if (m_hWnd == NULL)
64f0f1e5ffSGiannis Adamopoulos return E_FAIL;
65f0f1e5ffSGiannis Adamopoulos
66bab9a540SGiannis Adamopoulos if (!m_textFlag)
67bab9a540SGiannis Adamopoulos SendMessage(m_hWnd, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
68bab9a540SGiannis Adamopoulos
69f0f1e5ffSGiannis Adamopoulos // Set the image list.
70f0f1e5ffSGiannis Adamopoulos HIMAGELIST* piml;
71f0f1e5ffSGiannis Adamopoulos HRESULT hr = SHGetImageList(SHIL_SMALL, IID_IImageList, (void**)&piml);
72f0f1e5ffSGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
73f0f1e5ffSGiannis Adamopoulos {
74f0f1e5ffSGiannis Adamopoulos DestroyWindow();
75f0f1e5ffSGiannis Adamopoulos return hr;
76f0f1e5ffSGiannis Adamopoulos }
77f0f1e5ffSGiannis Adamopoulos SendMessage(m_hWnd, TB_SETIMAGELIST, 0, (LPARAM)piml);
78f0f1e5ffSGiannis Adamopoulos
79f0f1e5ffSGiannis Adamopoulos // Enumerate objects
80f0f1e5ffSGiannis Adamopoulos CComPtr<IEnumIDList> pEndl;
81f0f1e5ffSGiannis Adamopoulos LPITEMIDLIST pidl;
82f0f1e5ffSGiannis Adamopoulos STRRET stret;
83ee3b7320SGiannis Adamopoulos hr = m_pISF->EnumObjects(0, SHCONTF_FOLDERS|SHCONTF_NONFOLDERS, &pEndl);
84f0f1e5ffSGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
85f0f1e5ffSGiannis Adamopoulos {
86f0f1e5ffSGiannis Adamopoulos DestroyWindow();
87f0f1e5ffSGiannis Adamopoulos return hr;
88f0f1e5ffSGiannis Adamopoulos }
89f0f1e5ffSGiannis Adamopoulos
90f0f1e5ffSGiannis Adamopoulos for (int i=0; pEndl->Next(1, &pidl, NULL) != S_FALSE; i++)
91f0f1e5ffSGiannis Adamopoulos {
92f0f1e5ffSGiannis Adamopoulos WCHAR sz[MAX_PATH];
93f0f1e5ffSGiannis Adamopoulos int index = SHMapPIDLToSystemImageListIndex(m_pISF, pidl, NULL);
94f0f1e5ffSGiannis Adamopoulos hr = m_pISF->GetDisplayNameOf(pidl, SHGDN_NORMAL, &stret);
95f0f1e5ffSGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
96f0f1e5ffSGiannis Adamopoulos {
97f0f1e5ffSGiannis Adamopoulos StringCchCopyW(sz, MAX_PATH, L"<Unknown-Name>");
98f0f1e5ffSGiannis Adamopoulos }
99f0f1e5ffSGiannis Adamopoulos else
100f0f1e5ffSGiannis Adamopoulos StrRetToBuf(&stret, pidl, sz, _countof(sz));
101f0f1e5ffSGiannis Adamopoulos
102f0f1e5ffSGiannis Adamopoulos TBBUTTON tb = { MAKELONG(index, 0), i, TBSTATE_ENABLED, buttonStyles,{ 0 }, (DWORD_PTR)pidl, (INT_PTR)sz };
103f0f1e5ffSGiannis Adamopoulos SendMessage(m_hWnd, TB_INSERTBUTTONW, i, (LPARAM)&tb);
104f0f1e5ffSGiannis Adamopoulos }
105f0f1e5ffSGiannis Adamopoulos
106f0f1e5ffSGiannis Adamopoulos // Resize the toolbar, and then show it.
107f0f1e5ffSGiannis Adamopoulos SendMessage(m_hWnd, TB_AUTOSIZE, 0, 0);
108f0f1e5ffSGiannis Adamopoulos
109f0f1e5ffSGiannis Adamopoulos return hr;
110f0f1e5ffSGiannis Adamopoulos }
111f0f1e5ffSGiannis Adamopoulos
112f0f1e5ffSGiannis Adamopoulos /*****************************************************************************/
113f0f1e5ffSGiannis Adamopoulos
114f0f1e5ffSGiannis Adamopoulos // *** IObjectWithSite ***
SetSite(IUnknown * pUnkSite)115f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::SetSite(IUnknown *pUnkSite)
116f0f1e5ffSGiannis Adamopoulos {
117f0f1e5ffSGiannis Adamopoulos HRESULT hr;
118f0f1e5ffSGiannis Adamopoulos HWND hwndParent;
119f0f1e5ffSGiannis Adamopoulos
120f0f1e5ffSGiannis Adamopoulos TRACE("CISFBand::SetSite(0x%p)\n", pUnkSite);
121f0f1e5ffSGiannis Adamopoulos
122f0f1e5ffSGiannis Adamopoulos hr = IUnknown_GetWindow(pUnkSite, &hwndParent);
123f0f1e5ffSGiannis Adamopoulos if (FAILED(hr))
124f0f1e5ffSGiannis Adamopoulos {
125f0f1e5ffSGiannis Adamopoulos TRACE("Querying site window failed: 0x%x\n", hr);
126f0f1e5ffSGiannis Adamopoulos return hr;
127f0f1e5ffSGiannis Adamopoulos }
128f0f1e5ffSGiannis Adamopoulos m_Site = pUnkSite;
129f0f1e5ffSGiannis Adamopoulos
130f0f1e5ffSGiannis Adamopoulos hr = CreateSimpleToolbar(hwndParent);
131f0f1e5ffSGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
132f0f1e5ffSGiannis Adamopoulos return hr;
133f0f1e5ffSGiannis Adamopoulos
134f0f1e5ffSGiannis Adamopoulos return S_OK;
135f0f1e5ffSGiannis Adamopoulos }
136f0f1e5ffSGiannis Adamopoulos
GetSite(IN REFIID riid,OUT VOID ** ppvSite)137f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::GetSite(IN REFIID riid, OUT VOID **ppvSite)
138f0f1e5ffSGiannis Adamopoulos {
139f0f1e5ffSGiannis Adamopoulos TRACE("CISFBand::GetSite(0x%p,0x%p)\n", riid, ppvSite);
140f0f1e5ffSGiannis Adamopoulos
141f0f1e5ffSGiannis Adamopoulos HRESULT hr;
142f0f1e5ffSGiannis Adamopoulos if (m_Site != NULL)
143f0f1e5ffSGiannis Adamopoulos {
144f0f1e5ffSGiannis Adamopoulos hr = m_Site->QueryInterface(riid, ppvSite);
145f0f1e5ffSGiannis Adamopoulos if (FAILED(hr)) return hr;
146f0f1e5ffSGiannis Adamopoulos }
147f0f1e5ffSGiannis Adamopoulos
148f0f1e5ffSGiannis Adamopoulos *ppvSite = NULL;
149f0f1e5ffSGiannis Adamopoulos return E_FAIL;
150f0f1e5ffSGiannis Adamopoulos }
151f0f1e5ffSGiannis Adamopoulos
152f0f1e5ffSGiannis Adamopoulos /*****************************************************************************/
153f0f1e5ffSGiannis Adamopoulos // *** IDeskBand ***
GetWindow(OUT HWND * phwnd)154f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::GetWindow(OUT HWND *phwnd)
155f0f1e5ffSGiannis Adamopoulos {
156f0f1e5ffSGiannis Adamopoulos if (!m_hWnd)
157f0f1e5ffSGiannis Adamopoulos return E_FAIL;
158f0f1e5ffSGiannis Adamopoulos if (!phwnd)
159f0f1e5ffSGiannis Adamopoulos return E_POINTER;
160f0f1e5ffSGiannis Adamopoulos *phwnd = m_hWnd;
161f0f1e5ffSGiannis Adamopoulos
162f0f1e5ffSGiannis Adamopoulos return S_OK;
163f0f1e5ffSGiannis Adamopoulos }
164f0f1e5ffSGiannis Adamopoulos
ContextSensitiveHelp(IN BOOL fEnterMode)165f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::ContextSensitiveHelp(IN BOOL fEnterMode)
166f0f1e5ffSGiannis Adamopoulos {
167f0f1e5ffSGiannis Adamopoulos /* FIXME: Implement */
168f0f1e5ffSGiannis Adamopoulos return E_NOTIMPL;
169f0f1e5ffSGiannis Adamopoulos }
170f0f1e5ffSGiannis Adamopoulos
ShowDW(IN BOOL bShow)171f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::ShowDW(IN BOOL bShow)
172f0f1e5ffSGiannis Adamopoulos {
173f0f1e5ffSGiannis Adamopoulos if (m_hWnd)
174f0f1e5ffSGiannis Adamopoulos {
175f0f1e5ffSGiannis Adamopoulos ShowWindow(bShow ? SW_SHOW : SW_HIDE);
176f0f1e5ffSGiannis Adamopoulos return S_OK;
177f0f1e5ffSGiannis Adamopoulos }
178f0f1e5ffSGiannis Adamopoulos
179f0f1e5ffSGiannis Adamopoulos return E_FAIL;
180f0f1e5ffSGiannis Adamopoulos }
181f0f1e5ffSGiannis Adamopoulos
CloseDW(IN DWORD dwReserved)182f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::CloseDW(IN DWORD dwReserved)
183f0f1e5ffSGiannis Adamopoulos {
184f0f1e5ffSGiannis Adamopoulos if (m_hWnd)
185f0f1e5ffSGiannis Adamopoulos {
186f0f1e5ffSGiannis Adamopoulos ShowWindow(SW_HIDE);
187f0f1e5ffSGiannis Adamopoulos
188f0f1e5ffSGiannis Adamopoulos TBBUTTON tb;
189f0f1e5ffSGiannis Adamopoulos for (int i = 0; SendMessage(m_hWnd, TB_GETBUTTON, i, (LPARAM)&tb); i++)
190f0f1e5ffSGiannis Adamopoulos {
191f0f1e5ffSGiannis Adamopoulos CoTaskMemFree((LPITEMIDLIST)tb.dwData);
192f0f1e5ffSGiannis Adamopoulos }
193f0f1e5ffSGiannis Adamopoulos
194f0f1e5ffSGiannis Adamopoulos DestroyWindow();
195f0f1e5ffSGiannis Adamopoulos m_hWnd = NULL;
196f0f1e5ffSGiannis Adamopoulos return S_OK;
197f0f1e5ffSGiannis Adamopoulos }
198f0f1e5ffSGiannis Adamopoulos
199f0f1e5ffSGiannis Adamopoulos return E_FAIL;
200f0f1e5ffSGiannis Adamopoulos }
201f0f1e5ffSGiannis Adamopoulos
ResizeBorderDW(LPCRECT prcBorder,IUnknown * punkToolbarSite,BOOL fReserved)202f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved)
203f0f1e5ffSGiannis Adamopoulos {
204f0f1e5ffSGiannis Adamopoulos /* No need to implement this method */
205f0f1e5ffSGiannis Adamopoulos
206f0f1e5ffSGiannis Adamopoulos return E_NOTIMPL;
207f0f1e5ffSGiannis Adamopoulos }
208f0f1e5ffSGiannis Adamopoulos
GetBandInfo(IN DWORD dwBandID,IN DWORD dwViewMode,IN OUT DESKBANDINFO * pdbi)209f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::GetBandInfo(IN DWORD dwBandID, IN DWORD dwViewMode, IN OUT DESKBANDINFO *pdbi)
210f0f1e5ffSGiannis Adamopoulos {
211f0f1e5ffSGiannis Adamopoulos TRACE("CTaskBand::GetBandInfo(0x%x,0x%x,0x%p) hWnd=0x%p\n", dwBandID, dwViewMode, pdbi, m_hWnd);
212f0f1e5ffSGiannis Adamopoulos
213f0f1e5ffSGiannis Adamopoulos if (m_hWnd && pdbi)
214f0f1e5ffSGiannis Adamopoulos {
215f0f1e5ffSGiannis Adamopoulos m_BandID = dwBandID;
216f0f1e5ffSGiannis Adamopoulos
217f0f1e5ffSGiannis Adamopoulos RECT actualRect;
218f0f1e5ffSGiannis Adamopoulos POINTL actualSize;
219f0f1e5ffSGiannis Adamopoulos POINTL idealSize;
220f0f1e5ffSGiannis Adamopoulos POINTL maxSize;
221f0f1e5ffSGiannis Adamopoulos POINTL itemSize;
222f0f1e5ffSGiannis Adamopoulos
223f0f1e5ffSGiannis Adamopoulos GetWindowRect(&actualRect);
224f0f1e5ffSGiannis Adamopoulos actualSize.x = actualRect.right - actualRect.left;
225f0f1e5ffSGiannis Adamopoulos actualSize.y = actualRect.bottom - actualRect.top;
226f0f1e5ffSGiannis Adamopoulos
227f0f1e5ffSGiannis Adamopoulos // Obtain the ideal size, to be used as min and max
228f0f1e5ffSGiannis Adamopoulos SendMessageW(m_hWnd, TB_AUTOSIZE, 0, 0);
229f0f1e5ffSGiannis Adamopoulos SendMessageW(m_hWnd, TB_GETMAXSIZE, 0, reinterpret_cast<LPARAM>(&maxSize));
230f0f1e5ffSGiannis Adamopoulos
231f0f1e5ffSGiannis Adamopoulos idealSize = maxSize;
232f0f1e5ffSGiannis Adamopoulos SendMessageW(m_hWnd, TB_GETIDEALSIZE, FALSE, reinterpret_cast<LPARAM>(&idealSize));
233f0f1e5ffSGiannis Adamopoulos
234f0f1e5ffSGiannis Adamopoulos // Obtain the button size, to be used as the integral size
235f0f1e5ffSGiannis Adamopoulos DWORD size = SendMessageW(m_hWnd, TB_GETBUTTONSIZE, 0, 0);
236f0f1e5ffSGiannis Adamopoulos itemSize.x = GET_X_LPARAM(size);
237f0f1e5ffSGiannis Adamopoulos itemSize.y = GET_Y_LPARAM(size);
238f0f1e5ffSGiannis Adamopoulos
239f0f1e5ffSGiannis Adamopoulos if (pdbi->dwMask & DBIM_MINSIZE)
240f0f1e5ffSGiannis Adamopoulos {
241bab9a540SGiannis Adamopoulos if (m_QLaunch)
242bab9a540SGiannis Adamopoulos pdbi->ptMinSize.x = idealSize.x;
243bab9a540SGiannis Adamopoulos else
244f0f1e5ffSGiannis Adamopoulos pdbi->ptMinSize.x = -1;
245f0f1e5ffSGiannis Adamopoulos pdbi->ptMinSize.y = idealSize.y;
246f0f1e5ffSGiannis Adamopoulos }
247f0f1e5ffSGiannis Adamopoulos if (pdbi->dwMask & DBIM_MAXSIZE)
248f0f1e5ffSGiannis Adamopoulos {
249f0f1e5ffSGiannis Adamopoulos pdbi->ptMaxSize = maxSize;
250f0f1e5ffSGiannis Adamopoulos }
251f0f1e5ffSGiannis Adamopoulos if (pdbi->dwMask & DBIM_INTEGRAL)
252f0f1e5ffSGiannis Adamopoulos {
253f0f1e5ffSGiannis Adamopoulos pdbi->ptIntegral = itemSize;
254f0f1e5ffSGiannis Adamopoulos }
255f0f1e5ffSGiannis Adamopoulos if (pdbi->dwMask & DBIM_ACTUAL)
256f0f1e5ffSGiannis Adamopoulos {
257f0f1e5ffSGiannis Adamopoulos pdbi->ptActual = actualSize;
258f0f1e5ffSGiannis Adamopoulos }
259f0f1e5ffSGiannis Adamopoulos if (pdbi->dwMask & DBIM_TITLE)
260ee3b7320SGiannis Adamopoulos {
261bab9a540SGiannis Adamopoulos if (m_QLaunch || !ILGetDisplayNameEx(NULL, m_pidl, pdbi->wszTitle, ILGDN_INFOLDER))
262ee3b7320SGiannis Adamopoulos {
263ee3b7320SGiannis Adamopoulos pdbi->dwMask &= ~DBIM_TITLE;
264ee3b7320SGiannis Adamopoulos }
265ee3b7320SGiannis Adamopoulos }
266f0f1e5ffSGiannis Adamopoulos if (pdbi->dwMask & DBIM_MODEFLAGS)
267f0f1e5ffSGiannis Adamopoulos {
268bab9a540SGiannis Adamopoulos pdbi->dwModeFlags = DBIMF_NORMAL | DBIMF_VARIABLEHEIGHT | DBIMF_USECHEVRON | DBIMF_NOMARGINS | DBIMF_BKCOLOR;
269bab9a540SGiannis Adamopoulos if (m_QLaunch)
270bab9a540SGiannis Adamopoulos {
271bab9a540SGiannis Adamopoulos pdbi->dwModeFlags |= DBIMF_ADDTOFRONT;
272bab9a540SGiannis Adamopoulos }
273f0f1e5ffSGiannis Adamopoulos }
274f0f1e5ffSGiannis Adamopoulos if (pdbi->dwMask & DBIM_BKCOLOR)
275f0f1e5ffSGiannis Adamopoulos pdbi->dwMask &= ~DBIM_BKCOLOR;
276f0f1e5ffSGiannis Adamopoulos
277f0f1e5ffSGiannis Adamopoulos return S_OK;
278f0f1e5ffSGiannis Adamopoulos }
279f0f1e5ffSGiannis Adamopoulos
280f0f1e5ffSGiannis Adamopoulos return E_FAIL;
281f0f1e5ffSGiannis Adamopoulos }
282f0f1e5ffSGiannis Adamopoulos
283f0f1e5ffSGiannis Adamopoulos /*****************************************************************************/
284f0f1e5ffSGiannis Adamopoulos // *** IPersistStream ***
GetClassID(OUT CLSID * pClassID)285f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::GetClassID(OUT CLSID *pClassID)
286f0f1e5ffSGiannis Adamopoulos {
287f0f1e5ffSGiannis Adamopoulos *pClassID = CLSID_ISFBand;
288f0f1e5ffSGiannis Adamopoulos
289f0f1e5ffSGiannis Adamopoulos return S_OK;
290f0f1e5ffSGiannis Adamopoulos }
291f0f1e5ffSGiannis Adamopoulos
IsDirty()292f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::IsDirty()
293f0f1e5ffSGiannis Adamopoulos {
294f0f1e5ffSGiannis Adamopoulos /* The object hasn't changed since the last save! */
295f0f1e5ffSGiannis Adamopoulos
296f0f1e5ffSGiannis Adamopoulos return S_FALSE;
297f0f1e5ffSGiannis Adamopoulos }
298f0f1e5ffSGiannis Adamopoulos
Load(IN IStream * pStm)299f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::Load(IN IStream *pStm)
300f0f1e5ffSGiannis Adamopoulos {
301f0f1e5ffSGiannis Adamopoulos TRACE("CISFBand::Load called\n");
302f0f1e5ffSGiannis Adamopoulos /* Nothing to do */
303f0f1e5ffSGiannis Adamopoulos
304f0f1e5ffSGiannis Adamopoulos return S_OK;
305f0f1e5ffSGiannis Adamopoulos }
306f0f1e5ffSGiannis Adamopoulos
Save(IN IStream * pStm,IN BOOL fClearDirty)307f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::Save(IN IStream *pStm, IN BOOL fClearDirty)
308f0f1e5ffSGiannis Adamopoulos {
309f0f1e5ffSGiannis Adamopoulos /* Nothing to do */
310f0f1e5ffSGiannis Adamopoulos
311f0f1e5ffSGiannis Adamopoulos return S_OK;
312f0f1e5ffSGiannis Adamopoulos }
313f0f1e5ffSGiannis Adamopoulos
GetSizeMax(OUT ULARGE_INTEGER * pcbSize)314f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::GetSizeMax(OUT ULARGE_INTEGER *pcbSize)
315f0f1e5ffSGiannis Adamopoulos {
316f0f1e5ffSGiannis Adamopoulos TRACE("CISFBand::GetSizeMax called\n");
317f0f1e5ffSGiannis Adamopoulos
318f0f1e5ffSGiannis Adamopoulos return S_OK;
319f0f1e5ffSGiannis Adamopoulos }
320f0f1e5ffSGiannis Adamopoulos
321f0f1e5ffSGiannis Adamopoulos /*****************************************************************************/
322f0f1e5ffSGiannis Adamopoulos // *** IWinEventHandler ***
ContainsWindow(IN HWND hWnd)323f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::ContainsWindow(IN HWND hWnd)
324f0f1e5ffSGiannis Adamopoulos {
325f0f1e5ffSGiannis Adamopoulos if (hWnd == m_hWnd || IsChild(hWnd))
326f0f1e5ffSGiannis Adamopoulos {
327f0f1e5ffSGiannis Adamopoulos TRACE("CISFBand::ContainsWindow(0x%p) returns S_OK\n", hWnd);
328f0f1e5ffSGiannis Adamopoulos return S_OK;
329f0f1e5ffSGiannis Adamopoulos }
330f0f1e5ffSGiannis Adamopoulos
331f0f1e5ffSGiannis Adamopoulos return S_FALSE;
332f0f1e5ffSGiannis Adamopoulos }
333f0f1e5ffSGiannis Adamopoulos
OnWinEvent(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam,LRESULT * theResult)334f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
335f0f1e5ffSGiannis Adamopoulos {
336f0f1e5ffSGiannis Adamopoulos switch (uMsg)
337f0f1e5ffSGiannis Adamopoulos {
338f0f1e5ffSGiannis Adamopoulos case WM_COMMAND:
339f0f1e5ffSGiannis Adamopoulos {
340f0f1e5ffSGiannis Adamopoulos TBBUTTON tb;
341f0f1e5ffSGiannis Adamopoulos bool chk = SendMessage(m_hWnd, TB_GETBUTTON, LOWORD(wParam), (LPARAM)&tb);
342f0f1e5ffSGiannis Adamopoulos if (chk)
343f0f1e5ffSGiannis Adamopoulos SHInvokeDefaultCommand(m_hWnd, m_pISF, (LPITEMIDLIST)tb.dwData);
344f0f1e5ffSGiannis Adamopoulos
3450aed0fd1SThomas Faber if (theResult)
346f0f1e5ffSGiannis Adamopoulos *theResult = TRUE;
347f0f1e5ffSGiannis Adamopoulos break;
348f0f1e5ffSGiannis Adamopoulos }
349f0f1e5ffSGiannis Adamopoulos case WM_NOTIFY:
350f0f1e5ffSGiannis Adamopoulos {
351f0f1e5ffSGiannis Adamopoulos switch (((LPNMHDR)lParam)->code)
352f0f1e5ffSGiannis Adamopoulos {
353f0f1e5ffSGiannis Adamopoulos case NM_RCLICK:
354f0f1e5ffSGiannis Adamopoulos {
355f0f1e5ffSGiannis Adamopoulos HRESULT hr;
356*b4e946f5SKatayama Hirofumi MZ POINT pt = ((LPNMMOUSE)lParam)->pt; // Already in screen coordinates
357f0f1e5ffSGiannis Adamopoulos CComPtr<IContextMenu> picm;
358f0f1e5ffSGiannis Adamopoulos HMENU fmenu = CreatePopupMenu();
359f0f1e5ffSGiannis Adamopoulos TBBUTTON tb;
360f0f1e5ffSGiannis Adamopoulos
361f0f1e5ffSGiannis Adamopoulos bool chk = SendMessage(m_hWnd, TB_GETBUTTON, ((LPNMMOUSE)lParam)->dwItemSpec, (LPARAM)&tb);
362f0f1e5ffSGiannis Adamopoulos LPITEMIDLIST pidl = (LPITEMIDLIST)tb.dwData;
363f0f1e5ffSGiannis Adamopoulos
364f0f1e5ffSGiannis Adamopoulos if (chk)
365f0f1e5ffSGiannis Adamopoulos {
366f0f1e5ffSGiannis Adamopoulos hr = m_pISF->GetUIObjectOf(m_hWnd, 1, &pidl, IID_NULL_PPV_ARG(IContextMenu, &picm));
367f0f1e5ffSGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
368f0f1e5ffSGiannis Adamopoulos return hr;
369f0f1e5ffSGiannis Adamopoulos
370f0f1e5ffSGiannis Adamopoulos hr = picm->QueryContextMenu(fmenu, 0, 1, 0x7FFF, CMF_DEFAULTONLY);
371f0f1e5ffSGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
372f0f1e5ffSGiannis Adamopoulos return hr;
373f0f1e5ffSGiannis Adamopoulos
374f0f1e5ffSGiannis Adamopoulos int id = TrackPopupMenuEx(fmenu, TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_RETURNCMD, pt.x, pt.y, m_hWnd, 0);
375f0f1e5ffSGiannis Adamopoulos if (id > 0)
376f0f1e5ffSGiannis Adamopoulos {
377f0f1e5ffSGiannis Adamopoulos CMINVOKECOMMANDINFOEX info = { 0 };
378f0f1e5ffSGiannis Adamopoulos info.cbSize = sizeof(info);
379f0f1e5ffSGiannis Adamopoulos info.fMask = CMIC_MASK_PTINVOKE;
380f0f1e5ffSGiannis Adamopoulos if (GetKeyState(VK_CONTROL) < 0)
381f0f1e5ffSGiannis Adamopoulos {
382f0f1e5ffSGiannis Adamopoulos info.fMask |= CMIC_MASK_CONTROL_DOWN;
383f0f1e5ffSGiannis Adamopoulos }
384f0f1e5ffSGiannis Adamopoulos if (GetKeyState(VK_SHIFT) < 0)
385f0f1e5ffSGiannis Adamopoulos {
386f0f1e5ffSGiannis Adamopoulos info.fMask |= CMIC_MASK_SHIFT_DOWN;
387f0f1e5ffSGiannis Adamopoulos }
388f0f1e5ffSGiannis Adamopoulos info.hwnd = m_hWnd;
389f0f1e5ffSGiannis Adamopoulos info.lpVerb = MAKEINTRESOURCEA(id - 1);
390f0f1e5ffSGiannis Adamopoulos info.nShow = SW_SHOWNORMAL;
391f0f1e5ffSGiannis Adamopoulos info.ptInvoke = pt;
392f0f1e5ffSGiannis Adamopoulos picm->InvokeCommand((LPCMINVOKECOMMANDINFO)&info);
393f0f1e5ffSGiannis Adamopoulos }
394f0f1e5ffSGiannis Adamopoulos }
395f0f1e5ffSGiannis Adamopoulos DestroyMenu(fmenu);
396f0f1e5ffSGiannis Adamopoulos
3970aed0fd1SThomas Faber if (theResult)
398f0f1e5ffSGiannis Adamopoulos *theResult = TRUE;
399f0f1e5ffSGiannis Adamopoulos break;
400f0f1e5ffSGiannis Adamopoulos }
401f0f1e5ffSGiannis Adamopoulos default:
4020aed0fd1SThomas Faber if (theResult)
403f0f1e5ffSGiannis Adamopoulos *theResult = FALSE;
404f0f1e5ffSGiannis Adamopoulos }
405f0f1e5ffSGiannis Adamopoulos
406f0f1e5ffSGiannis Adamopoulos break;
407f0f1e5ffSGiannis Adamopoulos }
408f0f1e5ffSGiannis Adamopoulos default:
4090aed0fd1SThomas Faber if (theResult)
410f0f1e5ffSGiannis Adamopoulos *theResult = FALSE;
411f0f1e5ffSGiannis Adamopoulos }
412f0f1e5ffSGiannis Adamopoulos
413f0f1e5ffSGiannis Adamopoulos return S_OK;
414f0f1e5ffSGiannis Adamopoulos }
415f0f1e5ffSGiannis Adamopoulos
IsWindowOwner(HWND hWnd)416f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::IsWindowOwner(HWND hWnd)
417f0f1e5ffSGiannis Adamopoulos {
418f0f1e5ffSGiannis Adamopoulos return (hWnd == m_hWnd) ? S_OK : S_FALSE;
419f0f1e5ffSGiannis Adamopoulos }
420f0f1e5ffSGiannis Adamopoulos
421f0f1e5ffSGiannis Adamopoulos /*****************************************************************************/
422f0f1e5ffSGiannis Adamopoulos // *** IOleCommandTarget methods ***
QueryStatus(const GUID * pguidCmdGroup,ULONG cCmds,OLECMD prgCmds[],OLECMDTEXT * pCmdText)423f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText)
424f0f1e5ffSGiannis Adamopoulos {
425f0f1e5ffSGiannis Adamopoulos UNIMPLEMENTED;
426f0f1e5ffSGiannis Adamopoulos
427f0f1e5ffSGiannis Adamopoulos return E_NOTIMPL;
428f0f1e5ffSGiannis Adamopoulos }
429f0f1e5ffSGiannis Adamopoulos
Exec(const GUID * pguidCmdGroup,DWORD nCmdID,DWORD nCmdexecopt,VARIANT * pvaIn,VARIANT * pvaOut)430f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
431f0f1e5ffSGiannis Adamopoulos {
432f0f1e5ffSGiannis Adamopoulos if (IsEqualIID(*pguidCmdGroup, IID_IBandSite))
433f0f1e5ffSGiannis Adamopoulos {
434f0f1e5ffSGiannis Adamopoulos return S_OK;
435f0f1e5ffSGiannis Adamopoulos }
436f0f1e5ffSGiannis Adamopoulos
437f0f1e5ffSGiannis Adamopoulos if (IsEqualIID(*pguidCmdGroup, IID_IDeskBand))
438f0f1e5ffSGiannis Adamopoulos {
4394c23b78bSGiannis Adamopoulos if (nCmdID == DBID_SETWINDOWTHEME)
4404c23b78bSGiannis Adamopoulos {
4414c23b78bSGiannis Adamopoulos if (pvaIn && V_VT(pvaIn) == VT_BSTR && V_BSTR(pvaIn))
4424c23b78bSGiannis Adamopoulos {
4434c23b78bSGiannis Adamopoulos SetWindowTheme(m_hWnd, V_BSTR(pvaIn), NULL);
4444c23b78bSGiannis Adamopoulos }
4454c23b78bSGiannis Adamopoulos }
446f0f1e5ffSGiannis Adamopoulos return S_OK;
447f0f1e5ffSGiannis Adamopoulos }
448f0f1e5ffSGiannis Adamopoulos
449f0f1e5ffSGiannis Adamopoulos UNIMPLEMENTED;
450f0f1e5ffSGiannis Adamopoulos
451f0f1e5ffSGiannis Adamopoulos return E_NOTIMPL;
452f0f1e5ffSGiannis Adamopoulos }
453f0f1e5ffSGiannis Adamopoulos
454f0f1e5ffSGiannis Adamopoulos /*****************************************************************************/
455f0f1e5ffSGiannis Adamopoulos // *** IShellFolderBand ***
GetBandInfoSFB(PBANDINFOSFB pbi)456f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::GetBandInfoSFB(PBANDINFOSFB pbi)
457f0f1e5ffSGiannis Adamopoulos {
458ee3b7320SGiannis Adamopoulos if (pbi->dwMask == ISFB_MASK_IDLIST)
459ee3b7320SGiannis Adamopoulos {
460ee3b7320SGiannis Adamopoulos pbi->pidl = ILClone(m_pidl);
461ee3b7320SGiannis Adamopoulos if (!pbi->pidl)
462ee3b7320SGiannis Adamopoulos return E_OUTOFMEMORY;
463ee3b7320SGiannis Adamopoulos return S_OK;
464ee3b7320SGiannis Adamopoulos }
465ee3b7320SGiannis Adamopoulos
466f0f1e5ffSGiannis Adamopoulos return E_NOTIMPL;
467f0f1e5ffSGiannis Adamopoulos }
468f0f1e5ffSGiannis Adamopoulos
InitializeSFB(IShellFolder * psf,PCIDLIST_ABSOLUTE pidl)469f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::InitializeSFB(IShellFolder *psf, PCIDLIST_ABSOLUTE pidl)
470f0f1e5ffSGiannis Adamopoulos {
471ee3b7320SGiannis Adamopoulos HRESULT hr;
472ee3b7320SGiannis Adamopoulos
473ee3b7320SGiannis Adamopoulos if (!psf && !pidl)
474ee3b7320SGiannis Adamopoulos return E_INVALIDARG;
475ee3b7320SGiannis Adamopoulos
476ee3b7320SGiannis Adamopoulos if (psf && pidl)
477ee3b7320SGiannis Adamopoulos return E_INVALIDARG;
478ee3b7320SGiannis Adamopoulos
479ee3b7320SGiannis Adamopoulos if (pidl != NULL)
480ee3b7320SGiannis Adamopoulos {
481ee3b7320SGiannis Adamopoulos CComPtr<IShellFolder> psfDesktop;
482ee3b7320SGiannis Adamopoulos hr = SHGetDesktopFolder(&psfDesktop);
483ee3b7320SGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
484ee3b7320SGiannis Adamopoulos return hr;
485ee3b7320SGiannis Adamopoulos
486f0f1e5ffSGiannis Adamopoulos if (_ILIsDesktop(pidl))
487f0f1e5ffSGiannis Adamopoulos {
488ee3b7320SGiannis Adamopoulos m_pISF = psfDesktop;
489f0f1e5ffSGiannis Adamopoulos }
490f0f1e5ffSGiannis Adamopoulos else
491f0f1e5ffSGiannis Adamopoulos {
492ee3b7320SGiannis Adamopoulos hr = psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &m_pISF));
493ee3b7320SGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
494ee3b7320SGiannis Adamopoulos return hr;
495ee3b7320SGiannis Adamopoulos }
496ee3b7320SGiannis Adamopoulos
497f0f1e5ffSGiannis Adamopoulos m_pidl = ILClone(pidl);
498f0f1e5ffSGiannis Adamopoulos }
499f0f1e5ffSGiannis Adamopoulos
500ee3b7320SGiannis Adamopoulos if (psf != NULL)
501ee3b7320SGiannis Adamopoulos {
502ee3b7320SGiannis Adamopoulos CComPtr<IPersistFolder2> ppf2;
503ee3b7320SGiannis Adamopoulos hr = psf->QueryInterface(IID_PPV_ARG(IPersistFolder2, &ppf2));
504ee3b7320SGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
505ee3b7320SGiannis Adamopoulos return hr;
506ee3b7320SGiannis Adamopoulos
507ee3b7320SGiannis Adamopoulos hr = ppf2->GetCurFolder(&m_pidl);
508ee3b7320SGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
509ee3b7320SGiannis Adamopoulos return hr;
510ee3b7320SGiannis Adamopoulos
511ee3b7320SGiannis Adamopoulos m_pISF = psf;
512ee3b7320SGiannis Adamopoulos }
513ee3b7320SGiannis Adamopoulos
514f0f1e5ffSGiannis Adamopoulos return S_OK;
515f0f1e5ffSGiannis Adamopoulos }
516f0f1e5ffSGiannis Adamopoulos
SetBandInfoSFB(PBANDINFOSFB pbi)517f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::SetBandInfoSFB( PBANDINFOSFB pbi)
518f0f1e5ffSGiannis Adamopoulos {
519ee3b7320SGiannis Adamopoulos if ((pbi->dwMask & ISFB_MASK_STATE) &&
520ee3b7320SGiannis Adamopoulos (pbi->dwState & ISFB_STATE_QLINKSMODE) &&
521ee3b7320SGiannis Adamopoulos (pbi->dwStateMask & ISFB_STATE_QLINKSMODE))
522ee3b7320SGiannis Adamopoulos {
523ee3b7320SGiannis Adamopoulos m_QLaunch = true;
524bab9a540SGiannis Adamopoulos m_textFlag = false;
525bab9a540SGiannis Adamopoulos if (m_hWnd)
526bab9a540SGiannis Adamopoulos SendMessage(m_hWnd, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
527ee3b7320SGiannis Adamopoulos }
528ee3b7320SGiannis Adamopoulos
529f0f1e5ffSGiannis Adamopoulos return E_NOTIMPL;
530f0f1e5ffSGiannis Adamopoulos }
531f0f1e5ffSGiannis Adamopoulos
532f0f1e5ffSGiannis Adamopoulos /*****************************************************************************/
533f0f1e5ffSGiannis Adamopoulos // *** IContextMenu ***
GetCommandString(UINT_PTR idCmd,UINT uFlags,UINT * pwReserved,LPSTR pszName,UINT cchMax)534f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax)
535f0f1e5ffSGiannis Adamopoulos {
536f0f1e5ffSGiannis Adamopoulos /*HRESULT hr = E_INVALIDARG;
537f0f1e5ffSGiannis Adamopoulos
538f0f1e5ffSGiannis Adamopoulos if (idCmd == IDM_DISPLAY)
539f0f1e5ffSGiannis Adamopoulos {
540f0f1e5ffSGiannis Adamopoulos switch (uFlags)
541f0f1e5ffSGiannis Adamopoulos {
542f0f1e5ffSGiannis Adamopoulos case GCS_HELPTEXTW:
543f0f1e5ffSGiannis Adamopoulos // Only useful for pre-Vista versions of Windows that
544f0f1e5ffSGiannis Adamopoulos // have a Status bar.
545f0f1e5ffSGiannis Adamopoulos hr = StringCchCopyW(reinterpret_cast<PWSTR>(pszName),
546f0f1e5ffSGiannis Adamopoulos cchMax,
547f0f1e5ffSGiannis Adamopoulos L"Display File Name");
548f0f1e5ffSGiannis Adamopoulos break;
549f0f1e5ffSGiannis Adamopoulos
550f0f1e5ffSGiannis Adamopoulos case GCS_VERBW:
551f0f1e5ffSGiannis Adamopoulos // GCS_VERBW is an optional feature that enables a caller
552f0f1e5ffSGiannis Adamopoulos // to discover the canonical name for the verb that is passed in
553f0f1e5ffSGiannis Adamopoulos // through idCommand.
554f0f1e5ffSGiannis Adamopoulos hr = StringCchCopyW(reinterpret_cast<PWSTR>(pszName),
555f0f1e5ffSGiannis Adamopoulos cchMax,
556f0f1e5ffSGiannis Adamopoulos L"DisplayFileName");
557f0f1e5ffSGiannis Adamopoulos break;
558f0f1e5ffSGiannis Adamopoulos }
559f0f1e5ffSGiannis Adamopoulos }
560f0f1e5ffSGiannis Adamopoulos return hr; */
561f0f1e5ffSGiannis Adamopoulos
562f0f1e5ffSGiannis Adamopoulos return S_OK;
563f0f1e5ffSGiannis Adamopoulos }
564f0f1e5ffSGiannis Adamopoulos
InvokeCommand(LPCMINVOKECOMMANDINFO pici)565f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::InvokeCommand(LPCMINVOKECOMMANDINFO pici)
566f0f1e5ffSGiannis Adamopoulos {
567f0f1e5ffSGiannis Adamopoulos if (!HIWORD(pici->lpVerb))
568f0f1e5ffSGiannis Adamopoulos {
569f0f1e5ffSGiannis Adamopoulos switch (LOWORD(pici->lpVerb))
570f0f1e5ffSGiannis Adamopoulos {
571f0f1e5ffSGiannis Adamopoulos case IDM_LARGE_ICONS:
572f0f1e5ffSGiannis Adamopoulos {
573f0f1e5ffSGiannis Adamopoulos m_iconFlag = false;
574f0f1e5ffSGiannis Adamopoulos
575f0f1e5ffSGiannis Adamopoulos HIMAGELIST* piml = (HIMAGELIST*) SendMessage(m_hWnd, TB_GETIMAGELIST, 0, 0);
576f0f1e5ffSGiannis Adamopoulos HRESULT hr = SHGetImageList(SHIL_LARGE, IID_IImageList, (void**)&piml);
577f0f1e5ffSGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr)) return hr;
578f0f1e5ffSGiannis Adamopoulos SendMessage(m_hWnd, TB_SETIMAGELIST, 0, (LPARAM)piml);
579f0f1e5ffSGiannis Adamopoulos hr = IUnknown_Exec(m_Site, IID_IDeskBand, DBID_BANDINFOCHANGED, 0, NULL, NULL);
580f0f1e5ffSGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr)) return hr;
581f0f1e5ffSGiannis Adamopoulos break;
582f0f1e5ffSGiannis Adamopoulos }
583f0f1e5ffSGiannis Adamopoulos case IDM_SMALL_ICONS:
584f0f1e5ffSGiannis Adamopoulos {
585f0f1e5ffSGiannis Adamopoulos m_iconFlag = true;
586f0f1e5ffSGiannis Adamopoulos
587f0f1e5ffSGiannis Adamopoulos HIMAGELIST* piml = (HIMAGELIST*)SendMessage(m_hWnd, TB_GETIMAGELIST, 0, 0);
588f0f1e5ffSGiannis Adamopoulos HRESULT hr = SHGetImageList(SHIL_SMALL, IID_IImageList, (void**)&piml);
589f0f1e5ffSGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr)) return hr;
590f0f1e5ffSGiannis Adamopoulos SendMessage(m_hWnd, TB_SETIMAGELIST, 0, (LPARAM)piml);
591f0f1e5ffSGiannis Adamopoulos hr = IUnknown_Exec(m_Site, IID_IDeskBand, DBID_BANDINFOCHANGED, 0, NULL, NULL);
592f0f1e5ffSGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr)) return hr;
593f0f1e5ffSGiannis Adamopoulos break;
594f0f1e5ffSGiannis Adamopoulos }
595e12763d5SStanislav Motylkov case IDM_OPEN_FOLDER:
596e12763d5SStanislav Motylkov {
597e12763d5SStanislav Motylkov SHELLEXECUTEINFO shexinfo;
598e12763d5SStanislav Motylkov
599e12763d5SStanislav Motylkov memset(&shexinfo, 0x0, sizeof(shexinfo));
600e12763d5SStanislav Motylkov
601e12763d5SStanislav Motylkov shexinfo.cbSize = sizeof(shexinfo);
602e12763d5SStanislav Motylkov shexinfo.fMask = SEE_MASK_IDLIST;
603e12763d5SStanislav Motylkov shexinfo.lpVerb = _T("open");
604e12763d5SStanislav Motylkov shexinfo.lpIDList = m_pidl;
605e12763d5SStanislav Motylkov shexinfo.nShow = SW_SHOW;
606e12763d5SStanislav Motylkov
607e12763d5SStanislav Motylkov if (!ShellExecuteEx(&shexinfo))
608e12763d5SStanislav Motylkov return E_FAIL;
609e12763d5SStanislav Motylkov
610e12763d5SStanislav Motylkov break;
611e12763d5SStanislav Motylkov }
612f0f1e5ffSGiannis Adamopoulos case IDM_SHOW_TEXT:
613f0f1e5ffSGiannis Adamopoulos {
614f0f1e5ffSGiannis Adamopoulos if (m_textFlag)
615f0f1e5ffSGiannis Adamopoulos {
616f0f1e5ffSGiannis Adamopoulos m_textFlag = false;
617f0f1e5ffSGiannis Adamopoulos SendMessage(m_hWnd, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
618f0f1e5ffSGiannis Adamopoulos HRESULT hr = IUnknown_Exec(m_Site, IID_IDeskBand, DBID_BANDINFOCHANGED, 0, NULL, NULL);
619f0f1e5ffSGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr)) return hr;
620f0f1e5ffSGiannis Adamopoulos }
621f0f1e5ffSGiannis Adamopoulos else
622f0f1e5ffSGiannis Adamopoulos {
623f0f1e5ffSGiannis Adamopoulos m_textFlag = true;
624f0f1e5ffSGiannis Adamopoulos SendMessage(m_hWnd, TB_SETEXTENDEDSTYLE, 0, 0);
625f0f1e5ffSGiannis Adamopoulos HRESULT hr = IUnknown_Exec(m_Site, IID_IDeskBand, DBID_BANDINFOCHANGED, 0, NULL, NULL);
626f0f1e5ffSGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr)) return hr;
627f0f1e5ffSGiannis Adamopoulos }
628f0f1e5ffSGiannis Adamopoulos break;
629f0f1e5ffSGiannis Adamopoulos }
630f0f1e5ffSGiannis Adamopoulos default:
631f0f1e5ffSGiannis Adamopoulos return E_FAIL;
632f0f1e5ffSGiannis Adamopoulos }
633f0f1e5ffSGiannis Adamopoulos }
634f0f1e5ffSGiannis Adamopoulos
635f0f1e5ffSGiannis Adamopoulos return S_OK;
636f0f1e5ffSGiannis Adamopoulos }
637f0f1e5ffSGiannis Adamopoulos
QueryContextMenu(HMENU hmenu,UINT indexMenu,UINT idCmdFirst,UINT idCmdLast,UINT uFlags)638f0f1e5ffSGiannis Adamopoulos STDMETHODIMP CISFBand::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
639f0f1e5ffSGiannis Adamopoulos {
640f0f1e5ffSGiannis Adamopoulos HMENU qMenu = LoadMenu(GetModuleHandleW(L"browseui.dll"), MAKEINTRESOURCE(IDM_POPUPMENU));
641f0f1e5ffSGiannis Adamopoulos
642f0f1e5ffSGiannis Adamopoulos if(m_textFlag)
643f0f1e5ffSGiannis Adamopoulos CheckMenuItem(qMenu, IDM_SHOW_TEXT, MF_CHECKED);
644f0f1e5ffSGiannis Adamopoulos else
645f0f1e5ffSGiannis Adamopoulos CheckMenuItem(qMenu, IDM_SHOW_TEXT, MF_UNCHECKED);
646f0f1e5ffSGiannis Adamopoulos
647f0f1e5ffSGiannis Adamopoulos if (m_iconFlag)
648f0f1e5ffSGiannis Adamopoulos {
649f0f1e5ffSGiannis Adamopoulos CheckMenuItem(qMenu, IDM_SMALL_ICONS, MF_CHECKED);
650f0f1e5ffSGiannis Adamopoulos CheckMenuItem(qMenu, IDM_LARGE_ICONS, MF_UNCHECKED);
651f0f1e5ffSGiannis Adamopoulos }
652f0f1e5ffSGiannis Adamopoulos else
653f0f1e5ffSGiannis Adamopoulos {
654f0f1e5ffSGiannis Adamopoulos CheckMenuItem(qMenu, IDM_LARGE_ICONS, MF_CHECKED);
655f0f1e5ffSGiannis Adamopoulos CheckMenuItem(qMenu, IDM_SMALL_ICONS, MF_UNCHECKED);
656f0f1e5ffSGiannis Adamopoulos }
657f0f1e5ffSGiannis Adamopoulos
658e12763d5SStanislav Motylkov if (_ILIsDesktop(m_pidl))
659e12763d5SStanislav Motylkov DeleteMenu(qMenu, IDM_OPEN_FOLDER, MF_BYCOMMAND);
660e12763d5SStanislav Motylkov
661f0f1e5ffSGiannis Adamopoulos UINT idMax = Shell_MergeMenus(hmenu, GetSubMenu(qMenu, 0), indexMenu, idCmdFirst, idCmdLast, MM_SUBMENUSHAVEIDS);
662f0f1e5ffSGiannis Adamopoulos DestroyMenu(qMenu);
663f0f1e5ffSGiannis Adamopoulos return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(idMax - idCmdFirst +1));
664f0f1e5ffSGiannis Adamopoulos }
665f0f1e5ffSGiannis Adamopoulos
666f0f1e5ffSGiannis Adamopoulos /*****************************************************************************/
667f0f1e5ffSGiannis Adamopoulos // C Constructor
668f0f1e5ffSGiannis Adamopoulos extern "C"
RSHELL_CISFBand_CreateInstance(REFIID riid,void ** ppv)6698a52080dSGiannis Adamopoulos HRESULT WINAPI RSHELL_CISFBand_CreateInstance(REFIID riid, void** ppv)
670f0f1e5ffSGiannis Adamopoulos {
671f0f1e5ffSGiannis Adamopoulos return ShellObjectCreator<CISFBand>(riid, ppv);
672f0f1e5ffSGiannis Adamopoulos }
673f0f1e5ffSGiannis Adamopoulos
674