警告提示,可能大多数不在乎,我就是要弄个所以然!请进。(10分)

  • 主题发起人 主题发起人 Nizvoo
  • 开始时间 开始时间
N

Nizvoo

Unregistered / Unconfirmed
GUEST, unregistred user!
[Warning] p_18.pas(1553): Constructing instance of 'TGraphic' containing abstract method 'TGraphic.LoadFromStream'
[Warning] p_18.pas(1553): Constructing instance of 'TGraphic' containing abstract method 'TGraphic.SaveToStream'
[Warning] p_18.pas(1553): Constructing instance of 'TGraphic' containing abstract method 'TGraphic.LoadFromClipboardFormat'
[Warning] p_18.pas(1553): Constructing instance of 'TGraphic' containing abstract method 'TGraphic.SaveToClipboardFormat'
[Warning] p_18.pas(1555): Constructing instance of 'TGraphic' containing abstract method 'TGraphic.LoadFromStream'
[Warning] p_18.pas(1555): Constructing instance of 'TGraphic' containing abstract method 'TGraphic.SaveToStream'
[Warning] p_18.pas(1555): Constructing instance of 'TGraphic' containing abstract method 'TGraphic.LoadFromClipboardFormat'
[Warning] p_18.pas(1555): Constructing instance of 'TGraphic' containing abstract method 'TGraphic.SaveToClipboardFormat'
 
TGraphic = class(TPersistent)
private
FOnChange: TNotifyEvent;
FOnProgress: TProgressEvent;
FModified: Boolean;
FTransparent: Boolean;
FPaletteModified: Boolean;
procedure SetModified(Value: Boolean);
protected
constructor Create; virtual;
procedure Changed(Sender: TObject); virtual;
procedure DefineProperties(Filer: TFiler); override;
procedure Draw(ACanvas: TCanvas; const Rect: TRect); virtual; abstract;
function Equals(Graphic: TGraphic): Boolean; virtual;
function GetEmpty: Boolean; virtual; abstract;
function GetHeight: Integer; virtual; abstract;
function GetPalette: HPALETTE; virtual;
function GetTransparent: Boolean; virtual;
function GetWidth: Integer; virtual; abstract;
procedure Progress(Sender: TObject;
Stage: TProgressStage;
PercentDone: Byte;
RedrawNow: Boolean;
const R: TRect;
const Msg: string); dynamic;
procedure ReadData(Stream: TStream); virtual;
procedure SetHeight(Value: Integer); virtual; abstract;
procedure SetPalette(Value: HPALETTE); virtual;
procedure SetTransparent(Value: Boolean); virtual;
procedure SetWidth(Value: Integer); virtual; abstract;
procedure WriteData(Stream: TStream); virtual;
public
procedure LoadFromFile(const Filename: string); virtual;
procedure SaveToFile(const Filename: string); virtual;
procedure LoadFromStream(Stream: TStream); virtual; abstract;
procedure SaveToStream(Stream: TStream); virtual; abstract;
procedure LoadFromClipboardFormat(AFormat: Word; AData: THandle;
APalette: HPALETTE); virtual; abstract;
procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle;
var APalette: HPALETTE); virtual; abstract;
property Empty: Boolean read GetEmpty;
property Height: Integer read GetHeight write SetHeight;
property Modified: Boolean read FModified write SetModified;
property Palette: HPALETTE read GetPalette
write SetPalette;
property PaletteModified: Boolean read FPaletteModified
write FPaletteModified;
property Transparent: Boolean read GetTransparent
write SetTransparent;
property Width: Integer read GetWidth write SetWidth;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnProgress: TProgressEvent read FOnProgress
write FOnProgress;
end;
 
有没有还要发言。
 
TGraphic是一个抽象类,不能直接创建。要创建它的子类的话,子类必须实现了所有
父类的抽象方法,否则子类也是一个抽象类,不能创建(即使能创建,调用时也会出
错)。
 
我调用时没出错,这里我很模糊。
我的要求是有时候是jpg,有时候又是bmp。所以我创建这个了。
对了,还有一点就是因为我的文件都不以这些为后缀,所以要这么定义
 
如果后缀正常,你可以用TPicture。否则你得自己判断了。
》》调用时没出错
不会吧,你试试下面的代码:

procedure TForm1.Button1Click(Sender: TObject);
begin
with TGraphic.Create do
try
LoadFromStream(nil);
finally
Free;
end;
end;
 
我调用的一段代码。
请看。
JPEG格式
DspImage.JPEGImage.LoadFromFile(DspImage.Path + DspImage.main.image.imgfile);
PrtImgPar.QRImage.Picture.Bitmap.Assign(DspImage.JPEGImage); //这行是赋给打印上的

BMP格式
DspImage.BmpImage.LoadFromFile(DspImage.Path + DspImage.main.image.imgfile);
PrtImgPar.QRImage.Picture.Assign(DspImage.BmpImage); //这行是赋给打印上的
 
不好意思贴错了。。等会先
 
看看

http://www.delphibbs.com/delphibbs/dispq.asp?lid=792586
 
多人接受答案了。
 
后退
顶部