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

Manual Creation of Ribbon System Menu

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


Joined: 28 September 2007
Location: United States
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jayonas Quote  Post ReplyReply Direct Link To This Post Topic: Manual Creation of Ribbon System Menu
    Posted: 28 September 2007 at 1:00pm
I'm trying to figure out how to create the ribbon-style system menu without converting it from a menu resource, as the ribbon samples do. I've figured out how to create the second column for displaying recent documents, by adding the xtpFlagWrapRow style to the first control in the second column.

However, what I can't figure out is how to get the buttons at the bottom of the menu (where the sample has an Options and Exit button). The SDI ribbon sample builds the system menu from the following resource:

Quote
    POPUP "&File"
    BEGIN
        MENUITEM "&New\tCtrl+N", ID_FILE_NEW
        MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN
        MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE
        MENUITEM "Save &As...", ID_FILE_SAVE_AS
        MENUITEM SEPARATOR
        MENUITEM "&Print", ID_FILE_PRINT
        MENUITEM "Pr&epare", ID_FILE_PREPARE
        MENUITEM "Sen&d", ID_FILE_SEND
        MENUITEM "P&ublish", ID_FILE_PREPARE
        MENUITEM SEPARATOR
        MENUITEM "Close", ID_APP_CLOSE
        MENUITEM SEPARATOR
        MENUITEM "Recent Documents", ID_FILE_RECENTDOCUMENTS
        , MENUBARBREAK
        MENUITEM "Opt&ions", ID_APP_OPTIONS
        MENUITEM "E&xit Sample", ID_APP_EXIT
    END


It looks like the ", MENUBARBREAK" entry is what results in the last two items being displayed as buttons below the others, but when I debugged through the menu parsing code, the MENUBARBREAK looks like it results in the xtpFlagWrapRow style being applied, which is actually how I figured out how to start the second column. When I try having two items with the xtpFlagWrapRow style, then I just end up with a three column menu, rather than two columns and buttons below.

I think this ultimately has something to do with some code somewhere being hard-coded to detect the Recent Document list in the menu. I need to work without any such hard-coding, because I don't think that MFC's built-in recent document handling can work with documents which aren't based on filenames (though I could be wrong there). That being the case, I'd also like to know which code is responsible for the "Recent Documents" label at the top of the second column in the sample apps. That doesn't look like a standard menu item.

Here's the code I'm using so far and the menu it generates:

Quote
Popup = m_Ribbon->AddSystemButton(IDS_Menu_System);
this->LoadImage(IDP_VLogo_32, IDP_VLogo_32, CSize(32,32));
Popup->SetIconId(IDP_VLogo_32);
Popup->GetCommandBar()->SetIconSize(CSize(32,32));
Control = Popup->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_NewResource);
Control = Popup->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_OpenResource);
Control = Popup->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_SaveResource);
Control = Popup->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_PrintResource);
Control->SetBeginGroup(TRUE);
Control = Popup->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_RecentDocuments);
Control->SetBeginGroup(TRUE);
Control->SetFlags(Control->GetFlags() | xtpFlagWrapRow);
Control = Popup->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_ShowOptions);
Control->SetFlags(Control->GetFlags() | xtpFlagWrapRow);
Control = Popup->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_ExitProgram);




Thanks!
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: 29 September 2007 at 1:59am
Hi,,
See OnCreateControl method in Sample
 
and this block:
 
if (lpCreateControl->nID == ID_APP_EXIT || lpCreateControl->nID == ID_APP_OPTIONS)
 {  
  lpCreateControl->pControl = new CXTPRibbonControlSystemPopupBarButton();
  return TRUE;
 }
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Jayonas View Drop Down
Newbie
Newbie


Joined: 28 September 2007
Location: United States
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jayonas Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2007 at 4:17pm
Thanks! That's exactly what I needed. :)

One more thought/question: it might be nice if the menus that appear on top of the recent document list automatically set their width to match (just like they already seem to automatically set their height).

Similarly, it would be nice if the height of the system menu took into account the heights of any menus that could appear on top of the recent document list. In my application, some of the sub-menus will probably be taller than the main system menu, meaning that by default they will hang off the bottom of the system menu (also covering up the Options and Exit buttons). I was able to work around this problem by including a button with no text and a set height at the end of the system menu, to act like a spacer. It'd be nice if that wasn't necessary, though.

Thanks again!
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.031 seconds.