Range Check Error in CreatePatternBrush in winapi.inc
Original Reporter info from Mantis: tsapi
-
Reporter name: Tsvetoslav
Description:
I installed VirtualTreeView package (https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/virtualtreeview-new) and tried to run the demo applications. In most cases I received "Range Check Error" exception in CreatePatternBrush function in winapi.inc, more exactly on the line
LogBrush.lbHatch := ABitmap
It seems the problem is that lbHatch is PtrInt type (i.e. Longint with 32-bit applcations), while ABitmap is of type THandle, i.e. DWord (LongWord) and sometimes the assignment causes Range Check Error.
So, either lbHatch should be defined as PtrUInt in tagLOGBRUSH record definition, e.g.
tagLOGBRUSH = record
lbStyle: LongWord;
lbColor: TColorRef;
lbHatch: PtrUInt;
end;
or an implicit type cast should be used wherever there is such an assignment, e.g.
LogBrush.lbHatch := PtrInt(ABitmap);
Mantis conversion info:
-
Mantis ID: 16088
-
OS: windows
-
OS Build: WinXP
-
Platform: i386
-
Version: 0.9.29 (SVN)
-
Fixed in version: 0.9.29 (SVN)
-
Fixed in revision: 28637 (#b1d4dc1f)
-
Target version: 1.0.0
-
LazTarget: 1.0