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