Reference object instance created using “with” in Delphi

后端 未结 9 1345
生来不讨喜
生来不讨喜 2020-12-03 18:17

is there a way to reference an object instance that is created using the \"with\" statement?

Example:

with TAnObject.Create do
begin
  DoSomething(in         


        
9条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 19:24

    for FMX, you should use GetObject example:

    with TLabel.Create(box1) do
    begin
        Font.Size := 34;
        Font.Style := [TFontStyle.fsBold];
        TextAlign := TTextAlign.taCenter;
        box1.AddObject(GetObject);
    end;;
    

提交回复
热议问题