ReactOS 0.4.15-dev-8245-gd24675b
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

CMenuBandm_menuBand
 
DWORD m_dwMenuFlags
 
BOOL m_hasSizes
 
SIZE m_idealSize
 
SIZE m_itemSize
 
BOOL m_usePager
 
CMenuToolbarBasem_hotBar
 
INT m_hotItem
 
CMenuToolbarBasem_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 271 of file CMenuToolbars.cpp.

271 :
276 m_menuBand(menuBand),
277 m_dwMenuFlags(0),
279 m_usePager(usePager),
280 m_hotBar(NULL),
281 m_hotItem(-1),
283 m_popupItem(-1),
286{
287 m_idealSize.cx = 0;
288 m_idealSize.cy = 0;
289 m_itemSize.cx = 0;
290 m_itemSize.cy = 0;
292 0, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET,
294 DEFAULT_QUALITY, FF_DONTCARE, L"Marlett");
295}
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: ntvdm.h:50
#define WC_PAGESCROLLER
Definition: commctrl.h:4500
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:4443
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426

◆ ~CMenuToolbarBase()

CMenuToolbarBase::~CMenuToolbarBase ( )
virtual

Definition at line 297 of file CMenuToolbars.cpp.

298{
299 if (m_hWnd)
300 {
301 ClearToolbar();
303 }
304
305 if (m_pager.m_hWnd)
306 m_pager.DestroyWindow();
307
309}
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 997 of file CMenuToolbars.cpp.

998{
999 TBBUTTON tbb = { 0 };
1000
1002#if !USE_TBSTYLE_EX_VERTICAL
1003 if (!last && (m_initFlags & SMINIT_VERTICAL))
1004 tbb.fsState |= TBSTATE_WRAP;
1005#endif
1007
1008 if (hasSubMenu && (m_initFlags & SMINIT_VERTICAL))
1009 tbb.fsStyle |= BTNS_DROPDOWN;
1010
1011 if (!(m_initFlags & SMINIT_VERTICAL))
1012 tbb.fsStyle |= BTNS_AUTOSIZE;
1013
1014 tbb.iString = (INT_PTR) caption;
1015 tbb.idCommand = commandId;
1016
1017 tbb.iBitmap = iconId;
1018 tbb.dwData = buttonData;
1019
1020 m_hasSizes = FALSE;
1021
1022 if (!AddButtons(1, &tbb))
1024 return S_OK;
1025}
#define S_OK
Definition: intsafe.h:52
static UINT UINT last
Definition: font.c:45
#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
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

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

◆ AddPlaceholder()

HRESULT CMenuToolbarBase::AddPlaceholder ( )
protected

Definition at line 1047 of file CMenuToolbars.cpp.

1048{
1049 TBBUTTON tbb = { 0 };
1050 WCHAR MenuString[128];
1051
1052 LoadStringW(GetModuleHandle(L"shell32.dll"), IDS_MENU_EMPTY, MenuString, _countof(MenuString));
1053
1054 tbb.fsState = 0;
1055 tbb.fsStyle = 0;
1056 tbb.iString = (INT_PTR) MenuString;
1057 tbb.iBitmap = -1;
1058
1059 m_hasSizes = FALSE;
1060
1061 if (!AddButtons(1, &tbb))
1063
1064 return S_OK;
1065}
#define IDS_MENU_EMPTY
#define _countof(array)
Definition: sndvol32.h:70
#define GetModuleHandle
Definition: winbase.h:3827
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CMenuSFToolbar::FillToolbar().

◆ AddSeparator()

HRESULT CMenuToolbarBase::AddSeparator ( BOOL  last)
protected

Definition at line 1027 of file CMenuToolbars.cpp.

1028{
1029 TBBUTTON tbb = { 0 };
1030
1032#if !USE_TBSTYLE_EX_VERTICAL
1033 if (!last && (m_initFlags & SMINIT_VERTICAL))
1034 tbb.fsState |= TBSTATE_WRAP;
1035#endif
1036 tbb.fsStyle = BTNS_SEP;
1037 tbb.iBitmap = 0;
1038
1039 m_hasSizes = FALSE;
1040
1041 if (!AddButtons(1, &tbb))
1043
1044 return S_OK;
1045}
#define BTNS_SEP
Definition: commctrl.h:999

Referenced by CMenuStaticToolbar::FillToolbar().

◆ BeforeCancelPopup()

HRESULT CMenuToolbarBase::BeforeCancelPopup ( )

Definition at line 804 of file CMenuToolbars.cpp.

805{
807 TRACE("BeforeCancelPopup\n");
808 return S_OK;
809}
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by CMenuBand::_BeforeCancelPopup().

◆ CancelCurrentPopup()

HRESULT CMenuToolbarBase::CancelCurrentPopup ( )

Definition at line 1106 of file CMenuToolbars.cpp.

1107{
1109}
HRESULT _CancelCurrentPopup()
Definition: CMenuBand.cpp:1045

Referenced by OnPopupTimer(), and PopupItem().

◆ ChangeHotItem()

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

Definition at line 588 of file CMenuToolbars.cpp.

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

Referenced by CMenuBand::_ChangeHotItem().

◆ ChangePopupItem()

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

Definition at line 648 of file CMenuToolbars.cpp.

649{
650 // Ignore the change if it already matches the stored info
651 if (m_popupBar == toolbar && m_popupItem == item)
652 return S_FALSE;
653
654 // Notify the toolbar if the popup-tracking this toolbar
655 if (m_popupBar == this && toolbar != this)
656 {
657 CheckButton(m_popupItem, FALSE);
659 }
660
661 m_popupBar = toolbar;
663
664 if (m_popupBar == this)
665 {
666 CheckButton(m_popupItem, TRUE);
667 }
668
670 return S_OK;
671}

Referenced by CMenuBand::_ChangePopupItem().

◆ ChangeTrackedItem()

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

Definition at line 696 of file CMenuToolbars.cpp.

697{
698 TBBUTTON btn;
699 BOOL wasTracking = LOWORD(lParam);
700 BOOL mouse = HIWORD(lParam);
701 INT idx = (INT)wParam;
702
703 if (idx < 0)
704 {
707 }
708
709 if (!GetButton(idx, &btn))
710 return E_FAIL;
711
712 TRACE("ChangeTrackedItem %d, %d\n", idx, wasTracking);
713 m_isTrackingPopup = wasTracking;
714 return m_menuBand->_ChangeHotItem(this, btn.idCommand, mouse ? HICF_MOUSE : 0);
715}
HRESULT _ChangeHotItem(CMenuToolbarBase *tb, INT id, DWORD dwFlags)
Definition: CMenuBand.cpp:887
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:41
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 1067 of file CMenuToolbars.cpp.

1068{
1069 while (DeleteButton(0))
1070 {
1071 // empty;
1072 }
1073 m_hasSizes = FALSE;
1074 return S_OK;
1075}

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

◆ Close()

HRESULT CMenuToolbarBase::Close ( )

Definition at line 368 of file CMenuToolbars.cpp.

369{
370 if (m_hWnd)
372
373 if (m_pager.m_hWnd)
374 m_pager.DestroyWindow();
375
376 return S_OK;
377}

Referenced by CMenuBand::CloseDW().

◆ CreateToolbar()

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

Definition at line 379 of file CMenuToolbars.cpp.

380{
385
386 if (dwFlags & SMINIT_VERTICAL)
387 {
388 // Activate vertical semantics
389 tbStyles |= CCS_VERT;
390
391#if USE_TBSTYLE_EX_VERTICAL
392 tbExStyles |= TBSTYLE_EX_VERTICAL;
393#endif
394 }
395
397
398 // Get a temporary rect to use while creating the toolbar window.
399 // Ensure that it is not a null rect.
400 RECT rc;
401 if (!::GetClientRect(hwndParent, &rc) ||
402 (rc.left == rc.right) ||
403 (rc.top == rc.bottom))
404 {
405 rc.left = 0;
406 rc.top = 0;
407 rc.right = 1;
408 rc.bottom = 1;
409 }
410
411 // HACK & FIXME: CORE-17505
412 HWND toolbar = CToolbar::Create(hwndParent, tbStyles, tbExStyles);
413 m_hWnd = NULL;
414 SubclassWindow(toolbar);
415
416 SetWindowTheme(m_hWnd, L"", L"");
417
418 SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
419
421
422 // If needed, create the pager.
423 if (m_usePager)
424 {
425 LONG pgStyles = PGS_VERT | WS_CHILD | WS_VISIBLE;
426 LONG pgExStyles = 0;
427
428 HWND hwndPager = CreateWindowEx(
429 pgExStyles, WC_PAGESCROLLER, NULL,
430 pgStyles, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
431 hwndParent, NULL, _AtlBaseModule.GetModuleInstance(), 0);
432
433 m_pager.SubclassWindow(hwndPager);
434
435 ::SetParent(m_hWnd, hwndPager);
436
437 m_pager.SendMessageW(PGM_SETCHILD, 0, reinterpret_cast<LPARAM>(m_hWnd));
438 }
439
440 // Configure the image lists
442
443 return S_OK;
444}
HRESULT AdjustForTheme(BOOL bFlatStyle)
Definition: CMenuBand.cpp:1163
HRESULT UpdateImageLists()
HWND Create(HWND hWndParent, DWORD dwStyles=0, DWORD dwExStyles=0)
Definition: rosctrls.h:256
static HWND hwndParent
Definition: cryptui.c:300
#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:4502
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:989
#define TBSTYLE_LIST
Definition: commctrl.h:993
#define PGM_SETCHILD
Definition: commctrl.h:4516
#define CCS_VERT
Definition: commctrl.h:2249
#define TBSTYLE_EX_DOUBLEBUFFER
Definition: commctrl.h:1014
#define TBSTYLE_TRANSPARENT
Definition: commctrl.h:996
#define CCS_NODIVIDER
Definition: commctrl.h:2248
#define CCS_TOP
Definition: commctrl.h:2242
#define TBSTYLE_REGISTERDROP
Definition: commctrl.h:995
#define TBSTYLE_FLAT
Definition: commctrl.h:992
#define CCS_NOPARENTALIGN
Definition: commctrl.h:2246
#define CCS_NORESIZE
Definition: commctrl.h:2245
#define TBSTYLE_CUSTOMERASE
Definition: commctrl.h:994
#define TBSTYLE_EX_VERTICAL
Definition: commctrl.h:1011
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
HRESULT WINAPI SetWindowTheme(_In_ HWND hwnd, _In_ LPCWSTR pszSubAppName, _In_ LPCWSTR pszSubIdList)
Definition: uxthemesupp.c:69
LONG_PTR LPARAM
Definition: windef.h:208
#define SubclassWindow(hwnd, lpfn)
Definition: windowsx.h:542
#define CreateWindowEx
Definition: winuser.h:5764
HWND WINAPI SetParent(_In_ HWND, _In_opt_ HWND)
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

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

◆ DisableMouseTrack()

HRESULT CMenuToolbarBase::DisableMouseTrack ( BOOL  bDisable)

Definition at line 128 of file CMenuToolbars.cpp.

129{
130 if (m_disableMouseTrack != bDisable)
131 {
132 m_disableMouseTrack = bDisable;
133 TRACE("DisableMouseTrack %d\n", bDisable);
134 }
135 return S_OK;
136}

Referenced by CMenuBand::_DisableMouseTrack().

◆ ExecuteItem()

HRESULT CMenuToolbarBase::ExecuteItem ( )

Definition at line 892 of file CMenuToolbars.cpp.

893{
895}
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 1077 of file CMenuToolbars.cpp.

1078{
1079 if (pData)
1080 *pData = NULL;
1081
1082 if (pIndex)
1083 *pIndex = -1;
1084
1085 if (iItem < 0)
1086 return S_OK;
1087
1088 TBBUTTONINFO info = { 0 };
1089
1090 info.cbSize = sizeof(TBBUTTONINFO);
1091 info.dwMask = TBIF_COMMAND | TBIF_LPARAM;
1092
1093 int index = GetButtonInfo(iItem, &info);
1094 if (index < 0)
1095 return E_FAIL;
1096
1097 if (pIndex)
1098 *pIndex = index;
1099
1100 if (pData)
1101 *pData = info.lParam;
1102
1103 return S_OK;
1104}
#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 446 of file CMenuToolbars.cpp.

447{
448 if (pMinSize)
449 *pMinSize = m_idealSize;
450 if (pMaxSize)
451 *pMaxSize = m_idealSize;
452 if (pIntegralSize)
453 *pIntegralSize = m_itemSize;
454
455 if (m_hasSizes)
456 return S_OK;
457
458 TRACE("Sizes out of date, recalculating.\n");
459
460 if (!m_hWnd)
461 {
462 return S_OK;
463 }
464
465 // Obtain the ideal size, to be used as min and max
466 GetMaxSize(&m_idealSize);
467 GetIdealSize((m_initFlags & SMINIT_VERTICAL) != 0, &m_idealSize);
468
469 TRACE("Ideal Size: (%d, %d) for %d buttons\n", m_idealSize, GetButtonCount());
470
471 // Obtain the button size, to be used as the integral size
472 DWORD size = GetButtonSize();
476
477 if (pMinSize)
478 *pMinSize = m_idealSize;
479 if (pMaxSize)
480 *pMaxSize = m_idealSize;
481 if (pIntegralSize)
482 *pIntegralSize = m_itemSize;
483
484 return S_OK;
485}
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 518 of file CMenuToolbars.cpp.

519{
520 if (!phwnd)
521 return E_FAIL;
522
523 if (m_pager.m_hWnd)
524 *phwnd = m_pager.m_hWnd;
525 else
526 *phwnd = m_hWnd;
527
528 return S_OK;
529}

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 311 of file CMenuToolbars.cpp.

312{
314}
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 673 of file CMenuToolbars.cpp.

674{
675 TBBUTTON btn;
676 INT idx = (INT)wParam;
677
678 if (m_hotBar != this)
679 return S_FALSE;
680
681 if (idx < 0)
682 return S_FALSE;
683
684 if (!GetButton(idx, &btn))
685 return E_FAIL;
686
687 if (m_hotItem == btn.idCommand)
688 return S_OK;
689
690 if (m_popupItem == btn.idCommand)
691 return S_OK;
692
693 return S_FALSE;
694}

◆ IsWindowOwner()

HRESULT CMenuToolbarBase::IsWindowOwner ( HWND  hwnd)

Definition at line 511 of file CMenuToolbars.cpp.

512{
513 if (m_hWnd && m_hWnd == hwnd) return S_OK;
514 if (m_pager.m_hWnd && m_pager.m_hWnd == hwnd) return S_OK;
515 return S_FALSE;
516}
_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 897 of file CMenuToolbars.cpp.

898{
899 int prev = m_hotItem;
900 int index = -1;
901
902 if (dwSelectType != 0xFFFFFFFF)
903 {
904 int count = GetButtonCount();
905
906 if (dwSelectType == VK_HOME)
907 {
908 index = 0;
909 dwSelectType = VK_DOWN;
910 }
911 else if (dwSelectType == VK_END)
912 {
913 index = count - 1;
914 dwSelectType = VK_UP;
915 }
916 else
917 {
918 if (m_hotItem >= 0)
919 {
920 TBBUTTONINFO info = { 0 };
921 info.cbSize = sizeof(TBBUTTONINFO);
922 info.dwMask = 0;
923 index = GetButtonInfo(m_hotItem, &info);
924 }
925
926 if (index < 0)
927 {
928 if (dwSelectType == VK_UP)
929 {
930 index = count - 1;
931 }
932 else if (dwSelectType == VK_DOWN)
933 {
934 index = 0;
935 }
936 }
937 else
938 {
939 if (dwSelectType == VK_UP)
940 {
941 index--;
942 }
943 else if (dwSelectType == VK_DOWN)
944 {
945 index++;
946 }
947 }
948 }
949
950 TBBUTTON btn = { 0 };
951 while (index >= 0 && index < count)
952 {
953 DWORD res = GetButton(index, &btn);
954 if (!res)
955 return E_FAIL;
956
957 if (btn.dwData)
958 {
959 if (prev != btn.idCommand)
960 {
961 TRACE("Setting Hot item to %d\n", index);
962 if (!(m_initFlags & SMINIT_VERTICAL) && m_isTrackingPopup)
963 {
964 HWND tlw;
966 ::SendMessageW(tlw, WM_CANCELMODE, 0, 0);
968 }
969 else
970 m_menuBand->_ChangeHotItem(this, btn.idCommand, 0);
971 }
972 return S_OK;
973 }
974
975 if (dwSelectType == VK_UP)
976 {
977 index--;
978 }
979 else if (dwSelectType == VK_DOWN)
980 {
981 index++;
982 }
983 }
984
985 return S_FALSE;
986 }
987
988 if (prev != -1)
989 {
990 TRACE("Setting Hot item to null\n");
992 }
993
994 return S_FALSE;
995}
#define WM_USER_CHANGETRACKEDITEM
Definition: CMenuToolbars.h:26
HRESULT _GetTopLevelWindow(HWND *topLevel)
Definition: CMenuBand.cpp:881
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint res
Definition: glext.h:9613
#define MAKELPARAM(l, h)
Definition: winuser.h:4008
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CANCELMODE
Definition: winuser.h:1635
#define VK_UP
Definition: winuser.h:2225
#define VK_END
Definition: winuser.h:2222
#define VK_HOME
Definition: winuser.h:2223
#define VK_DOWN
Definition: winuser.h:2227
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ KillPopupTimer()

HRESULT CMenuToolbarBase::KillPopupTimer ( )

Definition at line 577 of file CMenuToolbars.cpp.

578{
579 if (m_timerEnabled)
580 {
583 return S_OK;
584 }
585 return S_FALSE;
586}
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by CMenuBand::_KillPopupTimers().

◆ MenuBarMouseDown()

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

Definition at line 850 of file CMenuToolbars.cpp.

851{
852 TBBUTTON btn;
853
854 GetButton(iIndex, &btn);
855
856 if ((m_initFlags & SMINIT_VERTICAL)
857 || m_popupBar
859 {
861 return S_OK;
862 }
863
864 return ProcessClick(btn.idCommand);
865}
HRESULT ProcessClick(INT iItem)

Referenced by CMenuBand::_MenuBarMouseDown().

◆ MenuBarMouseUp()

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

Definition at line 867 of file CMenuToolbars.cpp.

868{
869 TBBUTTON btn;
870
872
873 if (!(m_initFlags & SMINIT_VERTICAL))
874 return S_OK;
875
876 GetButton(iIndex, &btn);
877
878 if (isLButton)
879 return ProcessClick(btn.idCommand);
880 else
881 return ProcessContextMenu(btn.idCommand);
882}
HRESULT ProcessContextMenu(INT iItem)

Referenced by CMenuBand::_MenuBarMouseUp().

◆ OnCustomDraw()

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

Definition at line 153 of file CMenuToolbars.cpp.

154{
155 bool isHot, isPopup, isActive;
156 TBBUTTONINFO btni;
157
158 switch (cdraw->nmcd.dwDrawStage)
159 {
160 case CDDS_PREPAINT:
161 *theResult = CDRF_NOTIFYITEMDRAW;
162 return S_OK;
163
165
166 HWND tlw;
168
169 // The item with an active submenu gets the CHECKED flag.
170 isHot = m_hotBar == this && (int) cdraw->nmcd.dwItemSpec == m_hotItem;
171 isPopup = m_popupBar == this && (int) cdraw->nmcd.dwItemSpec == m_popupItem;
172 isActive = (GetForegroundWindow() == tlw) || (m_popupBar == this);
173
174 if (m_hotItem < 0 && isPopup)
175 isHot = TRUE;
176
177 if ((m_useFlatMenus && isHot) || (m_initFlags & SMINIT_VERTICAL))
178 {
179 COLORREF clrText;
180 HBRUSH bgBrush;
181 RECT rc = cdraw->nmcd.rc;
182 HDC hdc = cdraw->nmcd.hdc;
183
184 // Remove HOT and CHECKED flags (will restore HOT if necessary)
185 cdraw->nmcd.uItemState &= ~(CDIS_HOT | CDIS_CHECKED);
186
187 // Decide on the colors
188 if (isHot)
189 {
190 cdraw->nmcd.uItemState |= CDIS_HOT;
191
193 bgBrush = GetSysColorBrush(m_useFlatMenus ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT);
194 }
195 else
196 {
197 clrText = GetSysColor(COLOR_MENUTEXT);
198 bgBrush = GetSysColorBrush(COLOR_MENU);
199 }
200
201 // Paint the background color with the selected color
202 FillRect(hdc, &rc, bgBrush);
203
204 // Set the text color in advance, this color will be assigned when the ITEMPOSTPAINT triggers
205 SetTextColor(hdc, clrText);
206
207 // Set the text color, will be used by the internal drawing code
208 cdraw->clrText = clrText;
209 cdraw->iListGap += 4;
210
211 // Tell the default drawing code we don't want any fanciness, not even a background.
212 *theResult = CDRF_NOTIFYPOSTPAINT | TBCDRF_NOBACKGROUND | TBCDRF_NOEDGES | TBCDRF_NOOFFSET | TBCDRF_NOMARK | 0x00800000; // FIXME: the last bit is Vista+, useful for debugging only
213 }
214 else
215 {
216 // Set the text color, will be used by the internal drawing code
217 cdraw->clrText = GetSysColor(isActive ? COLOR_MENUTEXT : COLOR_GRAYTEXT);
218
219 // Remove HOT and CHECKED flags (will restore HOT if necessary)
220 cdraw->nmcd.uItemState &= ~CDIS_HOT;
221
222 // Decide on the colors
223 if (isHot)
224 {
225 cdraw->nmcd.uItemState |= CDIS_HOT;
226 }
227
228 *theResult = 0;
229 }
230
231 return S_OK;
232
234
235 // Fetch the button style
236 btni.cbSize = sizeof(btni);
237 btni.dwMask = TBIF_STYLE;
238 GetButtonInfo(cdraw->nmcd.dwItemSpec, &btni);
239
240 // Check if we need to draw a submenu arrow
241 if (btni.fsStyle & BTNS_DROPDOWN)
242 {
243 // TODO: Support RTL text modes by drawing a leftwards arrow aligned to the left of the control
244
245 // "8" is the rightwards dropdown arrow in the Marlett font
246 WCHAR text [] = L"8";
247
248 // Configure the font to draw with Marlett, keeping the current background color as-is
249 HGDIOBJ hFontOld = SelectObject(cdraw->nmcd.hdc, m_marlett);
250 SetBkMode(cdraw->nmcd.hdc, TRANSPARENT);
251
252 // Tweak the alignment by 1 pixel so the menu draws like the Windows start menu.
253 RECT rc = cdraw->nmcd.rc;
254 rc.right += 1;
255
256 // The arrow is drawn at the right of the item's rect, aligned vertically.
258
259 SelectObject(cdraw->nmcd.hdc, hFontOld);
260 }
261 *theResult = TRUE;
262 return S_OK;
263
264 default:
265 *theResult = 0L;
266 break;
267 }
268 return S_OK;
269}
const WCHAR * text
Definition: package.c:1799
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:92
#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
NMCUSTOMDRAW nmcd
Definition: commctrl.h:1017
COLORREF clrText
Definition: commctrl.h:1021
DWORD_PTR dwItemSpec
Definition: commctrl.h:307
DWORD COLORREF
Definition: windef.h:300
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#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:918
DWORD WINAPI GetSysColor(_In_ int)
#define COLOR_MENU
Definition: winuser.h:917
#define COLOR_GRAYTEXT
Definition: winuser.h:932
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define COLOR_HIGHLIGHT
Definition: winuser.h:926
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:927
#define DT_VCENTER
Definition: winuser.h:543
#define DT_RIGHT
Definition: winuser.h:538
#define COLOR_MENUTEXT
Definition: winuser.h:920
#define DrawTextEx
Definition: winuser.h:5781

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 531 of file CMenuToolbars.cpp.

532{
533 INT index;
535
536 INT iItem = tip->iItem;
537
538 GetDataFromId(iItem, &index, &dwData);
539
540 return InternalGetTooltip(iItem, index, dwData, tip->pszText, tip->cchTextMax);
541}
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: file.c:35
uint32_t DWORD_PTR
Definition: typedefs.h:65

Referenced by OnWinEvent().

◆ OnPagerCalcSize()

HRESULT CMenuToolbarBase::OnPagerCalcSize ( LPNMPGCALCSIZE  csize)
private

Definition at line 138 of file CMenuToolbars.cpp.

139{
140 SIZE tbs;
141 GetSizes(NULL, &tbs, NULL);
142 if (csize->dwFlag == PGF_CALCHEIGHT)
143 {
144 csize->iHeight = tbs.cy;
145 }
146 else if (csize->dwFlag == PGF_CALCWIDTH)
147 {
148 csize->iWidth = tbs.cx;
149 }
150 return S_OK;
151}
HRESULT GetSizes(SIZE *pMinSize, SIZE *pMaxSize, SIZE *pIntegralSize)
#define PGF_CALCWIDTH
Definition: commctrl.h:4582
#define PGF_CALCHEIGHT
Definition: commctrl.h:4583
DWORD dwFlag
Definition: commctrl.h:4587

Referenced by OnWinEvent().

◆ OnPopupTimer()

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

Definition at line 543 of file CMenuToolbars.cpp.

544{
546 {
547 bHandled = FALSE;
548 return 0;
549 }
550
552
553 if (!m_timerEnabled)
554 return 0;
555
557
558 if (m_hotItem < 0)
559 return 0;
560
561 // Returns S_FALSE if the current item did not show a submenu
563 if (hr != S_FALSE)
564 return 0;
565
566 // If we didn't switch submenus, cancel the current popup regardless
567 if (m_popupBar)
568 {
571 return 0;
572 }
573
574 return 0;
575}
HRESULT CancelCurrentPopup()
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT hr
Definition: shlfolder.c:183

◆ OnWinEvent()

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

Definition at line 46 of file CMenuToolbars.cpp.

47{
48 NMHDR * hdr;
49 HRESULT hr;
51
52 if (theResult)
53 *theResult = 0;
54 switch (uMsg)
55 {
56 case WM_COMMAND:
57 //return OnCommand(wParam, lParam, theResult);
58 return S_OK;
59
60 case WM_NOTIFY:
61 hdr = reinterpret_cast<LPNMHDR>(lParam);
62 switch (hdr->code)
63 {
65 return OnDeletingButton(reinterpret_cast<LPNMTOOLBAR>(hdr));
66
67 case PGN_CALCSIZE:
68 return OnPagerCalcSize(reinterpret_cast<LPNMPGCALCSIZE>(hdr));
69
70 case TBN_DROPDOWN:
71 return ProcessClick(reinterpret_cast<LPNMTOOLBAR>(hdr)->iItem);
72
74 //return OnHotItemChange(reinterpret_cast<LPNMTBHOTITEM>(hdr), theResult);
75 return S_OK;
76
77 case NM_CUSTOMDRAW:
78 hr = OnCustomDraw(reinterpret_cast<LPNMTBCUSTOMDRAW>(hdr), &result);
79 if (theResult)
80 *theResult = result;
81 return hr;
82
83 case TBN_GETINFOTIP:
84 return OnGetInfoTip(reinterpret_cast<LPNMTBGETINFOTIP>(hdr));
85
86 // Silence unhandled items so that they don't print as unknown
87 case RBN_CHILDSIZE:
88 return S_OK;
89
90 case TTN_GETDISPINFO:
91 return S_OK;
92
94 break;
95
96 case NM_CLICK:
97 case NM_RDOWN:
98 case NM_LDOWN:
99 break;
100
101 case TBN_GETDISPINFO:
102 break;
103
104 case TBN_BEGINDRAG:
105 case TBN_ENDDRAG:
106 break;
107
109 break;
110
111 case TBN_DRAGOUT: return S_FALSE;
112
113 default:
114 TRACE("WM_NOTIFY unknown code %d, %d\n", hdr->code, hdr->idFrom);
115 return S_OK;
116 }
117 return S_FALSE;
118 case WM_WININICHANGE:
119 if (wParam == SPI_SETFLATMENU)
120 {
121 SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
122 }
123 }
124
125 return S_FALSE;
126}
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
#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:1878
#define NM_CLICK
Definition: commctrl.h:130
#define LPNMTOOLBAR
Definition: commctrl.h:1457
#define PGN_CALCSIZE
Definition: commctrl.h:4580
#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_NOTIFY
Definition: richedit.h:61
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_WININICHANGE
Definition: winuser.h:1630

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

◆ OnWinEventWrap()

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

Definition at line 39 of file CMenuToolbars.cpp.

40{
41 LRESULT lr;
42 bHandled = OnWinEvent(m_hWnd, uMsg, wParam, lParam, &lr) != S_FALSE;
43 return lr;
44}
HRESULT OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)

◆ PopupItem()

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

Definition at line 1111 of file CMenuToolbars.cpp.

1112{
1113 INT index;
1115
1116 if (iItem < 0)
1117 return S_OK;
1118
1119 if (m_popupBar == this && m_popupItem == iItem)
1120 return S_OK;
1121
1122 GetDataFromId(iItem, &index, &dwData);
1123
1125 if (hr != S_OK)
1126 return hr;
1127
1128 if (m_popupBar)
1129 {
1132 return hr;
1133 }
1134
1135 if (!(m_initFlags & SMINIT_VERTICAL))
1136 {
1137 TRACE("PopupItem non-vertical %d %d\n", index, iItem);
1138 m_menuBand->_ChangeHotItem(this, iItem, 0);
1139 }
1140
1141 return InternalPopupItem(iItem, index, dwData, keyInitiated);
1142}
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 758 of file CMenuToolbars.cpp.

759{
760 // Calculate the submenu position and exclude area
761 RECT rc = { 0 };
762
763 if (!GetItemRect(index, &rc))
764 return E_FAIL;
765
766 POINT a = { rc.left, rc.top };
767 POINT b = { rc.right, rc.bottom };
768
771
772 POINT pt = { a.x, b.y };
773 RECT rcl = { a.x, a.y, b.x, b.y };
774
775 if (m_initFlags & SMINIT_VERTICAL)
776 {
777 pt.x = b.x;
778 pt.y = a.y;
779 }
780
781 HMENU popup = GetSubMenu(menu, index);
782
783 // Display the submenu
785 m_menuBand->_ChangePopupItem(this, iItem);
786 m_menuBand->_TrackSubMenu(popup, pt.x, pt.y, rcl);
789
790 return S_OK;
791}
HRESULT _TrackSubMenu(HMENU popup, INT x, INT y, RECT &rcExclude)
Definition: CMenuBand.cpp:800
HRESULT _ChangePopupItem(CMenuToolbarBase *tb, INT id)
Definition: CMenuBand.cpp:906
#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:63
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 717 of file CMenuToolbars.cpp.

718{
719 // Calculate the submenu position and exclude area
720 RECT rc = { 0 };
721
722 if (!GetItemRect(index, &rc))
723 return E_FAIL;
724
725 POINT a = { rc.left, rc.top };
726 POINT b = { rc.right, rc.bottom };
727
730
731 POINTL pt = { a.x, b.y };
732 RECTL rcl = { a.x, a.y, b.x, b.y };
733
734 if (m_initFlags & SMINIT_VERTICAL)
735 {
736 // FIXME: Hardcoding this here feels hacky.
737 if (IsAppThemed())
738 {
739 pt.x = b.x - 1;
740 pt.y = a.y - 1;
741 }
742 else
743 {
744 pt.x = b.x - 3;
745 pt.y = a.y - 3;
746 }
747 }
748
749 // Display the submenu
751
752 m_menuBand->_ChangePopupItem(this, iItem);
753 m_menuBand->_OnPopupSubMenu(childShellMenu, &pt, &rcl, keyInitiated);
754
755 return S_OK;
756}
HRESULT _OnPopupSubMenu(IShellMenu *childShellMenu, POINTL *pAt, RECTL *pExclude, BOOL mouseInitiated)
Definition: CMenuBand.cpp:1062
BOOL WINAPI IsAppThemed(void)
Definition: system.c:596

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

◆ PrepareExecuteItem()

HRESULT CMenuToolbarBase::PrepareExecuteItem ( INT  iItem)

Definition at line 884 of file CMenuToolbars.cpp.

885{
887
888 m_executeItem = iItem;
890}
HRESULT _KillPopupTimers()
Definition: CMenuBand.cpp:1126

◆ ProcessClick()

HRESULT CMenuToolbarBase::ProcessClick ( INT  iItem)

Definition at line 811 of file CMenuToolbars.cpp.

812{
814 {
815 TRACE("Item click prevented by DisableMouseTrack\n");
816 return S_OK;
817 }
818
819 // If a button is clicked while a submenu was open, cancel the submenu.
820 if (!(m_initFlags & SMINIT_VERTICAL) && m_isTrackingPopup)
821 {
822 TRACE("OnCommand cancelled because it was tracking submenu.\n");
823 return S_FALSE;
824 }
825
826 if (PopupItem(iItem, FALSE) == S_OK)
827 {
828 TRACE("PopupItem returned S_OK\n");
829 return S_FALSE;
830 }
831
832 TRACE("Executing...\n");
833
834 return m_menuBand->_MenuItemSelect(MPOS_EXECUTE);
835}
HRESULT _MenuItemSelect(DWORD changeType)
Definition: CMenuBand.cpp:961

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

◆ ProcessContextMenu()

HRESULT CMenuToolbarBase::ProcessContextMenu ( INT  iItem)

Definition at line 837 of file CMenuToolbars.cpp.

838{
839 INT index;
841
842 GetDataFromId(iItem, &index, &data);
843
846
847 return InternalContextMenu(iItem, index, data, pt);
848}
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 487 of file CMenuToolbars.cpp.

488{
489 // Update the toolbar or pager to fit the requested rect
490 // If we have a pager, set the toolbar height to the ideal height of the toolbar
491 if (m_pager.m_hWnd)
492 {
494 m_pager.SetWindowPos(NULL, x, y, cx, cy, 0);
495 }
496 else
497 {
498 SetWindowPos(NULL, x, y, cx, cy, 0);
499 }
500
501 // In a vertical menu, resize the buttons to fit the width
502 if (m_initFlags & SMINIT_VERTICAL)
503 {
504 DWORD btnSize = GetButtonSize();
505 SetButtonSize(cx, GET_Y_LPARAM(btnSize));
506 }
507
508 return S_OK;
509}
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 316 of file CMenuToolbars.cpp.

317{
318 if (m_hWnd == NULL)
319 return S_FALSE;
320
321 ShowWindow(fShow ? SW_SHOW : SW_HIDE);
322
323 // Ensure that the right image list is assigned to the toolbar
325
326 // For custom-drawing
327 SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
328
329 return S_OK;
330}
#define SW_HIDE
Definition: winuser.h:768
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define SW_SHOW
Definition: winuser.h:775

Referenced by CMenuBand::ShowDW().

◆ TrackContextMenu()

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

Definition at line 793 of file CMenuToolbars.cpp.

794{
795 // Cancel submenus
797 if (m_popupBar)
799
800 // Display the context menu
801 return m_menuBand->_TrackContextMenu(contextMenu, pt.x, pt.y);
802}
HRESULT _TrackContextMenu(IContextMenu *popup, INT x, INT y)
Definition: CMenuBand.cpp:821

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

◆ UpdateImageLists()

HRESULT CMenuToolbarBase::UpdateImageLists ( )
private

Definition at line 332 of file CMenuToolbars.cpp.

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

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: