|
I am a new user to the Pro version of toolkit and am trying to get to grips with the menus and toolbars which are very different from their MFC equivalents. As such I am updating my application to work as it did before under the toolkit.
I want to add a list of MRU reports to a Reports menu. I have added a handler for OnInitCommandsPopup, ensured that the popup menu is in fact the Reports menu and then wondered how to add items to it.
My thoughts were to create a CMenu popup menu and then add my new items to it, finally calling LoadMenu to load the CMenu into the command bar. This should have loaded a menu with 10 items but instead I only got the one and this was disabled.
I have used the following code:
// get the list of commands for the popup. CXTPControls* pCommandList = pCommandBar->GetControls();
// Is this the ReportWizard menu? CXTPControl* pReports = pCommandList->FindControl(xtpControlButton, ID_AUDIT_REPORT, TRUE, FALSE); if (!pReports) return;
// OK - we are popping up the Reports Menu - let's build the menu first CMenu PopupMenu; PopupMenu.CreatePopupMenu ();
DWORD dwCmdID = ID_FILE_MRU_FILE1; for (DWORD dw=0; dw<RptIni.m_listMRUReports.GetCount(); dw++) { PopupMenu.AppendMenu(MF_STRING ,dwCmdID++ ,RptIni.m_listMRUReports[dw]); }
// ...add ReportWizard to the end of the menu PopupMenu.AppendMenu (MF_SEPARATOR ,0 ,""); PopupMenu.AppendMenu (MF_STRING ,ID_AUDIT_REPORT ,"Report&Wizard");
// ...and then load this menu pCommandBar->LoadMenu(&PopupMenu ,TRUE);
This should have created loads of entries but instead I get 1 entry in the menu from the array of reports and the final ReportWizard entry - however the menu items entered in the loop are all disabled.
I have also added
ON_COMMAND_RANGE(ID_FILE_MRU_FILE1, ID_FILE_MRU_FILE16, OnMRUReport)
to my message map so it should (and did under MFC) work.
Any suggestions would be very welcome
|