删除一个编程添加的面板分隔符在MFC Ribbon Bar
Removing a programmatically added panel separator in MFC Ribbon Bar
我正在编写一个利用功能区栏的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元素?
提前感谢!
将分隔符视为普通的Ribbon元素,它只是从CMFCRibbonBaseElement
类派生的另一个类(CMFCRibbonSeparator
):
// Delete the separator:
pPanel->Remove( 2, TRUE );
// Remove the two buttons:
pPanel->Remove( 1, TRUE );
pPanel->Remove( 0, TRUE );
相关文章:
- C++ MFC Libraries in Travis CI
- 当用户键入分隔符时,停止getline()输入
- 为什么在逗号分隔符上下文中将预增量的结果强制转换为void
- 如何在 c++ 中使用 ',' 作为 getline 分隔符
- 带有多个字符分隔符的正则表达式
- 从 bmp 文件数据创建 MFC CBitmap
- 如何在 MFC 中显示文件的所有行
- 使用 char 分隔符解析C++中的字符串,但将可重复的字符保留为每个解析的子字符串 (C++ STL) 中的分隔符
- 字符串开头的分隔符
- 目录删除 MFC 的问题
- 尝试将 c 字符串数组与分隔符连接起来
- MFC:如何设置CEdit框的焦点?
- 正则表达式以匹配数字的重复模式,后跟任何类型的分隔符?
- MFC 中的抗锯齿
- 双击更改 mfc 中列表控件中的行的颜色
- C++MFC编辑框处理双击
- 根据新的行分隔符从字符串中删除子字符串
- C++ MFC CObject 派生类摘要?
- 删除一个编程添加的面板分隔符在MFC Ribbon Bar
- 如何在MFC对话框中创建虚线分隔符?