RangeCheck error in TppScreenDevice.DrawShape
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
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
This discussion has been closed.
Comments
Thanks you, we will make the appropriate changes to our source.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com