Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » RibbonBar Help Collapse All
Subject Author Date
FERNANDO GAMARRA Jul 1, 2008 - 7:02 AM

I need a simple sample over RibbonBar for starting to develop my application. I’ve got a lot of problems to present and handle my RibbonBar.


I’m sure that a simple sample I will get to develop a big RibbonBar.


Best regards,


 


 

FERNANDO GAMARRA Jul 9, 2008 - 6:59 AM

Hi,

I attached the code to generate a RibbonBar.

At the beggining it is only a node with 3 bottons, but why these three bottons are aligned horizontal? How can I make to aligne them vertical? What rules or methods can I use to control that kind of things, like position, size, etc.?

By other hand, when the application is execute, the RibbonBar appears with those three bottons, but the color is tenuous and greyish, as if they were inactive, what am I doing wrong?

And finally, by the moment, how the RibbonBar events are treated?



Thank you so much,



Fernando


 


 


void CMainFrame::rb_Init() // Inicializar la RibbonBar {     m_pRibbonNode = new CExtRibbonNode;     CExtRibbonNodeTabPageCollection * pRibbonNodeTabPageCollection = new CExtRibbonNodeTabPageCollection;     m_pRibbonNode->InsertNode(NULL, pRibbonNodeTabPageCollection);     pRibbonNodeTabPageCollection->InsertNode( NULL, rb_InitPage_Edition() );     pRibbonNodeTabPageCollection->PageSelectionSet(0);     m_wndRibbonBar.SetButtons(m_pRibbonNode);     VERIFY(m_wndRibbonBar.MenuInfoGetDefault()->AccelTableLoad(IDR_MAINFRAME)); } CExtRibbonNode* CMainFrame::rb_InitPage_Edition() // Inicializar un nodo-página {     CExtRibbonNodeTabPage * pRibbonNodeTabPage = new CExtRibbonNodeTabPage( 0L, NULL, _T("Edición") );     pRibbonNodeTabPage->CmdKeyTipSet( new CExtCustomizeCmdKeyTip( __EXT_MFC_SAFE_TCHAR( _T(’E’) ) ), false );     pRibbonNodeTabPage->InsertNode( NULL, rb_InitNode_Edition_Clipboard() );     //pRibbonNodeTabPage->InsertNode( NULL, rb_InitNode_Home_Dos() );     return pRibbonNodeTabPage; } CExtRibbonNode* CMainFrame::rb_InitNode_Edition_Clipboard() {     // Nuevo grupo Ribbon     CExtRibbonNodeGroup* pRibbonGroup = new CExtRibbonNodeToolGroup(ID_RIBBON_PAGE_EDITION);     // Preparar el grupo     // Primero el nodo raíz     pRibbonGroup->CmdKeyTipSet(new CExtCustomizeCmdKeyTip(__EXT_MFC_SAFE_LPCTSTR(_T("ZP"))), false);     //pRibbonGroup->RibbonILE_RuleArrayGet().RemoveAll();     bool bRes = pRibbonGroup->m_iconBig.m_bmpNormal.LoadBMP_Resource(MAKEINTRESOURCE(ID_INSERT_PICTURE_FROM_FILE_LARGE));     bRes = pRibbonGroup->m_iconBig.m_bmpNormal.Make32();     pRibbonGroup->m_iconBig.m_bmpNormal.AlphaColor(RGB(255, 0, 255), RGB(0, 0, 0), 0);     bRes = pRibbonGroup->m_iconSmall.m_bmpNormal.LoadBMP_Resource(MAKEINTRESOURCE(ID_INSERT_PICTURE_FROM_FILE_SMALL));     bRes = pRibbonGroup->m_iconSmall.m_bmpNormal.Make32();     pRibbonGroup->m_iconSmall.m_bmpNormal.AlphaColor(RGB(255, 0, 255), RGB(0, 0, 0), 0);     pRibbonGroup->SetTextInToolbar(_T("Portapapeles"));     // Ahora cada una de las opciones     CExtRibbonNode* pNodePaste = new CExtRibbonNode(ID_EDIT_CLEAR_SMALL, 0, NULL, 0, _T("Pegar\ndatos"));     pNodePaste->CmdKeyTipSet(new CExtCustomizeCmdKeyTip(__EXT_MFC_SAFE_TCHAR(_T("P"))), false);     //pNodePaste->RibbonILE_RuleRemoveSmallILV();     pNodePaste->RibbonILE_RuleArrayGet().RemoveAll();     pNodePaste->RibbonILE_RuleArrayGet().Add(__EXT_RIBBON_MAKE_RULE_ARRAY_ENTRY(__EXT_RIBBON_ILE_MAX, __EXT_RIBBON_ILV_SIMPLE_NORMAL, false));     pNodePaste->m_iconSmall.m_bmpNormal.LoadBMP_Resource(MAKEINTRESOURCE(ID_INSERT_PICTURE_FROM_FILE_SMALL));     bRes = pNodePaste->m_iconSmall.m_bmpNormal.Make32();     pNodePaste->m_iconSmall.m_bmpNormal.AlphaColor(RGB(255, 0, 255), RGB(0, 0, 0), 0);     pRibbonGroup->InsertNode(NULL, pNodePaste);     CExtRibbonNode* pNodeCut = new CExtRibbonNode(ID_EDIT_CUT_SMALL, 0, NULL, 0, _T("Cortar\ndatos"));     pNodeCut->CmdKeyTipSet(new CExtCustomizeCmdKeyTip(__EXT_MFC_SAFE_TCHAR(_T("C"))), false);     //pNodeCut->RibbonILE_RuleRemoveSmallILV();     pNodeCut->RibbonILE_RuleArrayGet().RemoveAll();     pNodeCut->RibbonILE_RuleArrayGet().Add(__EXT_RIBBON_MAKE_RULE_ARRAY_ENTRY(__EXT_RIBBON_ILE_MAX, __EXT_RIBBON_ILV_SIMPLE_NORMAL, false));     pNodeCut->m_iconBig.m_bmpNormal.LoadBMP_Resource(MAKEINTRESOURCE(ID_INSERT_SHAPES_LARGE));     bRes = pNodeCut->m_iconBig.m_bmpNormal.Make32();     pNodeCut->m_iconBig.m_bmpNormal.AlphaColor(RGB(255, 0, 255), RGB(0, 0, 0), 0);     pNodeCut->m_iconSmall.m_bmpNormal.LoadBMP_Resource(MAKEINTRESOURCE(ID_INSERT_SHAPES_SMALL));     bRes = pNodeCut->m_iconSmall.m_bmpNormal.Make32();     pNodeCut->m_iconSmall.m_bmpNormal.AlphaColor(RGB(255, 0, 255), RGB(0, 0, 0), 0);     pRibbonGroup->InsertNode(NULL, pNodeCut);     CExtRibbonNode* pNodeCopy = new CExtRibbonNode(ID_EDIT_COPY_SMALL, 0, NULL, 0, _T("Copiar\ndatos"));     pNodeCopy->CmdKeyTipSet(new CExtCustomizeCmdKeyTip(__EXT_MFC_SAFE_TCHAR(_T("O"))), false);     //pNodeCopy->RibbonILE_RuleRemoveSmallILV();     pNodeCopy->RibbonILE_RuleArrayGet().RemoveAll();     pNodeCopy->RibbonILE_RuleArrayGet().Add(__EXT_RIBBON_MAKE_RULE_ARRAY_ENTRY(__EXT_RIBBON_ILE_MAX, __EXT_RIBBON_ILV_SIMPLE_NORMAL, false));     pNodeCopy->m_iconBig.m_bmpNormal.LoadBMP_Resource(MAKEINTRESOURCE(ID_INSERT_QUICK_PARTS_LARGE));     bRes = pNodeCopy->m_iconBig.m_bmpNormal.Make32();     pNodeCopy->m_iconBig.m_bmpNormal.AlphaColor(RGB(255, 0, 255), RGB(0, 0, 0), 0);     pNodeCopy->m_iconSmall.m_bmpNormal.LoadBMP_Resource(MAKEINTRESOURCE(ID_INSERT_QUICK_PARTS_SMALL));     bRes = pNodeCopy->m_iconSmall.m_bmpNormal.Make32();     pNodeCopy->m_iconSmall.m_bmpNormal.AlphaColor(RGB(255, 0, 255), RGB(0, 0, 0), 0);     pRibbonGroup->InsertNode(NULL, pNodeCopy);     return pRibbonGroup; }

Technical Support Jul 9, 2008 - 12:44 PM

Please take a closer look at initialization code of all the ribbon nodes in the CMainFrame::rb_InitNode_Edition_Clipboard() method. It contains the following lines for each of ribbon nodes:

     pNodeXXX->RibbonILE_RuleArrayGet().RemoveAll();
     pNodeXXX->RibbonILE_RuleArrayGet().Add(__EXT_RIBBON_MAKE_RULE_ARRAY_ENTRY(__EXT_RIBBON_ILE_MAX, __EXT_RIBBON_ILV_SIMPLE_NORMAL, false));
The first line removes all behavior rules. The second line makes the ribbon button initially and always having a normal middle size state. You have simply killed the default behavior rules and didn’t specify new rules instead. In most cases you can simply get initialization code of ribbon groups from Prof-UIS sample applications and use these code snippets "as is" but with your icon resources and texts.



Technical Support Jul 2, 2008 - 5:59 AM

Could you tell us what the main difficulties are? We have a lot of real-life cases when customers converted the RibbonBar sample into their projects by renaming this sample, changing icons and command identifiers and removing everything that is not needed. All the ribbon-bar specific events are completely handled in the virtual methods in the CExtRibbonBar-derived class. Please note, the CExtRibbonBar control is a very extended version of the CExtToolControlBar toolbar control. You should handle the events of push buttons using the classic MFC way: by adding command and updating methods.