调试后发现执行此事件时一直在执行,执行Timage类的paint事件:看看怎样改?
procedure TDBTransparentImage.Paint;
var
R: TRect;
S: string;
DrawPict: TPicture;
TempBmp: TBitmap;
begin
if ((Picture.Graphic <> nil) or (csPaintCopy in ControlState)) then begin
DrawPict := TPicture.Create;
try
if (csPaintCopy in ControlState) and (Field <> nil)
{$IFDEF VER120}
and Field.IsBlob
{$ENDIF} then
DrawPict.Assign(Field)
else DrawPict.Assign(Picture); TempBmp := TBitmap.Create;
try
TempBmp.Height := ClientHeight;
TempBmp.Width := ClientWidth;
with TempBmp.Canvas do begin
if fBackgroundPic.Empty then
begin
Brush.Style := bsSolid;
Brush.Color := Color;
FillRect(ClientRect);
end
else StretchDraw(ClientRect, fBackgroundPic); if not ((DrawPict.Graphic = nil) or DrawPict.Graphic.Empty) then begin
if Stretch then
SetRect(R, 0, 0, ClientWidth, ClientHeight)
else begin
SetRect(R, 0, 0, DrawPict.Width, DrawPict.Height);
if Center then OffsetRect(R, (ClientWidth -
DrawPict.Width) div 2,
(ClientHeight - DrawPict.Height) div 2);
end; if fTransparent and (DrawPict.Graphic is TBitmap) then
begin
CopyMode := cmSrcAnd;
StretchDraw(R, DrawPict.Bitmap);
CopyMode := cmSrcCopy;
end
else StretchDraw(R, DrawPict.Graphic);
end;
end; //with
Canvas.Draw(0, 0, TempBmp);
finally
TempBmp.Free;
end;
finally
DrawPict.Free;
end;
end
else begin
Canvas.Font := Font;
Canvas.Brush.Color := Color;
if (Field <> nil) then
S := Field.DisplayLabel
else S := Name;
S := '(' + S + ')';
R := ClientRect;
Canvas.TextRect(R, (R.Right - Canvas.TextWidth(S)) div 2, (R.Bottom - Canvas.TextHeight(S)) div 2, S);
end; if (Focused and fFocusRect) then begin
Canvas.Brush.Color := fFocusColor;
Canvas.FrameRect(ClientRect);
end;
end;
procedure TDBTransparentImage.Paint;
var
R: TRect;
S: string;
DrawPict: TPicture;
TempBmp: TBitmap;
begin
if ((Picture.Graphic <> nil) or (csPaintCopy in ControlState)) then begin
DrawPict := TPicture.Create;
try
if (csPaintCopy in ControlState) and (Field <> nil)
{$IFDEF VER120}
and Field.IsBlob
{$ENDIF} then
DrawPict.Assign(Field)
else DrawPict.Assign(Picture); TempBmp := TBitmap.Create;
try
TempBmp.Height := ClientHeight;
TempBmp.Width := ClientWidth;
with TempBmp.Canvas do begin
if fBackgroundPic.Empty then
begin
Brush.Style := bsSolid;
Brush.Color := Color;
FillRect(ClientRect);
end
else StretchDraw(ClientRect, fBackgroundPic); if not ((DrawPict.Graphic = nil) or DrawPict.Graphic.Empty) then begin
if Stretch then
SetRect(R, 0, 0, ClientWidth, ClientHeight)
else begin
SetRect(R, 0, 0, DrawPict.Width, DrawPict.Height);
if Center then OffsetRect(R, (ClientWidth -
DrawPict.Width) div 2,
(ClientHeight - DrawPict.Height) div 2);
end; if fTransparent and (DrawPict.Graphic is TBitmap) then
begin
CopyMode := cmSrcAnd;
StretchDraw(R, DrawPict.Bitmap);
CopyMode := cmSrcCopy;
end
else StretchDraw(R, DrawPict.Graphic);
end;
end; //with
Canvas.Draw(0, 0, TempBmp);
finally
TempBmp.Free;
end;
finally
DrawPict.Free;
end;
end
else begin
Canvas.Font := Font;
Canvas.Brush.Color := Color;
if (Field <> nil) then
S := Field.DisplayLabel
else S := Name;
S := '(' + S + ')';
R := ClientRect;
Canvas.TextRect(R, (R.Right - Canvas.TextWidth(S)) div 2, (R.Bottom - Canvas.TextHeight(S)) div 2, S);
end; if (Focused and fFocusRect) then begin
Canvas.Brush.Color := fFocusColor;
Canvas.FrameRect(ClientRect);
end;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货