BCGControlBar中文教程之Ribbon Backstage视图(三)

为了在应用程序中启用Backstage视图,您可以执行以下步骤。以下的指南假设Ribbon控件被定义为m_wndRibbonBar,应用程序按钮上显示的文本是"File",命令图片以图片列表的形式展示,视图项拥有一个资源ID IDB_FILESMALL。下面提到的图像索引假设您已经获得下面的图像列表:

Ribbon Backstage视图

11. 在资源编辑器汇总新增一个具有IDD_FORM_RECENTFILES ID的新的对话框资源。

12. 打开对话框的属性,并设置Style - Child、Border - None、Clip siblings - checked、Clip children - checked。

13. 将3个控件放置在该对话框中——静态文本"Recent Files"、集中在对话框客户端区域的列表框和它们之间的分隔符。IDC_RECENT_FILES ID分配给列表框、IDC_INFO_LABEL1分配给静态文本、IDC_SEPARATOR_1分配给分隔符:

Ribbon Backstage视图

14. 从CBCGPDialog中派生出一个类,然后命名为CBackStagePageRecentFiles。

15. 按照如下使用CBCGPRecentFilesListBox来替代标准的列表框:

  • 定义对话框成员CBC PRecentFilesListBox m_wndRecentFiles;
  • 在CBackStagePageRecentFiles:: DoDataExchange中添加DDX_CONTROL宏:DDX_Control(pDX, IDC_RECENT_FILES, m_wndRecentFiles);

16. 当父Backstage视图调整大小时使用自动调整功能使对话框上的所有空间自动对齐。为此将下面的代码添加到OnInitDialog中:

1
2
3
4
5
CBCGPStaticLayout* pLayout = (CBCGPStaticLayout*)GetLayout();
 
pLayout->AddAnchor(IDC_INFO_LABEL1, CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeHorz);
pLayout->AddAnchor(IDC_SEPARATOR_1, CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeHorz);
pLayout->AddAnchor(IDC_RECENT_FILES, CBCGPStaticLayout::e_MoveTypeNone, CBCGPStaticLayout::e_SizeTypeBoth);

此代码意味着静态文本空间不动,只是水平调整;分隔符空间不动,只是水平调整;列表控件不动,垂直和水平调整。

17. 现在我们回到初始代码,并添加一个全新的视图条目命名为"Recent":

1
2
3
CBCGPRibbonBackstageViewItemForm* pFormRecent =  new CBCGPRibbonBackstageViewItemForm (IDD_FORM_RECENTFILES, RUNTIME_CLASS(CBackStagePageRecentFiles));
 
pBackstagePanel->AddView (0, _T( "Recent" ), pFormRecent);

18. 可能会在激活视图(激活的对话框)右下角显示一个水印图像。为此添加一个新的位图资源,并为其分配ID IDB_BS_WATERMARK。现在您可以通过调用SetWaterMarkImage为每个CBCGPRibbonBackstageViewItemForm或CBCGPRibbonBackstageViewItemPropertySheet对象设置水印图像。

19. 设置添加水印图像到"Recent"视图中:

1
pFormRecent->SetWaterMarkImage(IDB_BS_WATERMARK, RGB(0, 0, 192));

最后一个参数可以是相应于我们在步骤3设置的应用程序按钮颜色。

20. 添加最后一个命令"Exit":

pBackstagePanel->AddCommand (ID_APP_EXIT, _T("Exit"), 5 /* Image index */);

21. 现在,您可以编译并运行应用程序,同时可以在Backstage视图的右边查看6项条目:Save、Save As、Open、Close、Recent、Exit,其中有5个条目是命令,1个是视图("Recent")。当您单击命令时,Back Stage视图被关闭并执行单击的命令。当您选择一个视图条目 ("Recent")时,与MRU文件列表相对应的对话框将会显示在Backstage视图的右侧:

Ribbon Backstage视图

有兴趣的朋友可以击查看更多BCG资源>>

================================== ==注意:一共2个压缩包,这是第1个== ================================== *提示:无自动安装程序,包含所有源码、例子、帮助,请按照安装顺序安装!!! New Features in 13.1.4 (VCL Product Line) Breaking Changes To learn about breaking changes in this version, please refer to the following page: Breaking Changes in 13.1.4 (VCL Product Line) Known Issues To learn about known issues in this version, please refer to the following page: Known Issues in 13.1.4 (VCL Product Line) The following sections list all minor and major changes in DevExpress VCL 13.1.4. Note that products, controls and libraries which aren't mentioned in the list below are included in the unified installer for compatibility, but have not been updated. Enhancements and Updates New Features/Updates VCL Subscription ExpressTile Control ExpressDataController Resolved Issues ExpressBars Suite ExpressLayout Control ExpressNavBar ExpressPageControl ExpressPivotGrid Suite ExpressPrinting System ExpressQuantumGrid Suite ExpressQuantumTreeList Suite ExpressScheduler Suite ExpressSkins Library ExpressSpreadSheet ExpressTile Control ExpressVerticalGrid Suite ExpressDataController ExpressEditors Library ExpressLibrary Installation (VCL) New Features/Updates VCL Subscription S170932 - Documentation - Describe that the ExpressLayout Control and ExpressDocking Library are incompatible ExpressTile Control S172299 - Center the Back button and title text vertically within the title Common Libraries ExpressDataController S172107 - Add the capability to disable multi-threaded operations at the level of custom data sources (TcxCustomDataSource descendants) Resolved Issues ExpressBars Suite Q476901 - Documentation - The "Ribbon Application Menu" topic does not contain the menu creation steps that are specific to TdxRibbonBackstageView Q452658 - Documentation - The TdxCustomRibbonGalleryItem.GalleryGroups property is not marked as deprecated and is used in topics instead of TdxCustomRibbonGalleryItem.GalleryCategories Q513198 -
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值