create TAdvToolBarOfficeStyler at runtime probl.

Hello I have created a procedure to create and set some styler components:

procedure CreateAndSetRibbonStyler(const aForm: TForm);
var
  AdvToolBarOfficeStyler1: TAdvToolBarOfficeStyler;
  AdvPreviewMenuOfficeStyler1: TAdvPreviewMenuOfficeStyler;
  i: Integer;
begin
  AdvToolBarOfficeStyler1 := TAdvToolBarOfficeStyler.Create(aForm);
  AdvToolBarOfficeStyler1.Style := bsWindows8;
  AdvPreviewMenuOfficeStyler1 := TAdvPreviewMenuOfficeStyler.Create(aForm);
  AdvPreviewMenuOfficeStyler1.Style := psWindows8;

  for i := 0 to aForm.ComponentCount - 1 do
  begin
    if aForm.Components is TAdvToolBarPager then
      TAdvToolBarPager(aForm.Components).ToolBarStyler := AdvToolBarOfficeStyler1
    else if aForm.Components is TAdvPreviewMenu then
      TAdvPreviewMenu(aForm.Components).Styler := AdvPreviewMenuOfficeStyler1
  end;
end;

I add this code to the OnCreate event of the forms with ribbon controls. But the style is only half used. The background and the preview menu has windows 8 style. The buttons in the ribbon has the default style. Did I missing something? AdvToolBarPager1.Invalidate; does'nt help.

The form constructor is not a good place for this as the form window handle is not yet ready.
Try OnFormShow or on a datamodule that's loaded before the form.

Hello,


thanks. OnShow does'nt solve the problem. If I change the code to:

begin
  AdvToolBarOfficeStyler1 := TAdvToolBarOfficeStyler.Create(aForm);
  AdvPreviewMenuOfficeStyler1 := TAdvPreviewMenuOfficeStyler.Create(aForm);

  for i := 0 to aForm.ComponentCount - 1 do
  begin
    if aForm.Components is TAdvToolBarPager then
      TAdvToolBarPager(aForm.Components).ToolBarStyler := AdvToolBarOfficeStyler1
    else if aForm.Components is TAdvPreviewMenu then
      TAdvPreviewMenu(aForm.Components).Styler := AdvPreviewMenuOfficeStyler1
  end;

  AdvToolBarOfficeStyler1.Style := bsWindows8;
  AdvPreviewMenuOfficeStyler1.Style := psWindows8;
end;

then it works.