We have an application, which must be maintained using MFC, as well as uses the Prof-UIS library (different build targets). In several locations throughout the code, menu items are inserted dynamically to the CMenu instances, and this works fine for MFC. I have discovered that we must ignore the m_pMenu referenced within the pCmdUI parameter when running under Prof-UIS - this is OK.
However, the observation is that when running with Prof-UIS, the menu item inserted with InsertMenu(), does not appear in the menu until the drop-down menu is dropped down a second time. I have read about using OnExtMenuPrepare() to to dynamic menu creation, but this method is not compatible with our desire to maintain the MFC version in the mannor it is currently being used. What I hope to do is use OnExtMenuPrepare() to force a new transfer of the CMenu items to the CExtPopupMenuWnd items (I guess through UpdateFromMenu(), but the following snippet closes the menu and causes an assertion):
LRESULT CMainFrame::OnExtMenuPrepare(WPARAM wParam, LPARAM lParam) {
CExtPopupMenuWnd::MsgPrepareMenuData_t * pData = reinterpret_cast< CExtPopupMenuWnd::MsgPrepareMenuData_t * > (wParam);
ASSERT( pData != NULL );
CExtPopupMenuWnd * pPopup = pData->m_pPopup;
ASSERT( pPopup != NULL );
CMenu *pMenu = m_wndMenuBar->GetMenu();
pPopup->UpdateFromMenu( GetSafeHwnd(), pMenu, true, false );
return TRUE;
}
In addition, the menu pMenu is not the one which I think should be bound with this instance of pData->m_pPopup. Any sugguestions as to how to make this scheme work?
Thanks