4

雪佛龙
TActionMainMenuBar 没有这个功能。
TActionToolBar 自动添加 Chevron,但是这个菜单有一些自定义命令。

如何将此功能添加到 TActionMainMenuBar 并隐藏 Chevron 菜单中的自定义命令?
或者也许模仿这个功能?

4

1 回答 1

0

TActionToolBar 的解决方案:

将 Vcl.ActnMenus 和 Vcl.ActnCtrls 复制到您的项目源文件夹。

现在修改 ActCtrls 中的过程 TCustomToolScrollBtn.DrawArrows

procedure TCustomToolScrollBtn.DrawArrows;
const
  ArrowDirection: array[TAlign] of TScrollDirection = (sdDown, sdUp,
    sdDown, sdDown, sdDown, sdDown, sdDown);
var
  P: TPoint;
  TempCanvas: TCanvas;
  LDetails: TThemedElementDetails;
  LColor: TColor;
begin
  case FDirection of
    sdUp,
    sdDown : P := Point(Width div 2 - FArrowSize, 3);
    sdRight,
    sdLeft : P := Point(Width div 2 - FArrowSize div 2, 3);
  end;
  TempCanvas := TCanvas.Create;
  TempCanvas.Handle := Canvas.Handle;
  try
    if TCustomActionToolBar(Parent).HiddenCount < 1 then
     begin
       self.Enabled:=false;
       exit;
     end else self.Enabled:=true;
   if TStyleManager.IsCustomStyleActive then
    begin
      if not Enabled then
        LDetails := StyleServices.GetElementDetails(ttbButtonDisabled)
      else
      if Self.FDown then
        LDetails := StyleServices.GetElementDetails(ttbButtonPressed)
      else
      if FMouseInControl then
        LDetails := StyleServices.GetElementDetails(ttbButtonHot)
      else
        LDetails := StyleServices.GetElementDetails(ttbButtonNormal);
      if not StyleServices.GetElementColor(LDetails, ecTextColor, LColor) then
        if Enabled then
          LColor := StyleServices.GetSystemColor(clBtnText)
        else
          LColor := StyleServices.GetSystemColor(clGrayText);
      TempCanvas.Pen.Color := LColor;
    end
    else
    if Enabled then
      TempCanvas.Pen.Color := ActionBar.ColorMap.FontColor
    else
      TempCanvas.Pen.Color := ActionBar.ColorMap.DisabledFontColor;
    if Parent is TCustomActionToolBar then
      if TCustomActionToolBar(Parent).HiddenCount > 0 then
          DrawChevron(TempCanvas, sdDown, Point(Width div 2 - FArrowSize, Height div 2 - FArrowSize), FArrowSize);
  finally
    TempCanvas.Handle := 0;
    TempCanvas.Free;
  end;
end;

并在 Vcl.ActnMenus 中更改过程 TCustomizeActionToolBar.DoAddCustomizeItems 只需注释代码:

    if Assigned(ActionBarItem) then
    begin
     {
      if AnActionClient.Items.Count > 0 then
        AddSeparator(AnActionClient.Items);
      FAddlItem := AnActionClient.Items.Add;
      FAddlItem.Caption := SAddRemoveButtons;
      AddItems(FAddlItem.Items, ActionBarItem.Items, ActionBarItem.Items.Count - 1);
      with TActionBarItem(RootMenu.ParentControl.ActionBar.ActionClient) do  AddItems(FAddlItem.Items, Items, Items.Count - 2);
      }
      if ActionBarItem.Items.Count > 0 then
      begin
       {
        FResetAction := TCustomAction.Create(Self);
        with FResetAction do
          Caption := SResetActionToolbar;
        if FAddlItem.Items.Count > 0 then
          AddSeparator(AnActionClient.Items);
        FResetItem := AnActionClient.Items.Add;
        with FResetItem do
        begin
          Action := FResetAction;
          UsageCount := -1;
        end;
        }
      end;
    end;
  end;

如果某些元素被隐藏,现在雪佛龙是可见的,并且在其菜单中没有用于自定义的工具。

于 2019-08-20T15:56:57.353 回答