Ok I seemed to figure how to place one menu inside the other. It's a mix of CMenu and codejock controls - definitely not an elegant. I prefer just using codejock controls so if you have an answer to my first reply it would be appreciated. One thing I don't understand with this solution is why the icons are being placed next to the caption of the sub menu since I'm no longer setting the icon id using the CXTPControl - I'm using a simple CMenu. A further problem is my sub menu is all grayed out - not sure why either. The code is below.
int intMenuCmd = MENU_ID_CANCEL;
CMenu objMainMenu, objSubMenu;
BOOL bMenuCreated = FALSE;
CPoint objPoint;
BOOL bGetCursorPos = FALSE;
CXTPPopupBar* pObjPopupBar;
CXTPPopupBar* pObjParentPopupBar;
CXTPFrameWnd* pFrame = (CXTPFrameWnd*)AfxGetMainWnd();
// Create the popup bars
pObjParentPopupBar = CXTPPopupBar::CreatePopupBar(0);
pObjPopupBar = CXTPPopupBar::CreatePopupBar(0);
// Create the top level menu
bMenuCreated = objMainMenu.CreatePopupMenu();
// Create the sub menu
bMenuCreated = objSubMenu.CreatePopupMenu();
// Obtain a list of supported document types. These types are specified
// Load the menu into a popup bar
pObjPopupBar->LoadMenu(&objSubMenu);
CXTPControls* pControls = pObjPopupBar->GetControls();
for( int i=0; i< pControls->GetCount(); i++ )
{
CXTPControl* a = pControls->GetAt(i);
a->SetEnabled(TRUE);
}
// Determine if the Add menu item should appear - Note: this menu item
// contains a sub-menu
if( objSubMenu.GetMenuItemCount() )
{
objMainMenu.AppendMenu( MF_POPUP,
(UINT)objSubMenu.m_hMenu,
objResourceProvider.GetStringResource(IDS_SKSD_ADD));
CXTPControl* pControl = pObjParentPopupBar->GetControls()->AddMenuItem(&ob jMainMenu, objMainMenu.GetMenuItemCount()-1);
pControl->SetCaption(objResourceProvider.GetStringResourc e(IDS_SKSD_ADD));
pControl->SetFlags(xtpFlagManualUpdate);
}
// Determine if the Delete menu item should appear
if( pDocument->CanBeRemoved() )
{
objMainMenu.AppendMenu( MF_STRING,
IDS_SKSD_DELETE ,
objResourceProvider.GetStringResource(IDS_SKSD_DELETE));
CXTPControl* pControl = pObjParentPopupBar->GetControls()->AddMenuItem(&ob jMainMenu, objMainMenu.GetMenuItemCount()-1);
pControl->SetCaption(objResourceProvider.GetStringResourc e(IDS_SKSD_DELETE));
//pControl->SetFlags(xtpFlagManualUpdate);
}
// Determine if the Rename menu item should appear
if( pDocument->CanBeRenamed() )
{
objMainMenu.AppendMenu( MF_STRING,
IDS_SKSD_RENAME,
objResourceProvider.GetStringResource(IDS_SKSD_RENAME));
CXTPControl* pControl = pObjParentPopupBar->GetControls()->AddMenuItem(&ob jMainMenu, objMainMenu.GetMenuItemCount()-1);
pControl->SetCaption(objResourceProvider.GetStringResourc e(IDS_SKSD_RENAME));
pControl->SetFlags(xtpFlagManualUpdate);
}
UINT intCommand = CXTPCommandBars::TrackPopupMenu(pObjParentPopupBar, TPM_RETURNCMD, objPoint.x, objPoint.y, (CWnd*)m_pParentWnd);
thanks
|