4 * Copyright 2014 David Quintana
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <commoncontrols.h>
23 #include <shlwapi_undoc.h>
25 #include "CMenuBand.h"
26 #include "CMenuToolbars.h"
27 #include "CMenuFocusManager.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(CMenuBand
);
33 #define UNIMPLEMENTED TRACE("%s is UNIMPLEMENTED!\n", __FUNCTION__)
36 HRESULT WINAPI
CMenuBand_Constructor(REFIID riid
, LPVOID
*ppv
)
39 #if USE_SYSTEM_MENUBAND
40 hr
= CoCreateInstance(CLSID_MenuBand
,
47 CMenuBand
* site
= new CComObject
<CMenuBand
>();
52 hr
= site
->QueryInterface(riid
, ppv
);
54 if (FAILED_UNEXPECTEDLY(hr
))
61 CMenuBand::CMenuBand() :
62 m_staticToolbar(NULL
),
67 m_subMenuParent(NULL
),
73 m_topLevelWindow(NULL
),
80 m_focusManager
= CMenuFocusManager::AcquireManager();
83 CMenuBand::~CMenuBand()
85 CMenuFocusManager::ReleaseManager(m_focusManager
);
88 delete m_staticToolbar
;
94 HRESULT STDMETHODCALLTYPE
CMenuBand::Initialize(
95 IShellMenuCallback
*psmc
,
103 m_uIdAncestor
= uIdAncestor
;
108 _CallCB(SMC_CREATE
, 0, reinterpret_cast<LPARAM
>(&m_UserData
));
114 HRESULT STDMETHODCALLTYPE
CMenuBand::GetMenuInfo(
115 IShellMenuCallback
**ppsmc
,
120 if (!pdwFlags
) // maybe?
130 *puIdAncestor
= m_uIdAncestor
;
132 *pdwFlags
= m_dwFlags
;
137 HRESULT STDMETHODCALLTYPE
CMenuBand::SetMenu(
142 TRACE("CMenuBand::SetMenu called, hmenu=%p; hwnd=%p, flags=%x\n", hmenu
, hwnd
, dwFlags
);
144 BOOL created
= FALSE
;
146 if (m_staticToolbar
== NULL
)
148 m_staticToolbar
= new CMenuStaticToolbar(this);
154 HRESULT hr
= m_staticToolbar
->SetMenu(hmenu
, hwnd
, dwFlags
);
155 if (FAILED_UNEXPECTEDLY(hr
))
162 hr
= m_site
->GetWindow(&hwndParent
);
163 if (FAILED_UNEXPECTEDLY(hr
))
168 hr
= m_staticToolbar
->CreateToolbar(hwndParent
, m_dwFlags
);
169 if (FAILED_UNEXPECTEDLY(hr
))
172 hr
= m_staticToolbar
->FillToolbar();
176 hr
= m_staticToolbar
->FillToolbar(TRUE
);
183 HRESULT STDMETHODCALLTYPE
CMenuBand::GetMenu(
188 if (m_staticToolbar
== NULL
)
191 return m_staticToolbar
->GetMenu(phmenu
, phwnd
, pdwFlags
);
194 HRESULT STDMETHODCALLTYPE
CMenuBand::SetSite(IUnknown
*pUnkSite
)
201 if (pUnkSite
== NULL
)
205 hr
= pUnkSite
->QueryInterface(IID_PPV_ARG(IOleWindow
, &m_site
));
206 if (FAILED_UNEXPECTEDLY(hr
))
209 hr
= m_site
->GetWindow(&hwndParent
);
210 if (FAILED_UNEXPECTEDLY(hr
))
213 if (!::IsWindow(hwndParent
))
216 if (m_staticToolbar
!= NULL
)
218 hr
= m_staticToolbar
->CreateToolbar(hwndParent
, m_dwFlags
);
219 if (FAILED_UNEXPECTEDLY(hr
))
222 hr
= m_staticToolbar
->FillToolbar();
223 if (FAILED_UNEXPECTEDLY(hr
))
227 if (m_SFToolbar
!= NULL
)
229 hr
= m_SFToolbar
->CreateToolbar(hwndParent
, m_dwFlags
);
230 if (FAILED_UNEXPECTEDLY(hr
))
233 hr
= m_SFToolbar
->FillToolbar();
234 if (FAILED_UNEXPECTEDLY(hr
))
238 hr
= IUnknown_QueryService(m_site
, SID_SMenuPopup
, IID_PPV_ARG(IMenuPopup
, &m_subMenuParent
));
239 if (hr
!= E_NOINTERFACE
&& FAILED_UNEXPECTEDLY(hr
))
242 CComPtr
<IOleWindow
> pTopLevelWindow
;
243 hr
= IUnknown_QueryService(m_site
, SID_STopLevelBrowser
, IID_PPV_ARG(IOleWindow
, &pTopLevelWindow
));
244 if (FAILED_UNEXPECTEDLY(hr
))
247 return pTopLevelWindow
->GetWindow(&m_topLevelWindow
);
250 HRESULT STDMETHODCALLTYPE
CMenuBand::GetSite(REFIID riid
, PVOID
*ppvSite
)
255 return m_site
->QueryInterface(riid
, ppvSite
);
258 HRESULT STDMETHODCALLTYPE
CMenuBand::GetWindow(
261 if (m_SFToolbar
!= NULL
)
262 return m_SFToolbar
->GetWindow(phwnd
);
264 if (m_staticToolbar
!= NULL
)
265 return m_staticToolbar
->GetWindow(phwnd
);
270 HRESULT STDMETHODCALLTYPE
CMenuBand::OnPosRectChangeDB(RECT
*prc
)
272 SIZE maxStatic
= { 0 };
273 SIZE maxShlFld
= { 0 };
276 if (m_staticToolbar
!= NULL
)
277 hr
= m_staticToolbar
->GetSizes(NULL
, &maxStatic
, NULL
);
278 if (FAILED_UNEXPECTEDLY(hr
))
281 if (m_SFToolbar
!= NULL
)
282 hr
= m_SFToolbar
->GetSizes(NULL
, &maxShlFld
, NULL
);
283 if (FAILED_UNEXPECTEDLY(hr
))
286 if (m_staticToolbar
== NULL
&& m_SFToolbar
== NULL
)
289 int sy
= min(prc
->bottom
- prc
->top
, maxStatic
.cy
+ maxShlFld
.cy
);
291 int syStatic
= maxStatic
.cy
;
292 int syShlFld
= sy
- syStatic
;
296 m_SFToolbar
->SetPosSize(
299 prc
->right
- prc
->left
,
304 m_staticToolbar
->SetPosSize(
307 prc
->right
- prc
->left
,
314 HRESULT STDMETHODCALLTYPE
CMenuBand::GetBandInfo(
319 SIZE minStatic
= { 0 };
320 SIZE minShlFld
= { 0 };
321 SIZE maxStatic
= { 0 };
322 SIZE maxShlFld
= { 0 };
323 SIZE intStatic
= { 0 };
324 SIZE intShlFld
= { 0 };
328 if (m_staticToolbar
!= NULL
)
329 hr
= m_staticToolbar
->GetSizes(&minStatic
, &maxStatic
, &intStatic
);
330 if (FAILED_UNEXPECTEDLY(hr
))
333 if (m_SFToolbar
!= NULL
)
334 hr
= m_SFToolbar
->GetSizes(&minShlFld
, &maxShlFld
, &intShlFld
);
335 if (FAILED_UNEXPECTEDLY(hr
))
338 if (m_staticToolbar
== NULL
&& m_SFToolbar
== NULL
)
341 if (m_dwFlags
& SMINIT_VERTICAL
)
343 pdbi
->ptMinSize
.x
= max(minStatic
.cx
, minShlFld
.cx
) + 20;
344 pdbi
->ptMinSize
.y
= minStatic
.cy
+ minShlFld
.cy
;
345 pdbi
->ptMaxSize
.x
= max(maxStatic
.cx
, maxShlFld
.cx
) + 20;
346 pdbi
->ptMaxSize
.y
= maxStatic
.cy
+ maxShlFld
.cy
;
347 pdbi
->dwModeFlags
= DBIMF_VARIABLEHEIGHT
;
351 pdbi
->ptMinSize
.x
= minStatic
.cx
+ minShlFld
.cx
;
352 pdbi
->ptMinSize
.y
= max(minStatic
.cy
, minShlFld
.cy
);
353 pdbi
->ptMaxSize
.x
= maxStatic
.cx
+ maxShlFld
.cx
;
354 pdbi
->ptMaxSize
.y
= max(maxStatic
.cy
, maxShlFld
.cy
);
356 pdbi
->ptIntegral
.x
= max(intStatic
.cx
, intShlFld
.cx
);
357 pdbi
->ptIntegral
.y
= max(intStatic
.cy
, intShlFld
.cy
);
358 pdbi
->ptActual
= pdbi
->ptMinSize
;
363 HRESULT STDMETHODCALLTYPE
CMenuBand::ShowDW(BOOL fShow
)
370 if (m_staticToolbar
!= NULL
)
372 hr
= m_staticToolbar
->ShowWindow(fShow
);
373 if (FAILED_UNEXPECTEDLY(hr
))
377 if (m_SFToolbar
!= NULL
)
379 hr
= m_SFToolbar
->ShowWindow(fShow
);
380 if (FAILED_UNEXPECTEDLY(hr
))
386 hr
= _CallCB(SMC_INITMENU
, 0, 0);
387 if (FAILED_UNEXPECTEDLY(hr
))
390 else if (m_parentBand
)
392 m_parentBand
->SetClient(NULL
);
395 if (_IsPopup() == S_OK
)
398 hr
= m_focusManager
->PushMenuPopup(this);
400 hr
= m_focusManager
->PopMenuPopup(this);
405 hr
= m_focusManager
->PushMenuBar(this);
407 hr
= m_focusManager
->PopMenuBar(this);
415 HRESULT STDMETHODCALLTYPE
CMenuBand::CloseDW(DWORD dwReserved
)
419 if (m_staticToolbar
!= NULL
)
420 return m_staticToolbar
->Close();
422 if (m_SFToolbar
!= NULL
)
423 return m_SFToolbar
->Close();
428 HRESULT STDMETHODCALLTYPE
CMenuBand::UIActivateIO(BOOL fActivate
, LPMSG lpMsg
)
434 hr
= m_subMenuParent
->SetSubMenu(this, fActivate
);
435 if (FAILED_UNEXPECTEDLY(hr
))
441 CComPtr
<IOleWindow
> pTopLevelWindow
;
442 hr
= IUnknown_QueryService(m_site
, SID_SMenuPopup
, IID_PPV_ARG(IOleWindow
, &pTopLevelWindow
));
443 if (FAILED_UNEXPECTEDLY(hr
))
446 hr
= pTopLevelWindow
->GetWindow(&m_topLevelWindow
);
447 if (FAILED_UNEXPECTEDLY(hr
))
452 m_topLevelWindow
= NULL
;
458 HRESULT STDMETHODCALLTYPE
CMenuBand::Exec(const GUID
*pguidCmdGroup
, DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
463 if (IsEqualGUID(*pguidCmdGroup
, CLSID_MenuBand
))
465 if (nCmdID
== 16) // set (big) icon size
467 this->m_useBigIcons
= nCmdexecopt
== 2;
470 else if (nCmdID
== 19) // popup-related
474 else if (nCmdID
== 5) // select an item
476 if (nCmdexecopt
== 0) // first
478 _KeyboardItemChange(VK_HOME
);
482 _KeyboardItemChange(VK_END
);
494 HRESULT STDMETHODCALLTYPE
CMenuBand::QueryService(REFGUID guidService
, REFIID riid
, void **ppvObject
)
496 if (IsEqualIID(guidService
, SID_SMenuBandChild
) ||
497 IsEqualIID(guidService
, SID_SMenuBandBottom
) ||
498 IsEqualIID(guidService
, SID_SMenuBandBottomSelected
))
499 return this->QueryInterface(riid
, ppvObject
);
500 WARN("Unknown service requested %s\n", wine_dbgstr_guid(&guidService
));
501 return E_NOINTERFACE
;
504 HRESULT STDMETHODCALLTYPE
CMenuBand::Popup(POINTL
*ppt
, RECTL
*prcExclude
, MP_POPUPFLAGS dwFlags
)
510 HRESULT STDMETHODCALLTYPE
CMenuBand::OnSelect(DWORD dwSelectType
)
512 switch (dwSelectType
)
514 case MPOS_CHILDTRACKING
:
515 if (!m_subMenuParent
)
517 // TODO: Cancel timers?
518 return m_subMenuParent
->OnSelect(dwSelectType
);
519 case MPOS_SELECTLEFT
:
521 m_subMenuChild
->OnSelect(MPOS_CANCELLEVEL
);
522 if (!m_subMenuParent
)
524 return m_subMenuParent
->OnSelect(dwSelectType
);
525 case MPOS_SELECTRIGHT
:
526 if (!m_subMenuParent
)
528 return m_subMenuParent
->OnSelect(dwSelectType
);
530 case MPOS_FULLCANCEL
:
532 m_subMenuChild
->OnSelect(dwSelectType
);
533 if (!m_subMenuParent
)
535 return m_subMenuParent
->OnSelect(dwSelectType
);
536 case MPOS_CANCELLEVEL
:
538 m_subMenuChild
->OnSelect(dwSelectType
);
544 HRESULT STDMETHODCALLTYPE
CMenuBand::SetSubMenu(IMenuPopup
*pmp
, BOOL fSet
)
550 HRESULT
CMenuBand::_SetChildBand(CMenuBand
* child
)
555 _ChangePopupItem(NULL
, -1);
560 HRESULT
CMenuBand::_SetParentBand(CMenuBand
* parent
)
562 m_parentBand
= parent
;
566 HRESULT
CMenuBand::_IsPopup()
568 return m_subMenuParent
? S_OK
: S_FALSE
;
571 HRESULT
CMenuBand::_IsTracking()
573 return m_popupBar
!= NULL
;
576 HRESULT STDMETHODCALLTYPE
CMenuBand::SetClient(IUnknown
*punkClient
)
578 m_subMenuChild
= NULL
;
585 HRESULT hr
= punkClient
->QueryInterface(IID_PPV_ARG(IMenuPopup
, &m_subMenuChild
));
590 HRESULT STDMETHODCALLTYPE
CMenuBand::GetClient(IUnknown
**ppunkClient
)
592 // HACK, so I can test for a submenu in the DeskBar
596 *ppunkClient
= m_subMenuChild
;
603 HRESULT STDMETHODCALLTYPE
CMenuBand::IsMenuMessage(MSG
*pmsg
)
608 HRESULT STDMETHODCALLTYPE
CMenuBand::TranslateMenuMessage(MSG
*pmsg
, LRESULT
*plRet
)
613 HRESULT STDMETHODCALLTYPE
CMenuBand::SetShellFolder(IShellFolder
*psf
, LPCITEMIDLIST pidlFolder
, HKEY hKey
, DWORD dwFlags
)
615 if (m_SFToolbar
== NULL
)
617 m_SFToolbar
= new CMenuSFToolbar(this);
620 HRESULT hr
= m_SFToolbar
->SetShellFolder(psf
, pidlFolder
, hKey
, dwFlags
);
621 if (FAILED_UNEXPECTEDLY(hr
))
628 hr
= m_site
->GetWindow(&hwndParent
);
629 if (FAILED_UNEXPECTEDLY(hr
))
632 hr
= m_SFToolbar
->CreateToolbar(hwndParent
, m_dwFlags
);
633 if (FAILED_UNEXPECTEDLY(hr
))
636 hr
= m_SFToolbar
->FillToolbar();
642 HRESULT STDMETHODCALLTYPE
CMenuBand::GetShellFolder(DWORD
*pdwFlags
, LPITEMIDLIST
*ppidl
, REFIID riid
, void **ppv
)
645 return m_SFToolbar
->GetShellFolder(pdwFlags
, ppidl
, riid
, ppv
);
649 HRESULT STDMETHODCALLTYPE
CMenuBand::OnWinEvent(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, LRESULT
*theResult
)
653 if (m_staticToolbar
&& m_staticToolbar
->IsWindowOwner(hWnd
) == S_OK
)
655 return m_staticToolbar
->OnWinEvent(hWnd
, uMsg
, wParam
, lParam
, theResult
);
658 if (m_SFToolbar
&& m_SFToolbar
->IsWindowOwner(hWnd
) == S_OK
)
660 return m_SFToolbar
->OnWinEvent(hWnd
, uMsg
, wParam
, lParam
, theResult
);
666 HRESULT STDMETHODCALLTYPE
CMenuBand::IsWindowOwner(HWND hWnd
)
668 if (m_staticToolbar
&& m_staticToolbar
->IsWindowOwner(hWnd
) == S_OK
)
671 if (m_SFToolbar
&& m_SFToolbar
->IsWindowOwner(hWnd
) == S_OK
)
677 HRESULT
CMenuBand::_CallCBWithItemId(UINT id
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
679 return _CallCB(uMsg
, wParam
, lParam
, id
);
682 HRESULT
CMenuBand::_CallCBWithItemPidl(LPITEMIDLIST pidl
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
684 return _CallCB(uMsg
, wParam
, lParam
, 0, pidl
);
687 HRESULT
CMenuBand::_CallCB(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT id
, LPITEMIDLIST pidl
)
695 SMDATA smData
= { 0 };
696 smData
.punk
= static_cast<IShellMenu2
*>(this);
698 smData
.uIdParent
= m_uId
;
699 smData
.uIdAncestor
= m_uIdAncestor
;
700 smData
.pidlItem
= pidl
;
703 smData
.hmenu
= m_hmenu
;
704 smData
.pvUserData
= NULL
;
706 m_SFToolbar
->GetShellFolder(NULL
, &smData
.pidlFolder
, IID_PPV_ARG(IShellFolder
, &smData
.psf
));
707 HRESULT hr
= m_psmc
->CallbackSM(&smData
, uMsg
, wParam
, lParam
);
708 ILFree(smData
.pidlFolder
);
710 smData
.psf
->Release();
714 HRESULT
CMenuBand::_TrackSubMenu(HMENU popup
, INT x
, INT y
, RECT
& rcExclude
)
716 TPMPARAMS params
= { sizeof(TPMPARAMS
), rcExclude
};
717 UINT flags
= TPM_VERPOSANIMATION
| TPM_VERTICAL
| TPM_LEFTALIGN
;
718 HWND hwnd
= m_menuOwner
? m_menuOwner
: m_topLevelWindow
;
720 m_focusManager
->PushTrackedPopup(popup
);
721 ::TrackPopupMenuEx(popup
, flags
, x
, y
, hwnd
, ¶ms
);
722 m_focusManager
->PopTrackedPopup(popup
);
724 _DisableMouseTrack(FALSE
);
729 HRESULT
CMenuBand::_TrackContextMenu(IContextMenu
* contextMenu
, INT x
, INT y
)
733 HMENU popup
= CreatePopupMenu();
738 TRACE("Before Query\n");
739 hr
= contextMenu
->QueryContextMenu(popup
, 0, 0, UINT_MAX
, CMF_NORMAL
);
740 if (FAILED_UNEXPECTEDLY(hr
))
742 TRACE("Query failed\n");
747 HWND hwnd
= m_menuOwner
? m_menuOwner
: m_topLevelWindow
;
749 TRACE("Before Tracking\n");
750 uCommand
= ::TrackPopupMenuEx(popup
, TPM_RETURNCMD
, x
, y
, hwnd
, NULL
);
754 TRACE("Before InvokeCommand\n");
755 CMINVOKECOMMANDINFO cmi
= { 0 };
756 cmi
.cbSize
= sizeof(cmi
);
757 cmi
.lpVerb
= MAKEINTRESOURCEA(uCommand
);
759 hr
= contextMenu
->InvokeCommand(&cmi
);
763 TRACE("TrackPopupMenu failed. Code=%d, LastError=%d\n", uCommand
, GetLastError());
771 HRESULT
CMenuBand::_GetTopLevelWindow(HWND
*topLevel
)
773 *topLevel
= m_topLevelWindow
;
777 HRESULT
CMenuBand::_ChangeHotItem(CMenuToolbarBase
* tb
, INT id
, DWORD dwFlags
)
779 if (m_hotBar
== tb
&& m_hotItem
== id
)
782 TRACE("Hot item changed from %p %p, to %p %p\n", m_hotBar
, m_hotItem
, tb
, id
);
788 if (m_staticToolbar
) m_staticToolbar
->ChangeHotItem(tb
, id
, dwFlags
);
789 if (m_SFToolbar
) m_SFToolbar
->ChangeHotItem(tb
, id
, dwFlags
);
791 _MenuItemHotTrack(MPOS_CHILDTRACKING
);
797 HRESULT
CMenuBand::_ChangePopupItem(CMenuToolbarBase
* tb
, INT id
)
799 TRACE("Popup item changed from %p %p, to %p %p\n", m_popupBar
, m_popupItem
, tb
, id
);
803 if (m_staticToolbar
) m_staticToolbar
->ChangePopupItem(tb
, id
);
804 if (m_SFToolbar
) m_SFToolbar
->ChangePopupItem(tb
, id
);
809 HRESULT
CMenuBand::_KeyboardItemChange(DWORD change
)
812 CMenuToolbarBase
*tb
= m_hotBar
;
816 // If no hot item was selected choose the appropriate toolbar
817 if (change
== VK_UP
|| change
== VK_END
)
820 tb
= m_staticToolbar
;
824 else if (change
== VK_DOWN
|| change
== VK_HOME
)
829 tb
= m_staticToolbar
;
833 // Ask the first toolbar to change
834 hr
= tb
->KeyboardItemChange(change
);
839 // Select the second toolbar based on the first
840 if (tb
== m_SFToolbar
&& m_staticToolbar
)
841 tb
= m_staticToolbar
;
842 else if (m_SFToolbar
)
848 // Ask the second toolbar to change
849 return tb
->KeyboardItemChange(change
== VK_DOWN
? VK_HOME
: VK_END
);
852 HRESULT
CMenuBand::_MenuItemHotTrack(DWORD changeType
)
856 if (m_dwFlags
& SMINIT_VERTICAL
)
862 return _KeyboardItemChange(changeType
);
864 // TODO: Left/Right across multi-column menus, if they ever work.
866 changeType
= MPOS_SELECTLEFT
;
869 changeType
= MPOS_SELECTRIGHT
;
875 // In horizontal menubars, left/right are equivalent to vertical's up/down
879 hr
= _KeyboardItemChange(VK_UP
);
883 hr
= _KeyboardItemChange(VK_DOWN
);
892 m_hotBar
->ExecuteItem(m_hotItem
);
895 case MPOS_SELECTLEFT
:
896 if (m_parentBand
&& m_parentBand
->_IsPopup()==S_FALSE
)
897 return m_parentBand
->_MenuItemHotTrack(VK_LEFT
);
899 return m_subMenuChild
->OnSelect(MPOS_CANCELLEVEL
);
900 if (!m_subMenuParent
)
902 return m_subMenuParent
->OnSelect(MPOS_CANCELLEVEL
);
904 case MPOS_SELECTRIGHT
:
905 if (m_hotBar
&& m_hotItem
>= 0 && m_hotBar
->PopupItem(m_hotItem
, TRUE
) == S_OK
)
908 return m_parentBand
->_MenuItemHotTrack(VK_RIGHT
);
909 if (!m_subMenuParent
)
911 return m_subMenuParent
->OnSelect(MPOS_SELECTRIGHT
);
914 if (!m_subMenuParent
)
916 return m_subMenuParent
->OnSelect(changeType
);
922 HRESULT
CMenuBand::_CancelCurrentPopup()
927 HRESULT hr
= m_subMenuChild
->OnSelect(MPOS_CANCELLEVEL
);
931 HRESULT
CMenuBand::_OnPopupSubMenu(IShellMenu
* childShellMenu
, POINTL
* pAt
, RECTL
* pExclude
, BOOL keyInitiated
)
934 IBandSite
* pBandSite
;
937 // Create the necessary objects
938 hr
= CMenuSite_Constructor(IID_PPV_ARG(IBandSite
, &pBandSite
));
939 if (FAILED_UNEXPECTEDLY(hr
))
942 hr
= CMenuDeskBar_Constructor(IID_PPV_ARG(IDeskBar
, &pDeskBar
));
943 if (FAILED_UNEXPECTEDLY(hr
))
946 hr
= pDeskBar
->SetClient(pBandSite
);
947 if (FAILED_UNEXPECTEDLY(hr
))
950 hr
= pBandSite
->AddBand(childShellMenu
);
951 if (FAILED_UNEXPECTEDLY(hr
))
955 CComPtr
<IMenuPopup
> popup
;
956 hr
= pDeskBar
->QueryInterface(IID_PPV_ARG(IMenuPopup
, &popup
));
957 if (FAILED_UNEXPECTEDLY(hr
))
960 m_subMenuChild
= popup
;
963 IUnknown_SetSite(popup
, m_subMenuParent
);
965 IUnknown_SetSite(popup
, m_site
);
967 DWORD flags
= MPPF_RIGHT
;
969 if (keyInitiated
&& m_dwFlags
& SMINIT_VERTICAL
)
970 flags
|= MPPF_INITIALSELECT
;
972 popup
->Popup(pAt
, pExclude
, flags
);
977 HRESULT
CMenuBand::_DisableMouseTrack(BOOL bDisable
)
980 m_staticToolbar
->DisableMouseTrack(bDisable
);
982 m_SFToolbar
->DisableMouseTrack(bDisable
);
986 HRESULT
CMenuBand::_KillPopupTimers()
990 hr
= m_staticToolbar
->KillPopupTimer();
995 hr
= m_SFToolbar
->KillPopupTimer();
1000 HRESULT STDMETHODCALLTYPE
CMenuBand::InvalidateItem(LPSMDATA psmd
, DWORD dwFlags
)
1006 HRESULT STDMETHODCALLTYPE
CMenuBand::GetState(LPSMDATA psmd
)
1012 HRESULT STDMETHODCALLTYPE
CMenuBand::SetMenuToolbar(IUnknown
*punk
, DWORD dwFlags
)
1018 HRESULT STDMETHODCALLTYPE
CMenuBand::ResizeBorderDW(LPCRECT prcBorder
, IUnknown
*punkToolbarSite
, BOOL fReserved
)
1024 HRESULT STDMETHODCALLTYPE
CMenuBand::ContextSensitiveHelp(BOOL fEnterMode
)
1030 HRESULT STDMETHODCALLTYPE
CMenuBand::GetSubMenu(THIS
)
1036 HRESULT STDMETHODCALLTYPE
CMenuBand::SetToolbar(THIS
)
1042 HRESULT STDMETHODCALLTYPE
CMenuBand::SetMinWidth(THIS
)
1048 HRESULT STDMETHODCALLTYPE
CMenuBand::SetNoBorder(THIS
)
1054 HRESULT STDMETHODCALLTYPE
CMenuBand::SetTheme(THIS
)
1060 HRESULT STDMETHODCALLTYPE
CMenuBand::GetTop(THIS
)
1066 HRESULT STDMETHODCALLTYPE
CMenuBand::GetBottom(THIS
)
1072 HRESULT STDMETHODCALLTYPE
CMenuBand::GetTracked(THIS
)
1078 HRESULT STDMETHODCALLTYPE
CMenuBand::GetParentSite(THIS
)
1084 HRESULT STDMETHODCALLTYPE
CMenuBand::GetState(THIS
)
1090 HRESULT STDMETHODCALLTYPE
CMenuBand::DoDefaultAction(THIS
)
1096 HRESULT STDMETHODCALLTYPE
CMenuBand::IsEmpty(THIS
)
1102 HRESULT STDMETHODCALLTYPE
CMenuBand::HasFocusIO()
1109 HRESULT STDMETHODCALLTYPE
CMenuBand::TranslateAcceleratorIO(LPMSG lpMsg
)
1111 // TODO: Alt down -> toggle menu focus
1115 HRESULT STDMETHODCALLTYPE
CMenuBand::IsDirty()
1121 HRESULT STDMETHODCALLTYPE
CMenuBand::Load(IStream
*pStm
)
1127 HRESULT STDMETHODCALLTYPE
CMenuBand::Save(IStream
*pStm
, BOOL fClearDirty
)
1133 HRESULT STDMETHODCALLTYPE
CMenuBand::GetSizeMax(ULARGE_INTEGER
*pcbSize
)
1139 HRESULT STDMETHODCALLTYPE
CMenuBand::GetClassID(CLSID
*pClassID
)
1145 HRESULT STDMETHODCALLTYPE
CMenuBand::QueryStatus(const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)