- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个 FMX 组件,它是一个按钮数组。它有一个简单的列和行计数属性。数组中的每个按钮本身都是一个组件,当行数或列数发生更改时,我删除所有按钮并重新创建所需的数量。
我遇到的问题是,删除组件后,它们继续在屏幕上出现重影。例如,默认的列数和行数为 10,但对于手机格式,我在设计时将其更改为 5 x 5。这是结果...
我确信这与“存储”属性有关,但是我确信我已经尝试在按钮和数组上打开和关闭它,没有任何区别。组件的源代码(尝试删除多余的代码):
type
TLFArrayButton = class(TStyledControl)
TLFButtonArray = class(TPanel)
private
{ Private declarations }
FButtons: Array[0..9, 0..9] of TLFArrayButton;
Sections: Array[0..3] of TRectangle;
SectionsText: Array[0..3] of TText;
FRowCount: integer;
FColCount: integer;
FFourUp: boolean;
FOnArrayButtonClick: TLFButtonArrayButtonClick;
procedure SetColCount(const Value: integer);
procedure SetRowCount(const Value: integer);
procedure CheckButtonArraySize;
procedure PositionButtons;
procedure FreeButtons;
function GetButtonsText(Col, Row: Integer): String;
procedure SetButtonsText(Col, Row: Integer; const Value: String);
function GetButtonEnabled(Col, Row: Integer): Boolean;
procedure SetButtonEnabled(Col, Row: Integer; const Value: Boolean);
procedure SetFourUp(const Value: boolean);
procedure OnButtonClick(Sender: TObject);
procedure OnButtonMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
procedure SetupSectionHeadders;
function GetButton(id: integer): TLFArrayButton;
function GetSectionHeadding(idx: integer): string;
procedure SetSectionHeadding(idx: integer; const Value: string);
procedure SetOnArrayButtonClick(const Value: TLFButtonArrayButtonClick);
protected
{ Protected declarations }
function GetStyleObject: TFmxObject; override;
procedure Resize; override;
procedure ApplyTriggers; virtual;
procedure DoButtonClick(id: integer); virtual;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Button[id: integer]: TLFArrayButton read GetButton;
property ButtonEnabled[Col, Row: Integer]: Boolean read GetButtonEnabled write SetButtonEnabled;
property ButtonsText[Col, Row: Integer]: String read GetButtonsText write SetButtonsText;
property SectionHeadding[idx: integer]: string read GetSectionHeadding write SetSectionHeadding;
published
{ Published declarations }
property FourUp: boolean read FFourUp write SetFourUp stored true default false;
property ColCount: integer read FColCount write SetColCount stored true default 10;
property RowCount: integer read FRowCount write SetRowCount stored true default 10;
property OnArrayButtonClick: TLFButtonArrayButtonClick read FOnArrayButtonClick write SetOnArrayButtonClick;
end;
procedure Register;
implementation
{$R *.res}
procedure Register;
begin
RegisterComponents('LightFactoryFMX', [TLFButtonArray]);
RegisterComponents('LightFactoryFMX', [TLFArrayButton]);
end;
{ TLFButtonArray }
procedure TLFButtonArray.CheckButtonArraySize;
var
r, c, i: Integer;
begin
FreeButtons;
InvalidateRect(RectF(0,0,width,height));
i := 1;
for r := 0 to FRowCount-1 do
begin
for c := 0 to FColCount-1 do
begin
FButtons[r,c] := TLFArrayButton.Create(Self);
FButtons[r,c].Parent := Self;
FButtons[r,c].Stored := false;
FButtons[r,c].Locked := true;
FButtons[r,c].ShowID := true;
FButtons[r,c].ID := i;
FButtons[r,c].OnClick := OnButtonClick;
inc(i);
end;
end;
end;
constructor TLFButtonArray.Create(AOwner: TComponent);
begin
inherited;
Stored := false;
StyleLookup := 'panelstyle';
FFourUp := false;
FColCount := 10;
FRowCount := 10;
CheckButtonArraySize;
PositionButtons;
end;
procedure TLFButtonArray.FreeButtons;
var
r, c: Integer;
begin
for r := 0 to FRowCount-1 do
begin
for c := 0 to FColCount-1 do
begin
if assigned(FButtons[r, c]) then
begin
FButtons[r, c].Free;
FButtons[r, c] := NIL;
end;
end;
end;
end;
procedure TLFButtonArray.PositionButtons;
var
r, c, s, b, loc_col, loc_row, num_per_sec: Integer;
x, y, dw, dh: single;
tmpBtn: TLFArrayButton;
begin
if FFourUp then
begin
loc_col := ColCount div 2;
loc_row := RowCount div 2;
num_per_sec := loc_col * loc_row;
//
dw := (Width - INTER_SECTION_SPACING - ((FColCount+1) * BUTTON_SPACING)) / FColCount;
dh := (Height - INTER_SECTION_SPACING - (Sections[0].Height * 2) - ((FRowCount+1) * BUTTON_SPACING)) / FRowCount;
x := BUTTON_SPACING;
y := BUTTON_SPACING;
for s := 0 to 3 do
begin
x := Sections[s].Position.X;
y := Sections[s].Position.Y + Sections[s].Height + BUTTON_SPACING;
for b := 1 to num_per_sec do
begin
tmpBtn := GetButton((s*num_per_sec) + b);
if assigned(tmpBtn) then
begin
tmpBtn.Position.X := x;
tmpBtn.Position.Y := y;
tmpBtn.Width := dw;
tmpBtn.Height := dh;
x := x + dw + BUTTON_SPACING;
if x > (Sections[s].Position.X + Sections[s].Width) then
begin
x := Sections[s].Position.X;
y := y + dh + BUTTON_SPACING;
end;
end;
end;
end;
end
else
begin
dw := (Width - ((FColCount+1) * BUTTON_SPACING)) / FColCount;
dh := (Height - ((FRowCount+1) * BUTTON_SPACING)) / FRowCount;
x := BUTTON_SPACING;
y := BUTTON_SPACING;
for r := 0 to FRowCount-1 do
begin
for c := 0 to FColCount-1 do
begin
FButtons[r,c].Position.X := x;
FButtons[r,c].Position.Y := y;
FButtons[r,c].Width := dw;
FButtons[r,c].Height := dh;
x := x + dw + BUTTON_SPACING;
end;
x := BUTTON_SPACING;
y := y + dh + BUTTON_SPACING;
end;
end;
end;
procedure TLFButtonArray.Resize;
begin
inherited;
if FourUp then
SetupSectionHeadders;
PositionButtons;
end;
destructor TLFButtonArray.Destroy;
begin
FreeButtons;
inherited;
end;
procedure TLFButtonArray.SetColCount(const Value: integer);
begin
if FColCount <> Value then
begin
if (Value > 0) and (Value < 11) then
begin
FColCount := Value;
CheckButtonArraySize;
PositionButtons;
end;
end;
end;
procedure TLFButtonArray.SetRowCount(const Value: integer);
begin
if FRowCount <> Value then
begin
if (Value > 0) and (Value < 11) then
begin
FRowCount := Value;
CheckButtonArraySize;
PositionButtons;
end;
end;
end;
最佳答案
由于 iOS/Android 版 Delphi 中的 ARC(自动引用计数),表单仍然引用按钮。因此 FButtons[r, c].Free;
应该是 FButtons[r, c].DisposeOf;
。
关于Delphi FMX 组件重影删除子组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25519207/
我创建了一个 FMX 组件,它是一个按钮数组。它有一个简单的列和行计数属性。数组中的每个按钮本身都是一个组件,当行数或列数发生更改时,我删除所有按钮并重新创建所需的数量。 我遇到的问题是,删除组件后,
是否可以在 Delphi FMX 中使用鼠标调整无边框窗体的大小?我尝试使用 OnMouseDown 和 OnMouseMove ,然后使用表单的位置与表单的左侧和顶部进行比较,但我无法使其工作。 出
我有一个带有 CheckColumn 的网格,该网格通过实时绑定(bind)与查询连接。当我打开查询时,所有数据都加载到网格中,但复选框不显示。如果我单击网格,则会出现复选框。 我打开查询时的图片:
我正在尝试构建一个看似简单的 GUI,其中可以平移、缩放和旋转 Timage。缩放和旋转应在/围绕定义的缩放和旋转中心位置进行。 我首先在 Windows 上尝试这个。现在一切正常,除了当图像旋转时,
我想知道如何反编译 fmx 文件以便在没有源代码的情况下对应用程序进行一些更改,我们只有 .fmx (Oracle 9i) 文件并且确实需要源代码。 最佳答案 实际上没有用于反编译 FMX 的工具。您
我有简单的 fmx 表单(Delphi 10.2 Tokyo): 在代码中,我将 Button2 显示为第二个: procedure TForm6.FormCreate(Sender: TObject
我在使用 FMX(XE3、Windows)设置托盘图标时遇到问题。我使用的代码可以在无数线程中找到,但我没有获得图标工作的消息处理。 为了说明这一点,我创建了一个测试应用程序,它在 FormCreat
我正在 firemonkey 中使用 DirectShow,但在输出视频时遇到问题。 iVideoWindow.Put_Owner(Panel1.Handle); 我需要 TPanel 的句柄,以在其
所以我一直在基于两个不同的源代码开发这个 TrayIcon 组件。 一款适用于 Windows,一款适用于 Mac。 一切工作正常,除了当使用 FMX TPopupMenu 作为托盘图标菜单时,它不断
假设我在 Firemonkey 中有一个小位图(比如 32x24 像素)。因此,我将 TImage 放入表单中,并在构造函数中包含以下代码: Image1.Bitmap.Create(32, 24
使用样书时,如果按钮已禁用,则颜色很难说明该按钮已禁用。因此,我想在按钮禁用时更改颜色。我怎么做。我正在使用德尔福西雅图 最佳答案 这并不像更改样式书中的正常颜色那么简单。禁用的外观是通过降低控件的不
我创建了一个测试新的 FMX 项目。向其中添加了一个 TabControl。使用上下文菜单添加 3 个选项卡。向第三个选项卡添加一个 TEdit。向选项卡控件添加了 OnChangeEvent 处理程
在 VCL 中,这是我如何从两个图像制作单个图像,同时在它们之间创建空间: procedure TForm2.Button1Click(Sender: TObject); var p1,p2:str
我有一个包含 2 RadioButtons(具有相同 GroupName)的表单,我需要保存 'A'(如果选择了 RadioButton1)或 'I' (如果选择了 RadioButton2)在状态字
我通过 TCameraComponent.SampleBufferReady 事件收到位图。然后我需要裁剪接收到的图像,以便获得例如矩形图像。 我用以下方法计算了必要的参数: procedure TP
我在 Delphi 10.1 的多设备应用程序(在 Windows 上)中遇到问题。我有一个 StringGrid (连接到数据库),我可以更改行的背景颜色,但问题是单元格之间有“填充”(灰色/银色)
有一些关于将 FMX 表单嵌入面板的代码... http://docwiki.embarcadero.com/CodeExamples/XE5/en/FMXEmbeddedForm_(Delphi)
通常在使用 TDataset 后代作为数据存储(例如 TClientDataset)的 Delphi VCL 应用程序中,在 Dataset1BeforeDelete 处理程序中,我们执行如下操作:
我目前正在使用 Delphi 10 Seattle 开发 Android 应用程序。我拥有一个 Galaxy Tab E (SM-T560) 和一个 Samsung Galaxy S3 Mini 来测
大家下午好! 我目前的一个项目遇到了一个相当烦人的问题。我正在我当前的一个项目中使用硬件库(Andreas Hausladen 的 NVAPI Pascal header 翻译)。这个库允许我从 NV
我是一名优秀的程序员,十分优秀!