Print Page | Close Window

Manual Creation of Ribbon System 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=8213
Printed Date: 03 March 2025 at 4:34am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Manual Creation of Ribbon System Menu
Posted By: Jayonas
Subject: Manual Creation of Ribbon System Menu
Date 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!



Replies:
Posted By: Oleg
Date 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


Posted By: Jayonas
Date 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!



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