[英]Delphi 4 error:- Incompatible Types : “TBitmap” and “TObject”
在我尝试运行/ compile / build一个Proiject时出现此错误
Incompatible Types : “TBitmap” and “TObject”
光标指向Bitmap := FSectionList.BackgroundBitmap
请帮我弄清楚。 像救护车一样挤在这里
这是代码的一部分:
procedure ThtmlViewer.DoBackground1(ACanvas: TCanvas; ATop, AWidth, AHeight, FullHeight: integer);
var
ARect: TRect;
Bitmap, Mask: TBitmap;
PRec: PtPositionRec;
BW, BH, X, Y, X2, Y2, IW, IH, XOff, YOff: integer;
Fixed: boolean;
begin
ARect := Rect(0, 0, AWidth, AHeight);
Bitmap := FSectionList.BackgroundBitmap;
if FSectionList.ShowImages and Assigned(Bitmap) then
begin
Mask := FSectionList.BackgroundMask;
BW := Bitmap.Width;
BH := Bitmap.Height;
PRec := FSectionList.BackgroundPRec;
Fixed := PRec[1].Fixed;
if Fixed then
begin {fixed background}
XOff := 0;
YOff := 0;
IW := AWidth;
IH := AHeight;
end
else
begin {scrolling background}
XOff := 0;
YOff := ATop;
IW := AWidth;
IH := FullHeight;
end;
CalcBckgrndLoctionAndTilng(PRec, ARect, XOff, YOff, IW, IH, BW, BH, X, Y, X2, Y2);
DrwBckgrnd(ACanvas, ARect, X, Y, X2, Y2, Bitmap, Mask, BW, BH, PaintPanel.Color);
end
else
begin {no background image, show color only}
DrwBckgrnd(ACanvas, ARect, 0,0,0,0, Nil, Nil, 0, 0, PaintPanel.Color);
end;
end;
感谢和问候瓦斯
我只是在猜测,但是从错误消息和FSectionList的名称来看,它是一种包含通用TObject实例的List,而BackgroundBitmap就是其中之一。
您需要将其投射回TBitmap:
Bitmap := FSectionList.BackgroundBitmap as TBitMap;
在Windows.pas中定义的TBitmap和Graphics.pas中定义的TBitmap类之间,似乎使编译器有些困惑。 似乎认为您正在尝试将Graphics.TBitmap分配给Windows.TBitmap。
您可以通过将Bitmap的声明更改为Windows.TBitmap或Graphics.TBitmap来解决此问题。 您没有在FSectionList上包含任何信息,但是导致问题的原因可能是该行
var
Bitmap, Mask: TBitmap;
将其更改为以下之一:
Bitmap, Mask: Graphics.TBitmap;
or
Bitmap, Mask: Windows: TBitmap;
我无法告诉您使用哪个,因为我不知道那里有FSectionList。 添加其中之一然后尝试编译应该为您决定。 但我会根据错误消息怀疑您需要Windows。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.