Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - [solved] how to add submenu?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[solved] how to add submenu?

 Post Reply Post Reply
Author
Message
ksc4703 View Drop Down
Newbie
Newbie


Joined: 04 November 2016
Location: south korea
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote ksc4703 Quote  Post ReplyReply Direct Link To This Post Topic: [solved] how to add submenu?
    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?

Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (1) Thanks(1)   Quote olebed Quote  Post ReplyReply Direct Link To This Post 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);
Back to Top
ksc4703 View Drop Down
Newbie
Newbie


Joined: 04 November 2016
Location: south korea
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote ksc4703 Quote  Post ReplyReply Direct Link To This Post Posted: 15 November 2016 at 12:37am
Hi, Smile

Thank you for your response. It works well.

Problem solved.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.195 seconds.