控件的强行转换时发生的错误

动态生成控件,应该是这么写(当场创建):

    with TLabel.Create(PanelCheque) do
    begin
        Parent:=PanelCheque;
        Name:='Bank'+CurNumber;
        Left:=270;
        Top:=CurTop;
        Height:=24;
        Width:=90;
        Text:='';
    end;

却一不小心写成了(少了一个Create):

    with TLabel(PanelCheque) do
    begin
        Parent:=PanelCheque;
        Name:='numero'+CurNumber;
        Left:=450;
        Top:=CurTop;
        Height:=24;
        Width:=160;
        Text:='';
    end;

结果报错:A control cannot have itself as its parent

有空研究一下,这个报错信息在哪里。另外我就是很感兴趣,在编译器层面是如何做到“强行转换”的?仅仅切换内存的大小?留个爪以后研究。

posted @ 2015-07-26 00:00  findumars  Views(239)  Comments(0)    收藏  举报