Kikimorcho

Useful (or not) Delphi tips

  • Categories

  • Archives

Posts Tagged ‘Delphi’

GDI Objects – polygons, bitmaps …

Posted by kikimorcho on 22.f.11

There is a limitation of created polygons, bitmaps, brushes…
If you fail to create a polygon with CreatePolygonRGN, this means you reached the maximum count, or you are out of memory.

http://msdn.microsoft.com/en-us/library/ms724291(v=vs.85).aspx

I agree that creating 18000 brushes is a bit too much, but polygons?? I have a map with about 60000 non-rectangle objects, that are supposed to be able to be selected, moved and so on. So I really needed a large number of polygons… Too bad..

Posted in Canvas draw | Tagged: , , , , | Leave a Comment »

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…

Posted in Canvas draw | Tagged: , , | Leave a Comment »