我想要创建一个“面板组件”来按住x按钮(实际上不是完全按钮,但您明白了)。关于创建“容器”组件的建议
它看起来像一个扫雷艇,你可以点击任何按钮,每个按钮都有相同的“全局点击”事件。但与发件人和按钮作为参数,如:Sender: TObject; Button: TButton
)wherin发件人是面板组件,并按钮面板内的按钮。
到目前为止,我把水平方向的按钮数量和垂直方向的按钮数量分为两个属性。
property ButtonsHeight: Integer read fButtonsHeight write SetButtonsHeight;
property ButtonsWidth: Integer read fButtonsWidth write SetButtonsWidth;
procedure TMultipleDrawPanel.SetButtonsHeight(const Value: Integer);
begin
if Value < 1 then begin
raise Exception.Create('Mumarul minim de butoane este 1!');
end;
InflateButtonsHeight(fButtonsHeight, Value);
fButtonsHeight := Value;
end;
而且这是在一个方向按钮的数量变化的伪代码:
procedure TMultipleDrawPanel.InflateButtonsHeight(oldValue, newValue: Integer);
begin
if oldValue < newValue then begin
// free extra buttons
end else begin
// create new buttons
end;
end;
任何人都可以点我一些建议吗?
- 如何存储按钮列表?
- 如何在数字从较高值变为较低值时释放按钮? (以及如何创建新的,否则?)
- 我相信我需要覆盖resize方法。我有一些想法,但我没有得到那么多。
通常这种事情作为单个组件而不是复合组件更好用 –
使用TGridPanel并将按钮放置在单元格内。 –
tgridpanel不是我所需要的。我在这里公开的“面板组件”只是冰山的顶部。 –