(转 )Delphi指针如何指向使用with开域语句创建的无名组件对象


procedure TForm1.Button1Click(Sender: TObject);
var
  P: Pointer;
begin
  P :
= nil;{洗得干干净净一尘不染}
 
with TButton.Create(Self) do begin
    asm
      mov P, eax
   
end;
    TButton(P).Caption :
= 'All Right!';
    Parent :
= Self;{以下是开域语句的常见用法了}
    Left :
= 100;
    Top :
= 100;
    Width :
= 100;
    Height :
= 30;
    Show;
 
end;
end;
原文地址:https://www.cnblogs.com/chengxin1982/p/1355854.html