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..