Print Page | Close Window

[solved] how to add submenu?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=23187
Printed Date: 21 November 2024 at 11:02pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [solved] how to add submenu?
Posted By: ksc4703
Subject: [solved] how to add submenu?
Date Posted: 06 November 2016 at 9:47pm
hi!

i'm trying to add submenu as a popup item.

My project does not have a red box menu below.



i want to makes dynamic submenu.


CXTPCommandBars* pCommandBars = GetCommandBars();
CXTPMenuBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAIN_MENU); 

CXTPControls* pControls = pMenuBar->GetControls();
CXTPControl* pControl = pControls->GetAt(5);                   // <== "Tools"
CXTPControls* pUtilCtrls = pControl->GetCommandBar()->GetControls();

CXTPControl* pSubMenuItemCtrl = pUtilCtrls->GetAt(2);    // <== "Item3"

// make some menu for dynamic menu.
CMenu SubMenu;
SubMenu.CreatePopupMenu();
InsertMenu(SubMenu, 0, MF_BYPOSITION | MF_STRING, IDD_DYNAMIC+1, _T("Item3-1"));
InsertMenu(SubMenu, 0, MF_BYPOSITION | MF_STRING, IDD_DYNAMIC+2, _T("Item3-2"));
InsertMenu(SubMenu, 0, MF_BYPOSITION | MF_STRING, IDD_DYNAMIC+3, _T("Item3-3"));

pSubMenuItemCtrl ->GetControls()->AddMenuItem(&SubMenu, 0);
pSubMenuItemCtrl ->GetControls()->AddMenuItem(&SubMenu, 1);
pSubMenuItemCtrl ->GetControls()->AddMenuItem(&SubMenu, 2);

but result is below.



How to do this?




Replies:
Posted By: olebed
Date Posted: 11 November 2016 at 12:07pm
    CXTPCommandBars* pCommandBars = GetCommandBars();
    CXTPMenuBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME);

    CXTPControls* pControls        = pMenuBar->GetControls();
    CXTPControl*  pControl        = pControls->GetAt(5);                   // <== "Tools"
    CXTPControls* pUtilCtrls    = pControl->GetCommandBar()->GetControls();

    CXTPControl* pSubMenuItemCtrl = pUtilCtrls->GetAt(2);    // <== "Item3"  

// I don't know how change  usual type of menu item to popup. Just delete and create new.
    pUtilCtrls->Remove(pSubMenuItemCtrl);

 // make some menu for dynamic menu.
    CMenu SubMenu;
    SubMenu.CreatePopupMenu();

    SubMenu.AppendMenu(MF_BYPOSITION | MF_STRING, IDD_DYNAMIC+1, _T("Item3-1"));
    SubMenu.AppendMenu(MF_BYPOSITION | MF_STRING, IDD_DYNAMIC+2, _T("Item3-2"));
    SubMenu.AppendMenu(MF_BYPOSITION | MF_STRING, IDD_DYNAMIC+3, _T("Item3-3"));

    CMenu SubSubMenu;
    SubSubMenu.CreatePopupMenu();
    SubSubMenu.InsertMenu(0, MF_BYPOSITION | MF_POPUP, (UINT_PTR)SubMenu.m_hMenu, _T("Item3"));
    
    pUtilCtrls->AddMenuItem(&SubSubMenu, 0);


Posted By: ksc4703
Date Posted: 15 November 2016 at 12:37am
Hi, Smile

Thank you for your response. It works well.

Problem solved.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net