ReactOS 0.4.17-dev-1196-gb6224c3
CMenuToolbarBase Class Referenceabstract

#include <CMenuToolbars.h>

Inheritance diagram for CMenuToolbarBase:
Collaboration diagram for CMenuToolbarBase:

Public Member Functions

 CMenuToolbarBase (CMenuBand *menuBand, BOOL usePager)
 
virtual ~CMenuToolbarBase ()
 
HRESULT IsWindowOwner (HWND hwnd)
 
HRESULT CreateToolbar (HWND hwndParent, DWORD dwFlags)
 
HRESULT GetWindow (HWND *phwnd)
 
HRESULT ShowDW (BOOL fShow)
 
HRESULT Close ()
 
HRESULT OnWinEvent (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
 
HRESULT ChangeHotItem (CMenuToolbarBase *toolbar, INT item, DWORD dwFlags)
 
HRESULT ChangePopupItem (CMenuToolbarBase *toolbar, INT item)
 
HRESULT PopupSubMenu (UINT itemId, UINT index, IShellMenu *childShellMenu, BOOL keyInitiated)
 
HRESULT PopupSubMenu (UINT itemId, UINT index, HMENU menu)
 
HRESULT TrackContextMenu (IContextMenu *contextMenu, POINT pt)
 
HRESULT KeyboardItemChange (DWORD changeType)
 
HRESULT PrepareExecuteItem (INT iItem)
 
HRESULT ExecuteItem ()
 
HRESULT GetSizes (SIZE *pMinSize, SIZE *pMaxSize, SIZE *pIntegralSize)
 
HRESULT SetPosSize (int x, int y, int cx, int cy)
 
void InvalidateDraw ()
 
HRESULT DisableMouseTrack (BOOL bDisable)
 
virtual HRESULT FillToolbar (BOOL clearFirst=FALSE)=0
 
HRESULT CancelCurrentPopup ()
 
HRESULT PopupItem (INT iItem, BOOL keyInitiated)
 
HRESULT GetDataFromId (INT iItem, INT *pIndex, DWORD_PTR *pData)
 
HRESULT KillPopupTimer ()
 
HRESULT MenuBarMouseDown (INT iIndex, BOOL isLButton)
 
HRESULT MenuBarMouseUp (INT iIndex, BOOL isLButton)
 
HRESULT ProcessClick (INT iItem)
 
HRESULT ProcessContextMenu (INT iItem)
 
HRESULT BeforeCancelPopup ()
 

Protected Member Functions

virtual HRESULT OnDeletingButton (const NMTOOLBAR *tb) PURE
 
virtual HRESULT InternalGetTooltip (INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax) PURE
 
virtual HRESULT InternalExecuteItem (INT iItem, INT index, DWORD_PTR dwData) PURE
 
virtual HRESULT InternalPopupItem (INT iItem, INT index, DWORD_PTR dwData, BOOL keyInitiated) PURE
 
virtual HRESULT InternalHasSubMenu (INT iItem, INT index, DWORD_PTR dwData) PURE
 
virtual HRESULT InternalContextMenu (INT iItem, INT index, DWORD_PTR dwData, POINT pt) PURE
 
HRESULT AddButton (DWORD commandId, LPCWSTR caption, BOOL hasSubMenu, INT iconId, DWORD_PTR buttonData, BOOL last)
 
HRESULT AddSeparator (BOOL last)
 
HRESULT AddPlaceholder ()
 
HRESULT ClearToolbar ()
 
HWND GetToolbar ()
 

Protected Attributes

CMenuBand * m_menuBand
 
DWORD m_dwMenuFlags
 
BOOL m_hasSizes
 
SIZE m_idealSize
 
SIZE m_itemSize
 
BOOL m_usePager
 
CMenuToolbarBase * m_hotBar
 
INT m_hotItem
 
CMenuToolbarBase * m_popupBar
 
INT m_popupItem
 
DWORD m_initFlags
 
BOOL m_isTrackingPopup
 
INT m_executeIndex
 
INT m_executeItem
 
DWORD_PTR m_executeData
 
BOOL m_cancelingPopup
 

Private Member Functions

HRESULT UpdateImageLists ()
 
HRESULT OnPagerCalcSize (LPNMPGCALCSIZE csize)
 
HRESULT OnCustomDraw (LPNMTBCUSTOMDRAW cdraw, LRESULT *theResult)
 
HRESULT OnGetInfoTip (NMTBGETINFOTIP *tip)
 
LRESULT IsTrackedItem (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT ChangeTrackedItem (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnWinEventWrap (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
HRESULT OnPopupTimer (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 

Private Attributes

CContainedWindow m_pager
 
HFONT m_marlett
 
BOOL m_useFlatMenus
 
BOOL m_disableMouseTrack
 
BOOL m_timerEnabled
 

Detailed Description

Definition at line 28 of file CMenuToolbars.h.

Constructor & Destructor Documentation

◆ CMenuToolbarBase()

CMenuToolbarBase::CMenuToolbarBase ( CMenuBand *  menuBand,
BOOL  usePager 
)

Definition at line 281 of file CMenuToolbars.cpp.

281 :
286 m_menuBand(menuBand),
287 m_dwMenuFlags(0),
289 m_usePager(usePager),
290 m_hotBar(NULL),
291 m_hotItem(-1),
293 m_popupItem(-1),
296{
297 m_idealSize.cx = 0;
298 m_idealSize.cy = 0;
299 m_itemSize.cx = 0;
300 m_itemSize.cy = 0;
302 0, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET,
304 DEFAULT_QUALITY, FF_DONTCARE, L"Marlett");
305}
CContainedWindow m_pager
Definition: CMenuToolbars.h:31
CMenuToolbarBase * m_popupBar
Definition: CMenuToolbars.h:47
CMenuToolbarBase * m_hotBar
Definition: CMenuToolbars.h:45
CMenuBand * m_menuBand
Definition: CMenuToolbars.h:39
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define L(x)
Definition: resources.c:13
#define WC_PAGESCROLLER
Definition: commctrl.h:4505
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
#define DEFAULT_QUALITY
Definition: wingdi.h:436
#define FF_DONTCARE
Definition: wingdi.h:448
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define CreateFont
Definition: wingdi.h:4889
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426

◆ ~CMenuToolbarBase()

CMenuToolbarBase::~CMenuToolbarBase ( )
virtual

Definition at line 307 of file CMenuToolbars.cpp.

308{
309 if (m_hWnd)
310 {
311 ClearToolbar();
313 }
314
315 if (m_pager.m_hWnd)
316 m_pager.DestroyWindow();
317
319}
pKey DeleteObject()
BOOL WINAPI DestroyWindow(_In_ HWND)

Member Function Documentation

◆ AddButton()

HRESULT CMenuToolbarBase::AddButton ( DWORD  commandId,
LPCWSTR  caption,
BOOL  hasSubMenu,
INT  iconId,
DWORD_PTR  buttonData,
BOOL  last 
)
protected

Definition at line 1015 of file CMenuToolbars.cpp.

1016{
1017 TBBUTTON tbb = { 0 };
1018
1020#if !USE_TBSTYLE_EX_VERTICAL
1021 if (!last && (m_initFlags & SMINIT_VERTICAL))
1022 tbb.fsState |= TBSTATE_WRAP;
1023#endif
1025
1026 if (hasSubMenu && (m_initFlags & SMINIT_VERTICAL))
1027 tbb.fsStyle |= BTNS_DROPDOWN;
1028
1029 if (!(m_initFlags & SMINIT_VERTICAL))
1030 tbb.fsStyle |= BTNS_AUTOSIZE;
1031
1032 tbb.iString = (INT_PTR) caption;
1033 tbb.idCommand = commandId;
1034
1035 tbb.iBitmap = iconId;
1036 tbb.dwData = buttonData;
1037
1038 m_hasSizes = FALSE;
1039
1040 if (!AddButtons(1, &tbb))
1042 return S_OK;
1043}
#define S_OK
Definition: intsafe.h:52
static const LARGE_INTEGER *static const HANDLE const LARGE_INTEGER *static PSLIST_ENTRY PSLIST_ENTRY last
Definition: sync.c:64
#define BTNS_AUTOSIZE
Definition: commctrl.h:1004
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define BTNS_DROPDOWN
Definition: commctrl.h:1003
#define TBSTATE_WRAP
Definition: commctrl.h:977
#define BTNS_CHECKGROUP
Definition: commctrl.h:1002
BYTE fsState
Definition: commctrl.h:951
INT_PTR iString
Definition: commctrl.h:959
int idCommand
Definition: commctrl.h:950
DWORD_PTR dwData
Definition: commctrl.h:958
int iBitmap
Definition: commctrl.h:949
BYTE fsStyle
Definition: commctrl.h:952
int32_t INT_PTR
Definition: typedefs.h:64
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

Referenced by CMenuStaticToolbar::FillToolbar(), and CMenuSFToolbar::FillToolbar().

◆ AddPlaceholder()

HRESULT CMenuToolbarBase::AddPlaceholder ( )
protected

Definition at line 1065 of file CMenuToolbars.cpp.

1066{
1067 TBBUTTON tbb = { 0 };
1068 WCHAR MenuString[128];
1069
1070 LoadStringW(GetModuleHandle(L"shell32.dll"), IDS_MENU_EMPTY, MenuString, _countof(MenuString));
1071
1072 tbb.fsState = 0;
1073 tbb.fsStyle = 0;
1074 tbb.iString = (INT_PTR) MenuString;
1075 tbb.iBitmap = -1;
1076
1077 m_hasSizes = FALSE;
1078
1079 if (!AddButtons(1, &tbb))
1081
1082 return S_OK;
1083}
#define IDS_MENU_EMPTY
short WCHAR
Definition: pedump.c:58
#define LoadStringW
Definition: utils.h:64
#define _countof(array)
Definition: sndvol32.h:70
#define GetModuleHandle
Definition: winbase.h:3550

Referenced by CMenuSFToolbar::FillToolbar().

◆ AddSeparator()

HRESULT CMenuToolbarBase::AddSeparator ( BOOL  last)
protected

Definition at line 1045 of file CMenuToolbars.cpp.

1046{
1047 TBBUTTON tbb = { 0 };
1048
1050#if !USE_TBSTYLE_EX_VERTICAL
1051 if (!last && (m_initFlags & SMINIT_VERTICAL))
1052 tbb.fsState |= TBSTATE_WRAP;
1053#endif
1054 tbb.fsStyle = BTNS_SEP;
1055 tbb.iBitmap = 0;
1056
1057 m_hasSizes = FALSE;
1058
1059 if (!AddButtons(1, &tbb))
1061
1062 return S_OK;
1063}
#define BTNS_SEP
Definition: commctrl.h:999

Referenced by CMenuStaticToolbar::FillToolbar().

◆ BeforeCancelPopup()

HRESULT CMenuToolbarBase::BeforeCancelPopup ( )

Definition at line 814 of file CMenuToolbars.cpp.

815{
817 TRACE("BeforeCancelPopup\n");
818 return S_OK;
819}
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by CMenuBand::_BeforeCancelPopup().

◆ CancelCurrentPopup()

HRESULT CMenuToolbarBase::CancelCurrentPopup ( )

Definition at line 1124 of file CMenuToolbars.cpp.

1125{
1127}
HRESULT _CancelCurrentPopup()
Definition: CMenuBand.cpp:1049

Referenced by OnPopupTimer(), and PopupItem().

◆ ChangeHotItem()

HRESULT CMenuToolbarBase::ChangeHotItem ( CMenuToolbarBase *  toolbar,
INT  item,
DWORD  dwFlags 
)

Definition at line 598 of file CMenuToolbars.cpp.

599{
600 // Ignore the change if it already matches the stored info
601 if (m_hotBar == toolbar && m_hotItem == item)
602 return S_FALSE;
603
604 // Prevent a change of hot item if the change was triggered by the mouse,
605 // and mouse tracking is disabled.
607 {
608 TRACE("Hot item change prevented by DisableMouseTrack\n");
609 return S_OK;
610 }
611
612 // Notify the toolbar if the hot-tracking left this toolbar
613 if (m_hotBar == this && toolbar != this)
614 {
615 SetHotItem(-1);
616 }
617
618 TRACE("Hot item changed from %p %p, to %p %p\n", m_hotBar, m_hotItem, toolbar, item);
619 m_hotBar = toolbar;
620 m_hotItem = item;
621
622 if (m_hotBar == this)
623 {
624 if (m_isTrackingPopup && !(m_initFlags & SMINIT_VERTICAL))
625 {
626 // If the menubar has an open submenu, switch to the new item's submenu immediately
628 }
629 else if (dwFlags & HICF_MOUSE)
630 {
631 // Vertical menus show/hide the submenu after a delay,
632 // but only with the mouse.
633 if (m_initFlags & SMINIT_VERTICAL)
634 {
635 DWORD elapsed = 0;
636 SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &elapsed, 0);
637 SetTimer(TIMERID_HOTTRACK, elapsed);
639 TRACE("SetTimer called with m_hotItem=%d\n", m_hotItem);
640 }
641 }
642 else
643 {
645 info.cbSize = sizeof(info);
646 info.dwMask = 0;
647
648 int index = GetButtonInfo(item, &info);
649
650 SetHotItem(index);
651 }
652 }
653
655 return S_OK;
656}
#define TIMERID_HOTTRACK
HRESULT PopupItem(INT iItem, BOOL keyInitiated)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint index
Definition: glext.h:6031
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define HICF_MOUSE
Definition: commctrl.h:1326
#define TBBUTTONINFO
Definition: commctrl.h:1254
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define SystemParametersInfo
Definition: winuser.h:6024
#define S_FALSE
Definition: winerror.h:3451

Referenced by CMenuBand::_ChangeHotItem().

◆ ChangePopupItem()

HRESULT CMenuToolbarBase::ChangePopupItem ( CMenuToolbarBase *  toolbar,
INT  item 
)

Definition at line 658 of file CMenuToolbars.cpp.

659{
660 // Ignore the change if it already matches the stored info
661 if (m_popupBar == toolbar && m_popupItem == item)
662 return S_FALSE;
663
664 // Notify the toolbar if the popup-tracking this toolbar
665 if (m_popupBar == this && toolbar != this)
666 {
667 CheckButton(m_popupItem, FALSE);
669 }
670
671 m_popupBar = toolbar;
673
674 if (m_popupBar == this)
675 {
676 CheckButton(m_popupItem, TRUE);
677 }
678
680 return S_OK;
681}

Referenced by CMenuBand::_ChangePopupItem().

◆ ChangeTrackedItem()

LRESULT CMenuToolbarBase::ChangeTrackedItem ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL &  bHandled 
)
private

Definition at line 706 of file CMenuToolbars.cpp.

707{
708 TBBUTTON btn;
709 BOOL wasTracking = LOWORD(lParam);
710 BOOL mouse = HIWORD(lParam);
711 INT idx = (INT)wParam;
712
713 if (idx < 0)
714 {
717 }
718
719 if (!GetButton(idx, &btn))
720 return E_FAIL;
721
722 TRACE("ChangeTrackedItem %d, %d\n", idx, wasTracking);
723 m_isTrackingPopup = wasTracking;
724 return m_menuBand->_ChangeHotItem(this, btn.idCommand, mouse ? HICF_MOUSE : 0);
725}
HRESULT _ChangeHotItem(CMenuToolbarBase *tb, INT id, DWORD dwFlags)
Definition: CMenuBand.cpp:891
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define E_FAIL
Definition: ddrawi.h:102
unsigned int idx
Definition: utils.c:40
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LOWORD(l)
Definition: pedump.c:82
#define INT
Definition: polytest.cpp:20
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247

◆ ClearToolbar()

HRESULT CMenuToolbarBase::ClearToolbar ( )
protected

Definition at line 1085 of file CMenuToolbars.cpp.

1086{
1087 while (DeleteButton(0))
1088 {
1089 // empty;
1090 }
1091 m_hasSizes = FALSE;
1092 return S_OK;
1093}

Referenced by CMenuStaticToolbar::FillToolbar(), CMenuStaticToolbar::SetMenu(), CMenuSFToolbar::SetShellFolder(), and ~CMenuToolbarBase().

◆ Close()

HRESULT CMenuToolbarBase::Close ( )

Definition at line 378 of file CMenuToolbars.cpp.

379{
380 if (m_hWnd)
382
383 if (m_pager.m_hWnd)
384 m_pager.DestroyWindow();
385
386 return S_OK;
387}

Referenced by CMenuBand::CloseDW().

◆ CreateToolbar()

HRESULT CMenuToolbarBase::CreateToolbar ( HWND  hwndParent,
DWORD  dwFlags 
)

Definition at line 389 of file CMenuToolbars.cpp.

390{
395
396 if (dwFlags & SMINIT_VERTICAL)
397 {
398 // Activate vertical semantics
399 tbStyles |= CCS_VERT;
400
401#if USE_TBSTYLE_EX_VERTICAL
402 tbExStyles |= TBSTYLE_EX_VERTICAL;
403#endif
404 }
405
407
408 // Get a temporary rect to use while creating the toolbar window.
409 // Ensure that it is not a null rect.
410 RECT rc;
411 if (!::GetClientRect(hwndParent, &rc) ||
412 (rc.left == rc.right) ||
413 (rc.top == rc.bottom))
414 {
415 rc.left = 0;
416 rc.top = 0;
417 rc.right = 1;
418 rc.bottom = 1;
419 }
420
421 // HACK & FIXME: CORE-17505
422 HWND toolbar = CToolbar::Create(hwndParent, tbStyles, tbExStyles);
423 m_hWnd = NULL;
424 SubclassWindow(toolbar);
425
426 SetWindowTheme(m_hWnd, L"", L"");
427
428 SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
429
431
432 // If needed, create the pager.
433 if (m_usePager)
434 {
435 LONG pgStyles = PGS_VERT | WS_CHILD | WS_VISIBLE;
436 LONG pgExStyles = 0;
437
438 HWND hwndPager = CreateWindowEx(
439 pgExStyles, WC_PAGESCROLLER, NULL,
440 pgStyles, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
441 hwndParent, NULL, _AtlBaseModule.GetModuleInstance(), 0);
442
443 m_pager.SubclassWindow(hwndPager);
444
445 ::SetParent(m_hWnd, hwndPager);
446
447 m_pager.SendMessageW(PGM_SETCHILD, 0, reinterpret_cast<LPARAM>(m_hWnd));
448 }
449
450 // Configure the image lists
452
453 return S_OK;
454}
HRESULT AdjustForTheme(BOOL bFlatStyle)
Definition: CMenuBand.cpp:1167
HRESULT UpdateImageLists()
HWND Create(HWND hWndParent, DWORD dwStyles=0, DWORD dwExStyles=0)
Definition: rosctrls.h:261
static HWND hwndParent
Definition: cryptui.c:299
LONG_PTR LPARAM
Definition: minwindef.h:175
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
long LONG
Definition: pedump.c:60
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define PGS_VERT
Definition: commctrl.h:4507
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:989
#define TBSTYLE_LIST
Definition: commctrl.h:993
#define PGM_SETCHILD
Definition: commctrl.h:4521
#define CCS_VERT
Definition: commctrl.h:2254
#define TBSTYLE_EX_DOUBLEBUFFER
Definition: commctrl.h:1014
#define TBSTYLE_TRANSPARENT
Definition: commctrl.h:996
#define CCS_NODIVIDER
Definition: commctrl.h:2253
#define CCS_TOP
Definition: commctrl.h:2247
#define TBSTYLE_REGISTERDROP
Definition: commctrl.h:995
#define TBSTYLE_FLAT
Definition: commctrl.h:992
#define CCS_NOPARENTALIGN
Definition: commctrl.h:2251
#define CCS_NORESIZE
Definition: commctrl.h:2250
#define TBSTYLE_CUSTOMERASE
Definition: commctrl.h:994
#define TBSTYLE_EX_VERTICAL
Definition: commctrl.h:1011
#define CreateWindowEx
Definition: winuser.h:5921
HWND WINAPI SetParent(_In_ HWND, _In_opt_ HWND)
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
HRESULT WINAPI SetWindowTheme(_In_ HWND hwnd, _In_ LPCWSTR pszSubAppName, _In_ LPCWSTR pszSubIdList)
Definition: uxthemesupp.c:69
#define SubclassWindow(hwnd, lpfn)
Definition: windowsx.h:542

Referenced by CMenuBand::SetMenu(), CMenuBand::SetShellFolder(), and CMenuBand::SetSite().

◆ DisableMouseTrack()

HRESULT CMenuToolbarBase::DisableMouseTrack ( BOOL  bDisable)

Definition at line 138 of file CMenuToolbars.cpp.

139{
140 if (m_disableMouseTrack != bDisable)
141 {
142 m_disableMouseTrack = bDisable;
143 TRACE("DisableMouseTrack %d\n", bDisable);
144 }
145 return S_OK;
146}

Referenced by CMenuBand::_DisableMouseTrack().

◆ ExecuteItem()

HRESULT CMenuToolbarBase::ExecuteItem ( )

Definition at line 910 of file CMenuToolbars.cpp.

911{
913}
DWORD_PTR m_executeData
Definition: CMenuToolbars.h:55
virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData) PURE

◆ FillToolbar()

virtual HRESULT CMenuToolbarBase::FillToolbar ( BOOL  clearFirst = FALSE)
pure virtual

Implemented in CMenuStaticToolbar, and CMenuSFToolbar.

◆ GetDataFromId()

HRESULT CMenuToolbarBase::GetDataFromId ( INT  iItem,
INT *  pIndex,
DWORD_PTR *  pData 
)

Definition at line 1095 of file CMenuToolbars.cpp.

1096{
1097 if (pData)
1098 *pData = NULL;
1099
1100 if (pIndex)
1101 *pIndex = -1;
1102
1103 if (iItem < 0)
1104 return S_OK;
1105
1106 TBBUTTONINFO info = { 0 };
1107
1108 info.cbSize = sizeof(TBBUTTONINFO);
1109 info.dwMask = TBIF_COMMAND | TBIF_LPARAM;
1110
1111 int index = GetButtonInfo(iItem, &info);
1112 if (index < 0)
1113 return E_FAIL;
1114
1115 if (pIndex)
1116 *pIndex = index;
1117
1118 if (pData)
1119 *pData = info.lParam;
1120
1121 return S_OK;
1122}
#define index(s, c)
Definition: various.h:29
_Out_ PULONG _Out_ PULONG pIndex
Definition: ndis.h:4565
#define TBIF_LPARAM
Definition: commctrl.h:1223
#define TBIF_COMMAND
Definition: commctrl.h:1224
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

Referenced by OnGetInfoTip(), PopupItem(), PrepareExecuteItem(), and ProcessContextMenu().

◆ GetSizes()

HRESULT CMenuToolbarBase::GetSizes ( SIZE *  pMinSize,
SIZE *  pMaxSize,
SIZE *  pIntegralSize 
)

Definition at line 456 of file CMenuToolbars.cpp.

457{
458 if (pMinSize)
459 *pMinSize = m_idealSize;
460 if (pMaxSize)
461 *pMaxSize = m_idealSize;
462 if (pIntegralSize)
463 *pIntegralSize = m_itemSize;
464
465 if (m_hasSizes)
466 return S_OK;
467
468 TRACE("Sizes out of date, recalculating.\n");
469
470 if (!m_hWnd)
471 {
472 return S_OK;
473 }
474
475 // Obtain the ideal size, to be used as min and max
476 GetMaxSize(&m_idealSize);
477 GetIdealSize((m_initFlags & SMINIT_VERTICAL) != 0, &m_idealSize);
478
479 TRACE("Ideal Size: (%d, %d) for %d buttons\n", m_idealSize, GetButtonCount());
480
481 // Obtain the button size, to be used as the integral size
482 DWORD size = GetButtonSize();
486
487 if (pMinSize)
488 *pMinSize = m_idealSize;
489 if (pMaxSize)
490 *pMaxSize = m_idealSize;
491 if (pIntegralSize)
492 *pIntegralSize = m_itemSize;
493
494 return S_OK;
495}
GLsizeiptr size
Definition: glext.h:5919
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299

Referenced by CMenuBand::GetBandInfo(), OnPagerCalcSize(), and CMenuBand::OnPosRectChangeDB().

◆ GetToolbar()

HWND CMenuToolbarBase::GetToolbar ( )
inlineprotected

Definition at line 118 of file CMenuToolbars.h.

118{ return m_hWnd; }

Referenced by CMenuSFToolbar::FillToolbar(), and CMenuSFToolbar::InternalContextMenu().

◆ GetWindow()

HRESULT CMenuToolbarBase::GetWindow ( HWND *  phwnd)

Definition at line 528 of file CMenuToolbars.cpp.

529{
530 if (!phwnd)
531 return E_FAIL;
532
533 if (m_pager.m_hWnd)
534 *phwnd = m_pager.m_hWnd;
535 else
536 *phwnd = m_hWnd;
537
538 return S_OK;
539}

Referenced by CMenuBand::GetWindow().

◆ InternalContextMenu()

virtual HRESULT CMenuToolbarBase::InternalContextMenu ( INT  iItem,
INT  index,
DWORD_PTR  dwData,
POINT  pt 
)
protectedvirtual

Reimplemented in CMenuStaticToolbar, and CMenuSFToolbar.

Referenced by ProcessContextMenu().

◆ InternalExecuteItem()

virtual HRESULT CMenuToolbarBase::InternalExecuteItem ( INT  iItem,
INT  index,
DWORD_PTR  dwData 
)
protectedvirtual

Reimplemented in CMenuStaticToolbar, and CMenuSFToolbar.

Referenced by ExecuteItem().

◆ InternalGetTooltip()

virtual HRESULT CMenuToolbarBase::InternalGetTooltip ( INT  iItem,
INT  index,
DWORD_PTR  dwData,
LPWSTR  pszText,
INT  cchTextMax 
)
protectedvirtual

Reimplemented in CMenuStaticToolbar, and CMenuSFToolbar.

Referenced by OnGetInfoTip().

◆ InternalHasSubMenu()

virtual HRESULT CMenuToolbarBase::InternalHasSubMenu ( INT  iItem,
INT  index,
DWORD_PTR  dwData 
)
protectedvirtual

Reimplemented in CMenuStaticToolbar, and CMenuSFToolbar.

Referenced by PopupItem().

◆ InternalPopupItem()

virtual HRESULT CMenuToolbarBase::InternalPopupItem ( INT  iItem,
INT  index,
DWORD_PTR  dwData,
BOOL  keyInitiated 
)
protectedvirtual

Reimplemented in CMenuStaticToolbar, and CMenuSFToolbar.

Referenced by PopupItem().

◆ InvalidateDraw()

void CMenuToolbarBase::InvalidateDraw ( )

Definition at line 321 of file CMenuToolbars.cpp.

322{
324}
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by ChangeHotItem(), and ChangePopupItem().

◆ IsTrackedItem()

LRESULT CMenuToolbarBase::IsTrackedItem ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL &  bHandled 
)
private

Definition at line 683 of file CMenuToolbars.cpp.

684{
685 TBBUTTON btn;
686 INT idx = (INT)wParam;
687
688 if (m_hotBar != this)
689 return S_FALSE;
690
691 if (idx < 0)
692 return S_FALSE;
693
694 if (!GetButton(idx, &btn))
695 return E_FAIL;
696
697 if (m_hotItem == btn.idCommand)
698 return S_OK;
699
700 if (m_popupItem == btn.idCommand)
701 return S_OK;
702
703 return S_FALSE;
704}

◆ IsWindowOwner()

HRESULT CMenuToolbarBase::IsWindowOwner ( HWND  hwnd)

Definition at line 521 of file CMenuToolbars.cpp.

522{
523 if (m_hWnd && m_hWnd == hwnd) return S_OK;
524 if (m_pager.m_hWnd && m_pager.m_hWnd == hwnd) return S_OK;
525 return S_FALSE;
526}
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by CMenuBand::_MenuBarMouseDown(), CMenuBand::_MenuBarMouseUp(), CMenuBand::IsWindowOwner(), and CMenuBand::OnWinEvent().

◆ KeyboardItemChange()

HRESULT CMenuToolbarBase::KeyboardItemChange ( DWORD  changeType)

Definition at line 915 of file CMenuToolbars.cpp.

916{
917 int prev = m_hotItem;
918 int index = -1;
919
920 if (dwSelectType != 0xFFFFFFFF)
921 {
922 int count = GetButtonCount();
923
924 if (dwSelectType == VK_HOME)
925 {
926 index = 0;
927 dwSelectType = VK_DOWN;
928 }
929 else if (dwSelectType == VK_END)
930 {
931 index = count - 1;
932 dwSelectType = VK_UP;
933 }
934 else
935 {
936 if (m_hotItem >= 0)
937 {
938 TBBUTTONINFO info = { 0 };
939 info.cbSize = sizeof(TBBUTTONINFO);
940 info.dwMask = 0;
941 index = GetButtonInfo(m_hotItem, &info);
942 }
943
944 if (index < 0)
945 {
946 if (dwSelectType == VK_UP)
947 {
948 index = count - 1;
949 }
950 else if (dwSelectType == VK_DOWN)
951 {
952 index = 0;
953 }
954 }
955 else
956 {
957 if (dwSelectType == VK_UP)
958 {
959 index--;
960 }
961 else if (dwSelectType == VK_DOWN)
962 {
963 index++;
964 }
965 }
966 }
967
968 TBBUTTON btn = { 0 };
969 while (index >= 0 && index < count)
970 {
971 DWORD res = GetButton(index, &btn);
972 if (!res)
973 return E_FAIL;
974
975 if (btn.dwData)
976 {
977 if (prev != btn.idCommand)
978 {
979 TRACE("Setting Hot item to %d\n", index);
980 if (!(m_initFlags & SMINIT_VERTICAL) && m_isTrackingPopup)
981 {
982 HWND tlw;
984 ::SendMessageW(tlw, WM_CANCELMODE, 0, 0);
986 }
987 else
988 m_menuBand->_ChangeHotItem(this, btn.idCommand, 0);
989 }
990 return S_OK;
991 }
992
993 if (dwSelectType == VK_UP)
994 {
995 index--;
996 }
997 else if (dwSelectType == VK_DOWN)
998 {
999 index++;
1000 }
1001 }
1002
1003 return S_FALSE;
1004 }
1005
1006 if (prev != -1)
1007 {
1008 TRACE("Setting Hot item to null\n");
1010 }
1011
1012 return S_FALSE;
1013}
#define WM_USER_CHANGETRACKEDITEM
Definition: CMenuToolbars.h:26
HRESULT _GetTopLevelWindow(HWND *topLevel)
Definition: CMenuBand.cpp:885
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint res
Definition: glext.h:9613
#define MAKELPARAM(l, h)
Definition: winuser.h:4116
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CANCELMODE
Definition: winuser.h:1663
#define VK_UP
Definition: winuser.h:2261
#define VK_END
Definition: winuser.h:2258
#define VK_HOME
Definition: winuser.h:2259
#define VK_DOWN
Definition: winuser.h:2263
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ KillPopupTimer()

HRESULT CMenuToolbarBase::KillPopupTimer ( )

Definition at line 587 of file CMenuToolbars.cpp.

588{
589 if (m_timerEnabled)
590 {
593 return S_OK;
594 }
595 return S_FALSE;
596}
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by CMenuBand::_KillPopupTimers().

◆ MenuBarMouseDown()

HRESULT CMenuToolbarBase::MenuBarMouseDown ( INT  iIndex,
BOOL  isLButton 
)

Definition at line 860 of file CMenuToolbars.cpp.

861{
862 TBBUTTON btn;
863
864 GetButton(iIndex, &btn);
865
866 // Ignore disabled items
867 if (!(btn.fsState & TBSTATE_ENABLED))
868 return S_OK;
869
870 if ((m_initFlags & SMINIT_VERTICAL)
871 || m_popupBar
873 {
875 return S_OK;
876 }
877
878 return ProcessClick(btn.idCommand);
879}
HRESULT ProcessClick(INT iItem)

Referenced by CMenuBand::_MenuBarMouseDown().

◆ MenuBarMouseUp()

HRESULT CMenuToolbarBase::MenuBarMouseUp ( INT  iIndex,
BOOL  isLButton 
)

Definition at line 881 of file CMenuToolbars.cpp.

882{
883 TBBUTTON btn;
884
886
887 if (!(m_initFlags & SMINIT_VERTICAL))
888 return S_OK;
889
890 GetButton(iIndex, &btn);
891
892 // Ignore disabled items
893 if (!(btn.fsState & TBSTATE_ENABLED))
894 return S_OK;
895
896 if (isLButton)
897 return ProcessClick(btn.idCommand);
898 else
899 return ProcessContextMenu(btn.idCommand);
900}
HRESULT ProcessContextMenu(INT iItem)

Referenced by CMenuBand::_MenuBarMouseUp().

◆ OnCustomDraw()

HRESULT CMenuToolbarBase::OnCustomDraw ( LPNMTBCUSTOMDRAW  cdraw,
LRESULT *  theResult 
)
private

Definition at line 163 of file CMenuToolbars.cpp.

164{
165 bool isHot, isPopup, isActive;
166 TBBUTTONINFO btni;
167
168 switch (cdraw->nmcd.dwDrawStage)
169 {
170 case CDDS_PREPAINT:
171 *theResult = CDRF_NOTIFYITEMDRAW;
172 return S_OK;
173
175
176 HWND tlw;
178
179 // The item with an active submenu gets the CHECKED flag.
180 isHot = m_hotBar == this && (int) cdraw->nmcd.dwItemSpec == m_hotItem;
181 isPopup = m_popupBar == this && (int) cdraw->nmcd.dwItemSpec == m_popupItem;
182 isActive = (GetForegroundWindow() == tlw) || (m_popupBar == this);
183
184 if (m_hotItem < 0 && isPopup)
185 isHot = TRUE;
186
187 if ((m_useFlatMenus && isHot) || (m_initFlags & SMINIT_VERTICAL))
188 {
189 COLORREF clrText;
190 HBRUSH bgBrush;
191 RECT rc = cdraw->nmcd.rc;
192 HDC hdc = cdraw->nmcd.hdc;
193
194 // Remove HOT and CHECKED flags (will restore HOT if necessary)
195 cdraw->nmcd.uItemState &= ~(CDIS_HOT | CDIS_CHECKED);
196
197 // Decide on the colors
198 if (isHot)
199 {
200 cdraw->nmcd.uItemState |= CDIS_HOT;
201
203 bgBrush = GetSysColorBrush(m_useFlatMenus ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT);
204 }
205 else
206 {
207 clrText = GetSysColor(COLOR_MENUTEXT);
208 bgBrush = GetSysColorBrush(COLOR_MENU);
209 }
210
211 // Paint the background color with the selected color
212 FillRect(hdc, &rc, bgBrush);
213
214 // Set the text color in advance, this color will be assigned when the ITEMPOSTPAINT triggers
215 SetTextColor(hdc, clrText);
216
217 // Set the text color, will be used by the internal drawing code
218 cdraw->clrText = clrText;
219 cdraw->iListGap += 4;
220
221 // Tell the default drawing code we don't want any fanciness, not even a background.
222 *theResult = CDRF_NOTIFYPOSTPAINT | TBCDRF_NOBACKGROUND | TBCDRF_NOEDGES | TBCDRF_NOOFFSET | TBCDRF_NOMARK | 0x00800000; // FIXME: the last bit is Vista+, useful for debugging only
223 }
224 else
225 {
226 // Set the text color, will be used by the internal drawing code
227 cdraw->clrText = GetSysColor(isActive ? COLOR_MENUTEXT : COLOR_GRAYTEXT);
228
229 // Remove HOT and CHECKED flags (will restore HOT if necessary)
230 cdraw->nmcd.uItemState &= ~CDIS_HOT;
231
232 // Decide on the colors
233 if (isHot)
234 {
235 cdraw->nmcd.uItemState |= CDIS_HOT;
236 }
237
238 *theResult = 0;
239 }
240
241 return S_OK;
242
244
245 // Fetch the button style
246 btni.cbSize = sizeof(btni);
247 btni.dwMask = TBIF_STYLE;
248 GetButtonInfo(cdraw->nmcd.dwItemSpec, &btni);
249
250 // Check if we need to draw a submenu arrow
251 if (btni.fsStyle & BTNS_DROPDOWN)
252 {
253 // TODO: Support RTL text modes by drawing a leftwards arrow aligned to the left of the control
254
255 // "8" is the rightwards dropdown arrow in the Marlett font
256 WCHAR text [] = L"8";
257
258 // Configure the font to draw with Marlett, keeping the current background color as-is
259 HGDIOBJ hFontOld = SelectObject(cdraw->nmcd.hdc, m_marlett);
260 SetBkMode(cdraw->nmcd.hdc, TRANSPARENT);
261
262 // Tweak the alignment by 1 pixel so the menu draws like the Windows start menu.
263 RECT rc = cdraw->nmcd.rc;
264 rc.right += 1;
265
266 // The arrow is drawn at the right of the item's rect, aligned vertically.
268
269 SelectObject(cdraw->nmcd.hdc, hFontOld);
270 }
271 *theResult = TRUE;
272 return S_OK;
273
274 default:
275 *theResult = 0L;
276 break;
277 }
278 return S_OK;
279}
const WCHAR * text
Definition: package.c:1826
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
#define CDDS_ITEMPOSTPAINT
Definition: commctrl.h:286
#define CDDS_ITEMPREPAINT
Definition: commctrl.h:285
#define TBCDRF_NOEDGES
Definition: commctrl.h:1033
#define CDRF_NOTIFYITEMDRAW
Definition: commctrl.h:275
#define TBCDRF_NOOFFSET
Definition: commctrl.h:1035
#define CDRF_NOTIFYPOSTPAINT
Definition: commctrl.h:274
#define TBIF_STYLE
Definition: commctrl.h:1222
#define TBCDRF_NOBACKGROUND
Definition: commctrl.h:1040
#define CDIS_CHECKED
Definition: commctrl.h:294
#define CDDS_PREPAINT
Definition: commctrl.h:280
#define CDIS_HOT
Definition: commctrl.h:297
#define TBCDRF_NOMARK
Definition: commctrl.h:1036
DWORD WINAPI GetSysColor(_In_ int)
#define COLOR_MENU
Definition: winuser.h:928
#define COLOR_GRAYTEXT
Definition: winuser.h:943
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define COLOR_HIGHLIGHT
Definition: winuser.h:937
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define DT_SINGLELINE
Definition: winuser.h:540
#define DT_NOCLIP
Definition: winuser.h:536
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:938
#define DT_VCENTER
Definition: winuser.h:543
#define DT_RIGHT
Definition: winuser.h:538
#define COLOR_MENUTEXT
Definition: winuser.h:931
#define DrawTextEx
Definition: winuser.h:5938
NMCUSTOMDRAW nmcd
Definition: commctrl.h:1017
COLORREF clrText
Definition: commctrl.h:1021
DWORD_PTR dwItemSpec
Definition: commctrl.h:307
DWORD COLORREF
Definition: windef.h:100
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define TRANSPARENT
Definition: wingdi.h:950
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917

Referenced by OnWinEvent().

◆ OnDeletingButton()

virtual HRESULT CMenuToolbarBase::OnDeletingButton ( const NMTOOLBAR *  tb)
protectedvirtual

Reimplemented in CMenuStaticToolbar, and CMenuSFToolbar.

Referenced by OnWinEvent().

◆ OnGetInfoTip()

HRESULT CMenuToolbarBase::OnGetInfoTip ( NMTBGETINFOTIP *  tip)
private

Definition at line 541 of file CMenuToolbars.cpp.

542{
543 INT index;
545
546 INT iItem = tip->iItem;
547
548 GetDataFromId(iItem, &index, &dwData);
549
550 return InternalGetTooltip(iItem, index, dwData, tip->pszText, tip->cchTextMax);
551}
virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax) PURE
HRESULT GetDataFromId(INT iItem, INT *pIndex, DWORD_PTR *pData)
static HANDLE ULONG_PTR dwData
Definition: pipe.c:111
uint32_t DWORD_PTR
Definition: typedefs.h:65

Referenced by OnWinEvent().

◆ OnPagerCalcSize()

HRESULT CMenuToolbarBase::OnPagerCalcSize ( LPNMPGCALCSIZE  csize)
private

Definition at line 148 of file CMenuToolbars.cpp.

149{
150 SIZE tbs;
151 GetSizes(NULL, &tbs, NULL);
152 if (csize->dwFlag == PGF_CALCHEIGHT)
153 {
154 csize->iHeight = tbs.cy;
155 }
156 else if (csize->dwFlag == PGF_CALCWIDTH)
157 {
158 csize->iWidth = tbs.cx;
159 }
160 return S_OK;
161}
HRESULT GetSizes(SIZE *pMinSize, SIZE *pMaxSize, SIZE *pIntegralSize)
#define PGF_CALCWIDTH
Definition: commctrl.h:4587
#define PGF_CALCHEIGHT
Definition: commctrl.h:4588
DWORD dwFlag
Definition: commctrl.h:4592

Referenced by OnWinEvent().

◆ OnPopupTimer()

HRESULT CMenuToolbarBase::OnPopupTimer ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL &  bHandled 
)
private

Definition at line 553 of file CMenuToolbars.cpp.

554{
556 {
557 bHandled = FALSE;
558 return 0;
559 }
560
562
563 if (!m_timerEnabled)
564 return 0;
565
567
568 if (m_hotItem < 0)
569 return 0;
570
571 // Returns S_FALSE if the current item did not show a submenu
573 if (hr != S_FALSE)
574 return 0;
575
576 // If we didn't switch submenus, cancel the current popup regardless
577 if (m_popupBar)
578 {
581 return 0;
582 }
583
584 return 0;
585}
HRESULT CancelCurrentPopup()
HRESULT hr
Definition: delayimp.cpp:582
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:33

◆ OnWinEvent()

HRESULT CMenuToolbarBase::OnWinEvent ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT *  theResult 
)

Definition at line 56 of file CMenuToolbars.cpp.

57{
58 NMHDR * hdr;
59 HRESULT hr;
61
62 if (theResult)
63 *theResult = 0;
64 switch (uMsg)
65 {
66 case WM_COMMAND:
67 //return OnCommand(wParam, lParam, theResult);
68 return S_OK;
69
70 case WM_NOTIFY:
71 hdr = reinterpret_cast<LPNMHDR>(lParam);
72 switch (hdr->code)
73 {
75 return OnDeletingButton(reinterpret_cast<LPNMTOOLBAR>(hdr));
76
77 case PGN_CALCSIZE:
78 return OnPagerCalcSize(reinterpret_cast<LPNMPGCALCSIZE>(hdr));
79
80 case TBN_DROPDOWN:
81 return ProcessClick(reinterpret_cast<LPNMTOOLBAR>(hdr)->iItem);
82
84 //return OnHotItemChange(reinterpret_cast<LPNMTBHOTITEM>(hdr), theResult);
85 return S_OK;
86
87 case NM_CUSTOMDRAW:
88 hr = OnCustomDraw(reinterpret_cast<LPNMTBCUSTOMDRAW>(hdr), &result);
89 if (theResult)
90 *theResult = result;
91 return hr;
92
93 case TBN_GETINFOTIP:
94 return OnGetInfoTip(reinterpret_cast<LPNMTBGETINFOTIP>(hdr));
95
96 // Silence unhandled items so that they don't print as unknown
97 case RBN_CHILDSIZE:
98 return S_OK;
99
100 case TTN_GETDISPINFO:
101 return S_OK;
102
104 break;
105
106 case NM_CLICK:
107 case NM_RDOWN:
108 case NM_LDOWN:
109 break;
110
111 case TBN_GETDISPINFO:
112 break;
113
114 case TBN_BEGINDRAG:
115 case TBN_ENDDRAG:
116 break;
117
119 break;
120
121 case TBN_DRAGOUT: return S_FALSE;
122
123 default:
124 TRACE("WM_NOTIFY unknown code %d, %d\n", hdr->code, hdr->idFrom);
125 return S_OK;
126 }
127 return S_FALSE;
128 case WM_WININICHANGE:
129 if (wParam == SPI_SETFLATMENU)
130 {
131 SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
132 }
133 }
134
135 return S_FALSE;
136}
virtual HRESULT OnDeletingButton(const NMTOOLBAR *tb) PURE
HRESULT OnCustomDraw(LPNMTBCUSTOMDRAW cdraw, LRESULT *theResult)
HRESULT OnGetInfoTip(NMTBGETINFOTIP *tip)
HRESULT OnPagerCalcSize(LPNMPGCALCSIZE csize)
GLuint64EXT * result
Definition: glext.h:11304
char hdr[14]
Definition: iptest.cpp:33
LONG_PTR LRESULT
Definition: minwindef.h:176
#define NM_RELEASEDCAPTURE
Definition: commctrl.h:141
#define RBN_CHILDSIZE
Definition: commctrl.h:1636
#define TBN_ENDDRAG
Definition: commctrl.h:1308
#define NM_LDOWN
Definition: commctrl.h:145
#define TBN_HOTITEMCHANGE
Definition: commctrl.h:1336
#define NM_TOOLTIPSCREATED
Definition: commctrl.h:144
#define TTN_GETDISPINFO
Definition: commctrl.h:1883
#define NM_CLICK
Definition: commctrl.h:130
#define LPNMTOOLBAR
Definition: commctrl.h:1457
#define PGN_CALCSIZE
Definition: commctrl.h:4585
#define NM_CUSTOMDRAW
Definition: commctrl.h:137
#define TBN_GETDISPINFO
Definition: commctrl.h:1420
#define TBN_DRAGOUT
Definition: commctrl.h:1337
#define TBN_GETINFOTIP
Definition: commctrl.h:1392
#define TBN_BEGINDRAG
Definition: commctrl.h:1307
#define LPNMTBGETINFOTIP
Definition: commctrl.h:1394
#define TBN_DROPDOWN
Definition: commctrl.h:1316
#define TBN_DELETINGBUTTON
Definition: commctrl.h:1338
#define NM_RDOWN
Definition: commctrl.h:146
#define WM_COMMAND
Definition: winuser.h:1768
#define WM_WININICHANGE
Definition: winuser.h:1658
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by CMenuBand::OnWinEvent(), and OnWinEventWrap().

◆ OnWinEventWrap()

LRESULT CMenuToolbarBase::OnWinEventWrap ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL &  bHandled 
)
private

Definition at line 49 of file CMenuToolbars.cpp.

50{
51 LRESULT lr;
52 bHandled = OnWinEvent(m_hWnd, uMsg, wParam, lParam, &lr) != S_FALSE;
53 return lr;
54}
HRESULT OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)

◆ PopupItem()

HRESULT CMenuToolbarBase::PopupItem ( INT  iItem,
BOOL  keyInitiated 
)

Definition at line 1129 of file CMenuToolbars.cpp.

1130{
1131 INT index;
1133
1134 if (iItem < 0)
1135 return S_OK;
1136
1137 if (m_popupBar == this && m_popupItem == iItem)
1138 return S_OK;
1139
1140 GetDataFromId(iItem, &index, &dwData);
1141
1143 if (hr != S_OK)
1144 return hr;
1145
1146 if (m_popupBar)
1147 {
1150 return hr;
1151 }
1152
1153 if (!(m_initFlags & SMINIT_VERTICAL))
1154 {
1155 TRACE("PopupItem non-vertical %d %d\n", index, iItem);
1156 m_menuBand->_ChangeHotItem(this, iItem, 0);
1157 }
1158
1159 return InternalPopupItem(iItem, index, dwData, keyInitiated);
1160}
virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData, BOOL keyInitiated) PURE
virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData) PURE

Referenced by CMenuBand::_MenuItemSelect(), ChangeHotItem(), OnPopupTimer(), and ProcessClick().

◆ PopupSubMenu() [1/2]

HRESULT CMenuToolbarBase::PopupSubMenu ( UINT  itemId,
UINT  index,
HMENU  menu 
)

Definition at line 768 of file CMenuToolbars.cpp.

769{
770 // Calculate the submenu position and exclude area
771 RECT rc = { 0 };
772
773 if (!GetItemRect(index, &rc))
774 return E_FAIL;
775
776 POINT a = { rc.left, rc.top };
777 POINT b = { rc.right, rc.bottom };
778
781
782 POINT pt = { a.x, b.y };
783 RECT rcl = { a.x, a.y, b.x, b.y };
784
785 if (m_initFlags & SMINIT_VERTICAL)
786 {
787 pt.x = b.x;
788 pt.y = a.y;
789 }
790
791 HMENU popup = GetSubMenu(menu, index);
792
793 // Display the submenu
795 m_menuBand->_ChangePopupItem(this, iItem);
796 m_menuBand->_TrackSubMenu(popup, pt.x, pt.y, rcl);
799
800 return S_OK;
801}
HRESULT _TrackSubMenu(HMENU popup, INT x, INT y, RECT &rcExclude)
Definition: CMenuBand.cpp:802
HRESULT _ChangePopupItem(CMenuToolbarBase *tb, INT id)
Definition: CMenuBand.cpp:910
#define pt(x, y)
Definition: drawing.c:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define menu
Definition: input.c:3282
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)

◆ PopupSubMenu() [2/2]

HRESULT CMenuToolbarBase::PopupSubMenu ( UINT  itemId,
UINT  index,
IShellMenu *  childShellMenu,
BOOL  keyInitiated 
)

Definition at line 727 of file CMenuToolbars.cpp.

728{
729 // Calculate the submenu position and exclude area
730 RECT rc = { 0 };
731
732 if (!GetItemRect(index, &rc))
733 return E_FAIL;
734
735 POINT a = { rc.left, rc.top };
736 POINT b = { rc.right, rc.bottom };
737
740
741 POINTL pt = { a.x, b.y };
742 RECTL rcl = { a.x, a.y, b.x, b.y };
743
744 if (m_initFlags & SMINIT_VERTICAL)
745 {
746 // FIXME: Hardcoding this here feels hacky.
747 if (IsAppThemed())
748 {
749 pt.x = b.x - 1;
750 pt.y = a.y - 1;
751 }
752 else
753 {
754 pt.x = b.x - 3;
755 pt.y = a.y - 3;
756 }
757 }
758
759 // Display the submenu
761
762 m_menuBand->_ChangePopupItem(this, iItem);
763 m_menuBand->_OnPopupSubMenu(childShellMenu, &pt, &rcl, keyInitiated);
764
765 return S_OK;
766}
HRESULT _OnPopupSubMenu(IShellMenu *childShellMenu, POINTL *pAt, RECTL *pExclude, BOOL mouseInitiated)
Definition: CMenuBand.cpp:1066
BOOL WINAPI IsAppThemed(void)
Definition: system.c:620

Referenced by CMenuStaticToolbar::InternalPopupItem(), and CMenuSFToolbar::InternalPopupItem().

◆ PrepareExecuteItem()

HRESULT CMenuToolbarBase::PrepareExecuteItem ( INT  iItem)

Definition at line 902 of file CMenuToolbars.cpp.

903{
905
906 m_executeItem = iItem;
908}
HRESULT _KillPopupTimers()
Definition: CMenuBand.cpp:1130

◆ ProcessClick()

HRESULT CMenuToolbarBase::ProcessClick ( INT  iItem)

Definition at line 821 of file CMenuToolbars.cpp.

822{
824 {
825 TRACE("Item click prevented by DisableMouseTrack\n");
826 return S_OK;
827 }
828
829 // If a button is clicked while a submenu was open, cancel the submenu.
830 if (!(m_initFlags & SMINIT_VERTICAL) && m_isTrackingPopup)
831 {
832 TRACE("OnCommand cancelled because it was tracking submenu.\n");
833 return S_FALSE;
834 }
835
836 if (PopupItem(iItem, FALSE) == S_OK)
837 {
838 TRACE("PopupItem returned S_OK\n");
839 return S_FALSE;
840 }
841
842 TRACE("Executing...\n");
843
844 return m_menuBand->_MenuItemSelect(MPOS_EXECUTE);
845}
HRESULT _MenuItemSelect(DWORD changeType)
Definition: CMenuBand.cpp:965

Referenced by MenuBarMouseDown(), MenuBarMouseUp(), and OnWinEvent().

◆ ProcessContextMenu()

HRESULT CMenuToolbarBase::ProcessContextMenu ( INT  iItem)

Definition at line 847 of file CMenuToolbars.cpp.

848{
849 INT index;
851
852 GetDataFromId(iItem, &index, &data);
853
856
857 return InternalContextMenu(iItem, index, data, pt);
858}
virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT pt) PURE
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
DWORD WINAPI GetMessagePos(void)
Definition: message.c:1351

Referenced by MenuBarMouseUp().

◆ SetPosSize()

HRESULT CMenuToolbarBase::SetPosSize ( int  x,
int  y,
int  cx,
int  cy 
)

Definition at line 497 of file CMenuToolbars.cpp.

498{
499 // Update the toolbar or pager to fit the requested rect
500 // If we have a pager, set the toolbar height to the ideal height of the toolbar
501 if (m_pager.m_hWnd)
502 {
504 m_pager.SetWindowPos(NULL, x, y, cx, cy, 0);
505 }
506 else
507 {
508 SetWindowPos(NULL, x, y, cx, cy, 0);
509 }
510
511 // In a vertical menu, resize the buttons to fit the width
512 if (m_initFlags & SMINIT_VERTICAL)
513 {
514 DWORD btnSize = GetButtonSize();
515 SetButtonSize(cx, GET_Y_LPARAM(btnSize));
516 }
517
518 return S_OK;
519}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)

Referenced by CMenuBand::OnPosRectChangeDB().

◆ ShowDW()

HRESULT CMenuToolbarBase::ShowDW ( BOOL  fShow)

Definition at line 326 of file CMenuToolbars.cpp.

327{
328 if (m_hWnd == NULL)
329 return S_FALSE;
330
331 ShowWindow(fShow ? SW_SHOW : SW_HIDE);
332
333 // Ensure that the right image list is assigned to the toolbar
335
336 // For custom-drawing
337 SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
338
339 return S_OK;
340}
#define SW_HIDE
Definition: winuser.h:779
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define SW_SHOW
Definition: winuser.h:786

Referenced by CMenuBand::ShowDW().

◆ TrackContextMenu()

HRESULT CMenuToolbarBase::TrackContextMenu ( IContextMenu *  contextMenu,
POINT  pt 
)

Definition at line 803 of file CMenuToolbars.cpp.

804{
805 // Cancel submenus
807 if (m_popupBar)
809
810 // Display the context menu
811 return m_menuBand->_TrackContextMenu(contextMenu, pt.x, pt.y);
812}
HRESULT _TrackContextMenu(IContextMenu *popup, INT x, INT y)
Definition: CMenuBand.cpp:823

Referenced by CMenuStaticToolbar::InternalContextMenu(), and CMenuSFToolbar::InternalContextMenu().

◆ UpdateImageLists()

HRESULT CMenuToolbarBase::UpdateImageLists ( )
private

Definition at line 342 of file CMenuToolbars.cpp.

343{
344 if ((m_initFlags & (SMINIT_TOPLEVEL | SMINIT_VERTICAL)) == SMINIT_TOPLEVEL) // not vertical.
345 {
346 // No image list, prevents the buttons from having a margin at the left side
348 return S_OK;
349 }
350
351 // Assign the correct imagelist and padding based on the current icon size
352
353 int shiml;
354 if (m_menuBand->UseBigIcons())
355 {
356 shiml = SHIL_LARGE;
357 SetPadding(4, 0);
358 }
359 else
360 {
361 shiml = SHIL_SMALL;
362 SetPadding(4, 4);
363 }
364
365 IImageList * piml;
368 {
370 }
371 else
372 {
374 }
375 return S_OK;
376}
#define IID_PPV_ARG(Itype, ppType)
BOOL UseBigIcons()
Definition: CMenuBand.h:207
static VOID SetImageList(HWND hwnd)
Definition: mplay32.c:238
#define SHIL_SMALL
Definition: shellapi.h:186
#define SHIL_LARGE
Definition: shellapi.h:185
HRESULT WINAPI SHGetImageList(int iImageList, REFIID riid, void **ppv)
Definition: shellord.c:2890

Referenced by CreateToolbar(), and ShowDW().

Member Data Documentation

◆ m_cancelingPopup

BOOL CMenuToolbarBase::m_cancelingPopup
protected

Definition at line 57 of file CMenuToolbars.h.

Referenced by BeforeCancelPopup(), MenuBarMouseDown(), and MenuBarMouseUp().

◆ m_disableMouseTrack

BOOL CMenuToolbarBase::m_disableMouseTrack
private

Definition at line 35 of file CMenuToolbars.h.

Referenced by ChangeHotItem(), DisableMouseTrack(), and ProcessClick().

◆ m_dwMenuFlags

DWORD CMenuToolbarBase::m_dwMenuFlags
protected

◆ m_executeData

DWORD_PTR CMenuToolbarBase::m_executeData
protected

Definition at line 55 of file CMenuToolbars.h.

Referenced by ExecuteItem(), and PrepareExecuteItem().

◆ m_executeIndex

INT CMenuToolbarBase::m_executeIndex
protected

Definition at line 53 of file CMenuToolbars.h.

Referenced by PrepareExecuteItem().

◆ m_executeItem

INT CMenuToolbarBase::m_executeItem
protected

Definition at line 54 of file CMenuToolbars.h.

Referenced by ExecuteItem(), and PrepareExecuteItem().

◆ m_hasSizes

BOOL CMenuToolbarBase::m_hasSizes
protected

Definition at line 41 of file CMenuToolbars.h.

Referenced by AddButton(), AddPlaceholder(), AddSeparator(), ClearToolbar(), and GetSizes().

◆ m_hotBar

CMenuToolbarBase* CMenuToolbarBase::m_hotBar
protected

Definition at line 45 of file CMenuToolbars.h.

Referenced by ChangeHotItem(), IsTrackedItem(), and OnCustomDraw().

◆ m_hotItem

INT CMenuToolbarBase::m_hotItem
protected

◆ m_idealSize

SIZE CMenuToolbarBase::m_idealSize
protected

Definition at line 42 of file CMenuToolbars.h.

Referenced by CMenuToolbarBase(), GetSizes(), and SetPosSize().

◆ m_initFlags

◆ m_isTrackingPopup

BOOL CMenuToolbarBase::m_isTrackingPopup
protected

◆ m_itemSize

SIZE CMenuToolbarBase::m_itemSize
protected

Definition at line 43 of file CMenuToolbars.h.

Referenced by CMenuToolbarBase(), and GetSizes().

◆ m_marlett

HFONT CMenuToolbarBase::m_marlett
private

Definition at line 33 of file CMenuToolbars.h.

Referenced by CMenuToolbarBase(), OnCustomDraw(), and ~CMenuToolbarBase().

◆ m_menuBand

◆ m_pager

CContainedWindow CMenuToolbarBase::m_pager
private

◆ m_popupBar

CMenuToolbarBase* CMenuToolbarBase::m_popupBar
protected

◆ m_popupItem

INT CMenuToolbarBase::m_popupItem
protected

Definition at line 48 of file CMenuToolbars.h.

Referenced by ChangePopupItem(), IsTrackedItem(), OnCustomDraw(), and PopupItem().

◆ m_timerEnabled

BOOL CMenuToolbarBase::m_timerEnabled
private

Definition at line 36 of file CMenuToolbars.h.

Referenced by ChangeHotItem(), KillPopupTimer(), and OnPopupTimer().

◆ m_useFlatMenus

BOOL CMenuToolbarBase::m_useFlatMenus
private

Definition at line 34 of file CMenuToolbars.h.

Referenced by CreateToolbar(), OnCustomDraw(), OnWinEvent(), and ShowDW().

◆ m_usePager

BOOL CMenuToolbarBase::m_usePager
protected

Definition at line 44 of file CMenuToolbars.h.

Referenced by CreateToolbar().


The documentation for this class was generated from the following files: