[德尔福 XE5 Up2]
我正在尝试使用 TPopUp 继承和创建一个组件,遵循与 CalendarFlyout 的 Flyouts 演示中公开的相同想法。我不会使用日历,但我希望腾出空间,以便我可以放置我想要的任何其他 FMX 组件。
我使用新组件向导制作了组件并添加了一些控件:
unit PopupTest;
interface
uses
System.SysUtils, System.Classes, FMX.Types, FMX.Controls,
FMX.Layouts, FMX.StdCtrls;
type
TPopupTest = class(TPopup)
private
FPanel : TPanel;
FLayoutButton : TLayout;
FCloseButton : TButton;
FSaveButton : TButton;
FClientArea : TLayout;
protected
procedure OnClose(Sender: TObject);
procedure OnSave(Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TPopupTest]);
end;
{ TPopupTest }
constructor TPopupTest.Create(AOwner: TComponent);
begin
inherited;
FPanel := TPanel.Create(self);
FPanel.Position.X := 0;
FPanel.Position.Y := 0;
FPanel.Margins.Left := 10;
FPanel.Margins.Right := 10;
FPanel.Margins.Top := 10;
FPanel.Margins.Bottom := 10;
FPanel.StyleLookup := 'flyoutpanel';
FPanel.Align := TAlignLayout.alClient;
FPanel.Visible := True;
FLayoutButton := TLayout.Create(FPanel);
FLayoutButton.Align := TAlignLayout.alBottom;
FLayoutButton.Height := 22;
FCloseButton := TButton.Create(FLayoutButton);
FCloseButton.Align := TAlignLayout.alLeft;
FCloseButton.StyleLookup := 'flyoutbutton';
FCloseButton.Text := 'Fechar';
FCloseButton.OnClick := OnClose;
FSaveButton := TButton.Create(FLayoutButton);
FSaveButton.Align := TAlignLayout.alLeft;
FSaveButton.StyleLookup := 'flyoutbutton';
FSaveButton.Text := 'Salvar';
FSaveButton.OnClick := OnSave;
FClientArea := TLayout.Create(FPanel);
FClientArea.Align := TAlignLayout.alClient;
Width := 100;
Height := 100;
end;
destructor TPopupTest.Destroy;
begin
FClientArea.Free;
FCloseButton.Free;
FSaveButton.Free;
FLayoutButton.Free;
FPanel.Free;
inherited;
end;
procedure TPopupTest.OnClose(Sender: TObject);
begin
end;
procedure TPopupTest.OnSave(Sender: TObject);
begin
end;
end.
我已经进行了几次测试,但没有出现任何内容,只是弹出窗口本身,里面什么都没有。我正在使用 MetropoliUI 样式,内部控件的组件上的样式基于该样式。
为简单起见,我删除了所有其他内容并进行了编译和测试。
我使用 TPopUp 有几个原因,但主要原因是我的“对话框”将被插入到表单中,我将添加一些 TEdits,这些 TEdits 将通过 LiveBinding 连接到表单上的相同 DataSet 等。所以不需要用其他所有东西创建另一个表单,并保留所有上下文(至少我相信这是正确的做法)
我在找什么:
- 使所有内部控制出现的缺失
- 如何确保 FClientArea(即 TLayout)可供用户在其上添加其他控件?
最终结果是这样的:
中间区域是一个 TLayout,我可以在其中放置其他控件,例如 TEdit。