陈
陈冲伟
Unregistered / Unconfirmed
GUEST, unregistred user!
我从TGraphic派生了一个类TMyGraphic用来处理我自定义的图像格式*.abc.
TMyGraphic里重载了Create(override), LoadFromStream(override)等方法,
大致如下:
TMyGraphic = class(TGraphic)
public
constructor Create; override;
destructor Destroy; override;
procedure LoadFromStream(Stream: TStream); override;
end;
然后我在如下语句中调用:
var
GraphicClass: TGraphicClass;
Graphic: TGraphic:
begin
GraphicClass := TMyGraphic;
Graphic := GraphicClass.Create;
Graphic.LoadFromFile('mypicture.abc'); //每次执行到此就说Access Violatiion
end;
进一步研究发现在第二句GraphicClass.Create调用中没有调用TMyGraphic.Create方法.
而如果改为:
begin
Graphic := TMyGraphic.Create;
Graphic.LoadFromFile('mypicture.abc');
end;
则载入完全正常,请问这是怎么回事?
TMyGraphic里重载了Create(override), LoadFromStream(override)等方法,
大致如下:
TMyGraphic = class(TGraphic)
public
constructor Create; override;
destructor Destroy; override;
procedure LoadFromStream(Stream: TStream); override;
end;
然后我在如下语句中调用:
var
GraphicClass: TGraphicClass;
Graphic: TGraphic:
begin
GraphicClass := TMyGraphic;
Graphic := GraphicClass.Create;
Graphic.LoadFromFile('mypicture.abc'); //每次执行到此就说Access Violatiion
end;
进一步研究发现在第二句GraphicClass.Create调用中没有调用TMyGraphic.Create方法.
而如果改为:
begin
Graphic := TMyGraphic.Create;
Graphic.LoadFromFile('mypicture.abc');
end;
则载入完全正常,请问这是怎么回事?