   CreatePolygonRgn
  I'm trying to create a polygon region in a windows application. The other code in the window is working properly. This is what I have so far:POINT poly2[4];for(int i=0; i<4; ++i){poly2.x+=10;poly2.y+=10;}hRgn=CreatePolygonRgn(poly2,4,ALTERNATE);HBRUSH polyBrush = (HBRUSH)SelectObject(bbDC, GetStockObject(GRAY_BRUSH));FillRgn(bbDC,hRgn,polyBrush);The region is attempted to being drawn on a back buffer device context where everything else is working okay;Does anybody know how to use this function?Thanks
  What are you initializing the elements of poly2[4] to? Your for() loop is just adding 10 to some number you haven't specified. What kind of a region are you trying to create?   ;  Once you get that sorted: the POINTs that you pass to CreatePolygonRgn represent the corners of the polygon, right? Don't you think they should be at different positions from each other?   ;  Thats not the problem. I've tried different point initializations. Can you give me a short example of workable code for this function?   ;  As you posted it, that IS the problem. Also, you failed to mention exactly what the problem is. Are you able to draw anything into the device context? If not, that may be your problem. Is it not drawing or is not drawing as you expect?Quote:Original post by Deek880POINT poly2[4];//poly2[] is initialized to either 0 or some random value (possibly off screen).//At best, all of the coordinates are the same (0). At worst, they are a random//assortment of values. If you are not setting them at this point, before the loop,//you have no idea what data you're using. If your compiler sets poly2 to zero,//you're defining a single point on your screen. Nothing will be drawn. Adding//10 to each coordinate merely transforms all of the points in poly2 from {0,0}//to {10,10}, {20,20}, etc.for(int i=0; i<4; ++i){poly2.x+=10; // Adding 10 to what?poly2.y+=10; // Adding 10 to what?}hRgn=CreatePolygonRgn(poly2,4,ALTERNATE);HBRUSH polyBrush = (HBRUSH)SelectObject(bbDC, GetStockObject(GRAY_BRUSH));FillRgn(bbDC,hRgn,polyBrush);poly2[0].x = 0; // Assuming the compiler is initializing poly2 to zero.poly2[0].y = 0; // You didn't supply this part, so we can only assume...poly2[1].x = 0; // ""poly2[1].y = 0; // ""poly2[2].x = 0; // ""poly2[2].y = 0; // ""poly2[3].x = 0; // ""poly2[3].y = 0; // ""After the loop, you have this going on:poly2[0].x = 40; poly2[0].y = 40;poly2[1].x = 40; poly2[1].y = 40;poly2[2].x = 40; poly2[2].y = 40;poly2[3].x = 40; poly2[3].y = 40;Every coordinate is the same, hence, nothing is drawn. If this is truly not the issue, then you need to supply more of the code.   