Print Page | Close Window

Customization of dynamic Menu

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=955
Printed Date: 05 February 2025 at 1:05pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Customization of dynamic Menu
Posted By: yoavo
Subject: Customization of dynamic Menu
Date Posted: 19 July 2004 at 6:53am

Hi,

In my application I creates my menu dynamically and attach it to a CXTPMenuBar object. I want to see this menu in the customize dialog. How can I do that ? (I saw only an option to show a menu that is created by resources).

thanks, Yoav.




Replies:
Posted By: Oleg
Date Posted: 19 July 2004 at 8:52am

You also can create categories and items of customize dialog dynamically:

CXTPControls* CXTPCustomizeCommandsPage::InsertCategory(CString strCategory, int nIndex = -1);

CXTPControls::Add

 



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: yoavo
Date Posted: 19 July 2004 at 9:01am
But how do I expolre the CXTPMenuBar ? I did not find a way to recieve a CMenu out of the CXTPMenuBar. (how do I recieve from a CXTPMenuBar its categories ??? )


Posted By: Oleg
Date Posted: 19 July 2004 at 11:36am

pMenuBar->GetControls()->GetCount()

pMenuBar->GetControl(i)->GetCaption().



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: yoavo
Date Posted: 20 July 2004 at 11:18am

I still do not understand how do I get the commands of each category ?

This is my code for displaying the categories:

void CMainFrame::OnCustomize()
{
 CXTPCustomizeSheet cs(GetCommandBars());
 CXTPCustomizeOptionsPage pageOptions(&cs);
 cs.AddPage(&pageOptions);
 
 CXTPCustomizeCommandsPage* pCommands = cs.GetCommandsPage();
 CXTPMenuBar* pMenuBar = GetCommandBars()->GetMenuBar();

 CXTPControls* pMenuControls = pMenuBar->GetControls();
 int aCount = pMenuControls->GetCount();
 for (int i = 0 ; i < aCount ; ++i)
 {
  CXTPControl* pMenubarControl = pMenuControls->GetAt(i);
  CString aCaption = pMenubarControl->GetCaption();
  CXTPControls* pPageControls = pCommands->InsertCategory(aCaption);
...

what do I need do add inorder that the commands of each category will be displayed ?


 



Posted By: krulle
Date Posted: 29 October 2004 at 9:28am

My code fills the commands page even if you have dynamic menus, hope it will help. It could be a good idea to make a recursive version of my code if you need also need the submenus included in the list.

void CMainFrame::OnCustomize()
{
    // get a pointer to the command bars object.
    CXTPCommandBars* pCommandBars = GetCommandBars();
    if (pCommandBars == NULL)
        return;

    // instanciate the customize dialog
    CXTPCustomizeSheet dlg(pCommandBars);

    // add the options page to the customize dialog.
    CXTPCustomizeOptionsPage pageOptions(&dlg);
    dlg.AddPage(&pageOptions);

    // add the commands page to the customize dialog.
    CXTPCustomizeCommandsPage* pCommands = dlg.GetCommandsPage();
 
    // fill the page with menu controls
    CXTPControls* pMenuControls = GetCommandBars()->GetMenuBar()->GetControls();
    for(int i = 0; i < pMenuControls->GetCount(); i++)
    {
        CXTPControlPopup* pMenubarControl = DYNAMIC_DOWNCAST(CXTPControlPopup, pMenuControls->GetAt(i));
  
        if(pMenubarControl)
        {
             CString caption = pMenubarControl->GetCaption();
             caption.Replace("&", "");

             CXTPControls* pPageControls = pCommands->InsertCategory(caption);
             CXTPControls* pSourceControls = pMenubarControl->GetCommandBar()->GetControls();

             for(int j = 0; j < pSourceControls->GetCount(); j++)
             {
                 CXTPControl* tmp = pSourceControls->GetAt(j);
                 if(!(tmp->GetFlags() & xtpFlagNoMovable))
                     pPageControls->AddClone(tmp);
             }
        }
    }

    pCommands->InsertAllCommandsCategory();

    // display the customize dialog.
    dlg.DoModal();
}




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