I tried all sorts of functions such as PreCreateWindow, OnCreate, OnWindowPOSChanged, OnWindowPOSChanging.
I found that none of them worked. What did work was setting the CFMCPopupMenu::m_nMaxHeight before calling Create. This constrained the height of the popup menu to the size I wanted. The keyboard works now as does the mouse scroll wheel.
To get the scrollbar to display properly, I also had to set both CMFCPopupMenu::m_bShowScrollBar and CMFCPopupMenu::m_bScrollable to true before calling Create().
I have now run across another problem: m_bShowScrollBar stops the CMFCPopupMenu from sending WM_COMMAND messages to the parent window when an item is clicked. I'll dive into this and post an update or create another post if I need help.
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_bShowScrollBar = true;
m_bScrollable = true;
m_nMaxHeight = rParentRect.Height();
// Call the base class Create method
TRACE0("BECPopupMenu::Create() Create\n");
if (!CMFCPopupMenu::Create(pWndParent, x, y, hMenu, bLocked, bOwnMessage)) {
TRACE0("Failed to create BECPopupMenu\n");
return FALSE;
}
}