Useful (or not) Delphi tips

  • Categories

  • Archives

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);

//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…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: