我正在编写一个利用功能区栏的MFC应用程序,并且我已经在功能区编辑器中设计了大部分内容。但是,对于我的一个视图,我需要以编程方式添加一些按钮,并且我想在它们之间添加一个分隔符。
然而,当我切换视图时,我希望能够以编程方式删除按钮和分隔符,但我不确定如何进行,到目前为止,我有类似于以下内容(伪代码)的东西:
void AddButtons( CMFCRibbonBar& wndRibbonBar )
{
// Get the relevant panel:
CMFCRibbonCategory* pCategory = wndRibbonBar.GetCategory( 0 );
CMFCRibbonPanel* pPanel = pCategory->GetPanel( 0 );
// Insert the two buttons and add a separator:
CMFCRibbonButton* pButton = new CMFCRibbonButton( ID_TESTBUTTON1, _T("Test1") );
pPanel->Insert( pButton, 0 );
pButton = new CMFCRibbonButton( ID_TESTBUTTON2, _T("Test2") );
pPanel->Insert( pButton, 1 );
pPanel->AddSeparator();
}
void RemoveButtons( CMFCRibbonBar& wndRibbonBar )
{
// Get the relevant panel:
CMFCRibbonCategory* pCategory = wndRibbonBar.GetCategory( 0 );
CMFCRibbonPanel* pPanel = pCategory->GetPanel( 0 );
// Remove the two buttons:
pPanel->Remove( 1, TRUE );
pPanel->Remove( 0, TRUE );
// ToDo: Delete the separator:
}有没有可以调用的函数来删除分隔符,或者我应该把它当作一个普通的Ribbon元素?
提前感谢!
发布于 2013-06-09 16:03:26
将分隔符视为普通的功能区元素,它只是从CMFCRibbonBaseElement类派生的另一个类(CMFCRibbonSeparator):
// Delete the separator:
pPanel->Remove( 2, TRUE );
// Remove the two buttons:
pPanel->Remove( 1, TRUE );
pPanel->Remove( 0, TRUE );https://stackoverflow.com/questions/16999658
复制相似问题