gpt4 book ai didi

delphi - 在 FireMonkey 中更改 TMemo 的字体和背景颜色

转载 作者:行者123 更新时间:2023-12-03 14:48:21 29 4
gpt4 key购买 nike

我正在编写一个备忘录组件,它需要看起来像老式的终端 session 。这应该非常简单,但 FireMonkey 样式的工作方式似乎使其复杂得令人难以置信。

在非移动 FireMonkey 应用程序中,我可以右键单击控件并选择“编辑自定义样式”。此选项在移动应用程序中不可用。以下是一位 FireMonkey 开发人员给出的原因。

It is support different style on iOS and Android. We cannot run application on Android in iOS style. But when you try to change platform style, automatically we will use it on each target platform. If you want to change default style of fm control, you should put on the form style book and make style in it, or load to stylebook platform style and make changes in it.

Also very important, When you load platform style in style book, You can want that application instance will not have two copy of platform style (one - system in fmx package and other copy in your style book). For it you should to set flag true in TStylebook.UseStyleManager. In this case style in Style book will replace platform style.

好的,所以我认为我需要创建一个自定义样式。如何创建自定义样式以仅覆盖字体和背景属性?

我想我可以像这样重写ApplyStyle 过程。

procedure TMyMemo.ApplyStyle;
var
BackgroundObject: TFmxObject;
begin
inherited;

BackgroundObject := FindStyleResource('content');

if Assigned(BackgroundObject) then
begin
// Change the background color of the background
end;
end;

我如何知道背景对象是什么类型以及我需要更改哪个属性?

当然,更改控件的背景颜色不会这么困难!我是否遗漏了 FM 风格的一些基本内容?

最佳答案

希望您发现此解决方法有用

uses System.UIConsts;


procedure TfPlanJob.mDetailApplyStyleLookup(Sender: TObject);
var Obj: TFmxObject;
Rectangle1: TRectangle;
begin
Obj := mDetail.FindStyleResource('background');
if Obj <> nil then
begin
TControl(Obj).Margins := TBounds.Create(TRectF.Create(-1, -1, -1, -1));
Rectangle1 := TRectangle.Create(Obj);
Obj.AddObject(Rectangle1);
Rectangle1.Align := TAlignLayout.Client;
Rectangle1.Fill.Color := claLightslategrey;
Rectangle1.Stroke.Color := claNull;
Rectangle1.HitTest := False;
Rectangle1.SendToBack;
end;
end;

关于delphi - 在 FireMonkey 中更改 TMemo 的字体和背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19024083/

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