How to: create polygons with CreatePolygonRGN
Posted by kikimorcho on 22.f.11
In Delphi, if you want to create a polygon, you use CreatePolygonRGN.
I had a small problem with it, a small AV 🙂
So basically there is a BIG difference if your variable is an (dynamic) array of TPoint or array[0..x] of TPoint.
This is how to use both:
//Dynamic array : the parameter must be the first element of the array, not the array itself
var points : array of TPoint;
…
CreatePolygonRgn(Points[0], length(Points), ALTERNATE);
or
//Normal array : you just pass the array as a parameter
var points : array [0..3] of TPoint;
…
CreatePolygonRgn(Points, length(Points), ALTERNATE);
If you mix this, you’ll get either a AV, or nothing will happen…
Advertisements
Leave a Reply