gpt4 book ai didi

delphi - 如果某些菜单项不水平放置,如何将 V 形(双箭头)添加到 TActionMainMenuBar

转载 作者:行者123 更新时间:2023-12-03 15:36:30 26 4
gpt4 key购买 nike

chevron
TActionMainMenuBar没有此功能。
TActionToolBar 会自动添加 Chevron,但此菜单有一些自定义命令。

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

最佳答案

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;

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

    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;

现在,如果隐藏某些元素,Chevron 就会可见,并且其菜单中没有用于自定义的工具。

关于delphi - 如果某些菜单项不水平放置,如何将 V 形(双箭头)添加到 TActionMainMenuBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15003473/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com