Further to the above:
The CMFCPopupMenuBar::m_bDropDownListMode member is set equal to CMFCPopupMenu::m_bShowScrollBar member variable in the CMFCPopupMenu::Create.
This shuts off sending the WM_COMMAND when you click on a menu item.
Setting CMFCPopupMenu::m_bShowScrollBar true after the Create is called, followed by RecalcLayout() seems to correct the issue. Now I have scroll bars and can click on menu items to send an ON_COMMAND to the host window.
I'm not sure what downsides there might be to this. Feel free to comment. Thanks!
BOOL MyPopupMenu::Create(CWnd* pWndParent, int x, int y, HMENU hMenu, BOOL bLocked, BOOL bOwnMessage)
{
CRect rParentRect;
m_pBoundsWnd = pWndParent;
m_pBoundsWnd->GetWindowRect(rParentRect);
m_nMaxHeight = rParentRect.Height();
// Call the base class Create method
if (!CMFCPopupMenu::Create(pWndParent, x, y, hMenu, bLocked, bOwnMessage)) {
TRACE0("Failed to create BECPopupMenu\n");
return FALSE;
}
// These have to be called AFTER the create or you can't click on the menu items to send the ONCOMMAND to the parent.
// Internally CMFCPopupMenu::Create() sets the CMFCMenuBar::m_bDropDownListMode = m_bShowScrollBar.
// If it is true , it will not send the ONCOMMAND to the parent.
// Setting m_bShowScrollBar afterward and THEN calling RecalcLayout() will ensure that the menu behaves correctly.
m_bShowScrollBar = true;
m_bScrollable = true;
RecalcLayout();
return TRUE; // Indicate successful creation
}