From 5f69d873c777a3320086347eb068bb867730ff8a Mon Sep 17 00:00:00 2001 From: sdottaka Date: Tue, 13 Aug 2024 20:34:43 +0900 Subject: [PATCH] WIP --- Src/CommandBar.cpp | 22 ++++++++++++++++------ Src/CommandBar.h | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Src/CommandBar.cpp b/Src/CommandBar.cpp index 9c2cd41c998..3b436f9af40 100644 --- a/Src/CommandBar.cpp +++ b/Src/CommandBar.cpp @@ -169,14 +169,19 @@ static bool IsMDIChildMaximized() return bMaximized; } +void CCommandBar::ShowKeyboardCues(bool show) +{ + m_bShowKeyboardCues = show; + GetToolBarCtrl().SetDrawTextFlags(DT_HIDEPREFIX, show ? 0 : DT_HIDEPREFIX); + Invalidate(); +} + void CCommandBar::LoseFocus() { m_bActive = false; m_hwndOldFocus = nullptr; - m_bShowKeyboardCues = false; - GetToolBarCtrl().SetDrawTextFlags(DT_HIDEPREFIX, DT_HIDEPREFIX); + ShowKeyboardCues(false); GetToolBarCtrl().SetHotItem(-1); - Invalidate(); } void CCommandBar::OnSetFocus(CWnd* pOldWnd) @@ -293,6 +298,12 @@ void CCommandBar::OnCommandBarMenuItem(UINT nID) m_hCurrentPopupMenu = pPopup->m_hMenu; m_pThis = this; + if (m_bShowKeyboardCues) + { + AfxGetMainWnd()->PostMessage(WM_KEYDOWN, VK_DOWN, 0); + AfxGetMainWnd()->PostMessage(WM_KEYUP, VK_DOWN, 0); + } + m_hHook = SetWindowsHookEx(WH_MSGFILTER, MsgFilterProc, nullptr, GetCurrentThreadId()); CRect rc; @@ -322,9 +333,7 @@ BOOL CCommandBar::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_SYSKEYDOWN) { - m_bShowKeyboardCues = true; - GetToolBarCtrl().SetDrawTextFlags(DT_HIDEPREFIX, 0); - Invalidate(); + ShowKeyboardCues(true); } else if (pMsg->message == WM_SYSKEYUP && m_bShowKeyboardCues) { @@ -338,6 +347,7 @@ BOOL CCommandBar::PreTranslateMessage(MSG* pMsg) UINT uId = 0; if ((pMsg->message == WM_SYSKEYDOWN) && GetToolBarCtrl().MapAccelerator(static_cast(pMsg->wParam), &uId) != 0) { + ShowKeyboardCues(true); OnCommandBarMenuItem(uId); return TRUE; } diff --git a/Src/CommandBar.h b/Src/CommandBar.h index 182774d132a..d52749495b2 100644 --- a/Src/CommandBar.h +++ b/Src/CommandBar.h @@ -42,6 +42,7 @@ class CCommandBar : public CToolBar int GetMDIButtonIndexFromPoint(CPoint pt) const; CRect GetMDIButtonsRect() const; CRect GetMDIButtonRect(int nItem) const; + void ShowKeyboardCues(bool show); void LoseFocus(); HMENU m_hMenu;