2
이 TObjectList 안에 TFPolygon = TPoint 배열로 여러 Polygons를 저장할 Objectlist를 정의했습니다.TObjectList 내부에 TPoint의 배열을 저장합니다.
type
TFPolygon = array of TPoint;
TFPolygonList = class(TObjectList)
private
procedure SetPolygon(Index: Integer; Value: TFPolygon);
function GetPolygon(Index: Integer): TFPolygon;
public
procedure Add(p: TFPolygon);
property Items[index: Integer]: TFPolygon read GetPolygon write SetPolygon; default;
end;
implementation
procedure TFPolygonList.SetPolygon(Index: Integer; Value: TFPolygon);
begin
inherited Items[Index] := Pointer(Value);
end;
function TFPolygonList.GetPolygon(Index: Integer): TFPolygon;
begin
Result := TFPolygon(inherited Items[Index]);
end;
procedure TFPolygonList.Add(p: TFPolygon);
begin
inherited Add(Pointer(p));
end;
이 코드 샘플 내부 오류를 이해할 수 없다 :하지만 내 통해 Objectlist의 추가 기능 나는 액세스 위반 오류 를 얻을? TObjectList 내에서만 클래스를 저장할 수 있습니까? 아니면 TPoint 배열을 저장할 수있는 방법이 유효합니까?
내 코드가 모두 TFPolygonList = TList로 바뀝니다.; 멋진 짧은 버전 :-) –
user1769184
@user 예, 필요한 것처럼 들립니다. 제네릭 전에 우리가 어떻게 관리했는지 모르겠군요! –
@David, 우리는 더 많은 코드를 작성했고 더 작은 실행 파일을 가지고 있습니다. – Runner