Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Customization of dynamic Menu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Customization of dynamic Menu

 Post Reply Post Reply
Author
Message
yoavo View Drop Down
Senior Member
Senior Member


Joined: 29 February 2004
Location: Israel
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavo Quote  Post ReplyReply Direct Link To This Post Topic: Customization of dynamic Menu
    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.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
yoavo View Drop Down
Senior Member
Senior Member


Joined: 29 February 2004
Location: Israel
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavo Quote  Post ReplyReply Direct Link To This Post 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 ??? )
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 19 July 2004 at 11:36am

pMenuBar->GetControls()->GetCount()

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

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
yoavo View Drop Down
Senior Member
Senior Member


Joined: 29 February 2004
Location: Israel
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavo Quote  Post ReplyReply Direct Link To This Post 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 ?


 

Back to Top
krulle View Drop Down
Newbie
Newbie


Joined: 05 October 2004
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote krulle Quote  Post ReplyReply Direct Link To This Post 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();
}

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.172 seconds.