官方QQ:  16643506

如何在运行时动态创建一个TdxRibbon

设计期效果如下:




运行后效果如下:





代码如下:

 unit Unit3;

interface

uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, 
   dxBar, dxRibbon, dxRibbonForm, dxRibbonSkins, cxGraphics, cxControls, cxLookAndFeels,
   cxLookAndFeelPainters, cxClasses, dxRibbonBackstageView, cxBarEditItem;

type
   TForm3 = class(TdxRibbonForm)
    procedure FormCreate(Sender: TObject);
   private
    { Private declarations }
   public
    { Public declarations }
   end;

var
   Form3: TForm3;

implementation

{$R *.dfm}

{ TForm3 }

procedure TForm3.FormCreate(Sender: TObject);
var
   AManager: TdxBarManager;
   ARibbon: TdxRibbon;
   ATab: TdxRibbonTab;
   AGroup: TdxRibbonTabGroup;
   ABar: TdxBar;
   AButton: TdxBarLargeButton;
   ARibbonBackstageView: TdxRibbonBackstageView;
begin
   DisableAero := True;

   AManager := TdxBarManager.Create(Self);
   ARibbon := TdxRibbon.Create(Self);
   ARibbon.Parent := Self;
   ARibbon.BarManager := AManager;
   ARibbon.Style := rs2019;
   ARibbon.SupportNonClientDrawing := True;
   ATab := ARibbon.Tabs.Add;
   ATab.Caption := 'MyTab';
   AGroup := ATab.Groups.Add;
   AGroup.Caption := 'MyGroup';
   ABar := AManager.AddToolBar();
   ABar.Caption := 'MyBar';
   AGroup.ToolBar := ABar;
   AButton := ABar.ItemLinks.AddItem(TdxBarLargeButton).Item as TdxBarLargeButton;
   AButton.Caption := 'MyButton';
   ABar := AManager.AddToolBar();
   ABar.Caption := 'QuickAccessToolbar';
   AButton := ABar.ItemLinks.AddItem(TdxBarLargeButton).Item as TdxBarLargeButton;
   AButton.Caption := 'MyQuickButton';
   ARibbon.QuickAccessToolbar.Toolbar := ABar;

   ARibbonBackstageView := TdxRibbonBackstageView.Create(Self);
   ARibbonBackstageView.Parent := Self;
   ARibbonBackstageView.Ribbon := ARibbon;
   ARibbonBackstageView.AddTab.Caption := 'MyBackstageTab';
   ARibbon.ApplicationButton.Menu := ARibbonBackstageView;
end;

end.





联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678