Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

RangeCheck error in TppScreenDevice.DrawShape

edited September 2009 in General
Hi,

RbPro 11.06, Delphi 2006, Vista SP2


The following code fiom TppScreenDevice.DrawShape can lead to a RangeCheck
error:

FCanvas.Pen.Width := Round(aDrawShape.Pen.Width * FScaleX);

if (FCanvas.Pen.Style <> psSolid) and (FCanvas.Pen.Width > 1) then
begin
lLogBrush.lbStyle := Ord(bsSolid);
lLogBrush.lbColor := FCanvas.Pen.Color; <=== potential
RangeCheck error
lLogBrush.lbHatch := 0;
FCanvas.Pen.Handle := ExtCreatePen(PS_GEOMETRIC or
Ord(FCanvas.Pen.Style), FCanvas.Pen.Width, lLogBrush, 0, nil);
end;


if FCanvas.Pen.Color is a system color like clWindow. Color is then negative
and TLogBrush.lbColor is a cardinal.

A get this if a set a TppRegion to have no line color, Pen.Color is set then
to clWindowText and Pen.Style to psClear. (And compile with RangeChecks on
of course).
I don't know what windows does with the high bits of lbColor if you build
without RangeChecks and ignore the error, but i think the safest solution is
to change the assignment to:

lLogBrush.lbColor := ColorToRGB(FCanvas.Pen.Color);




Regards,

Max Paay
Quadrant Software bv.
The Netherlands.




__________ Information from ESET NOD32 Antivirus, version of virus signature database 4427 (20090915) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Comments

This discussion has been closed.