با سلام . تشکر
مشکل حل شد.
مورد این بود که بلافاصله بعد از ساخت لیبل ، دستور معرفی Parent رو میدادم. بعد از کلی کار با کشیدن این دستور به آخر ، مشکل برطرف شد .
این هم نمونه کد مورد استفاده من :
قرمز موقعیت دستور که موجب بروز خطا می شد و سبز موقعیت جدید که درست کار میکنه.
Procedure TMain.LoadComponents(AFileName: string);
var
S: string;
I: Integer;
Index: Integer;
IniFile: TIniFile;
Sections: TStringList;
Lab : TLabel;
Sh : TShape;
begin
IniFile := TIniFile.Create(AFileName);
try
Sections := TStringList.Create;
try
IniFile.ReadSections(Sections);
for I := 0 to Sections.Count - 1 do
begin
S := Sections[I];
if s = 'Panel3' then
Main.Panel3.Height := IniFile.ReadInteger(s, 'Height' , 90)
else
if LeftStr(S,8)='NewLabel' then
begin
Lab := TLabel.Create(self);
//Lab.Parent := Main.Panel3;
lab.Name := s;
Lab.Left := IniFile.ReadInteger(s, 'Left' , 20);
Lab.Top := IniFile.ReadInteger(s, 'Top' , 20);
Lab.Height := IniFile.ReadInteger(s, 'Height' , 20);
Lab.Width := IniFile.ReadInteger(s, 'Width' , 20);
Lab.Font.Size := IniFile.ReadInteger(s, 'FontSize' , 12);
Lab.Font.Color := StringToColor(IniFile.ReadString(s, 'Color' , '0'));
Lab.Caption := IniFile.ReadString(s, 'Caption' , '');
Lab.Hint := IniFile.ReadString(s, 'Hint' , '');
Lab.Font.Style:= [fsBold];
Lab.Transparent := True;
Lab.ShowHint := True;
Lab.AutoSize := True;
Lab.Parent := Main.Panel3;
end
else
if LeftStr(S,8)='NewShape' then
begin
Sh := TShape.Create(main.Panel3);
Sh.Name := s;
SetShape(Sh, IniFile.ReadString(s, 'Shape' , 'Solid'));
SetFillStyle(Sh, IniFile.ReadString(s, 'FillStyle' , 'Solid'));
Sh.Left := IniFile.ReadInteger(s, 'Left' , 20);
Sh.Top := IniFile.ReadInteger(s, 'Top' , 20);
Sh.Height := IniFile.ReadInteger(s, 'Height' , 20);
Sh.Width := IniFile.ReadInteger(s, 'Width' , 20);
Sh.Hint := IniFile.ReadString(s, 'Hint' , '');
Sh.ShowHint := True;
Sh.Pen.Color := StringToColor(IniFile.ReadString(s, 'PenColor' , '0'));
Sh.Brush.Color := StringToColor(IniFile.ReadString(s, 'BrushColor' , '0'));
Sh.pen.Width := IniFile.ReadInteger(s, 'FrameWidth' , 12);
Sh.Parent := Main.Panel3;
end;
end;
finally
Sections.Free;
end;
finally
IniFile.Free;
end;
end;
در پست اول هم میبینید که چهار مدل برا حذف لیبل نوشتم که همه شون هم با شرایط جدید کار میکنه.