Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka committed Aug 13, 2024
1 parent c4b9f48 commit 5f69d87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Src/CommandBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -338,6 +347,7 @@ BOOL CCommandBar::PreTranslateMessage(MSG* pMsg)
UINT uId = 0;
if ((pMsg->message == WM_SYSKEYDOWN) && GetToolBarCtrl().MapAccelerator(static_cast<TCHAR>(pMsg->wParam), &uId) != 0)
{
ShowKeyboardCues(true);
OnCommandBarMenuItem(uId);
return TRUE;
}
Expand Down
1 change: 1 addition & 0 deletions Src/CommandBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5f69d87

Please sign in to comment.