In this example:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs; Type tform1 = Class (tform) Procedure formclick (Sender: tobject); end; vaR form1: tform1; implementation {$ R *. DFM} var F: Boolean = false; Procedure tform1.formclick (Sender: tobject); const n = 50; var PS: array [0 .. 6] of tpoint; NS: array [0 .. 1] of integer; RGN: hrgn; I: integer; begin refresh; PS [0]: = point (N, N Div 2); PS [1]: = point (n, clientheight-N); PS [2]: = point (clientwidth-N, clientheight-N); PS [3]: = point (clientwidth-N, N Div 2); PS [4]: = point (clientwidth Div 2, n); PS [5]: = point (N Div 2, clientheight-N Div 2 ); PS [6]: = point (clientwidth-N Div 2, clientheight-N Div 2); NS [0]: = 4; NS [1]: = 3; {create a region composed of multiple polygon} if F then begin RGN: = createpolypolypolygonrgn (Ps, NS, length (NS), winding); text: = 'fill mode: winding '; end else begin RGN: = createpolypolygonrgn (Ps, NS, length (NS), alternate); text: = 'fill mode: alternet'; end; F: = not F; {fill area} canvas. brush. color: = clsilver; canvas. brush. style: = bscross; fillrgn (canvas. handle, RGN, canvas. brush. handle); {draw area boundary} canvas. brush. color: = clred; canvas. brush. style: = bssolid; framergn (canvas. handle, RGN, canvas. brush. handle, 2, 2); canvas. brush. color: = self. color; for I: = 0 to length (PS) Do canvas. textout (PS [I]. x, PS [I]. y, inttostr (I); deleteobject (RGN); end.
The following "Old A123" requires a dynamic array, which can be changed to this:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs; Type tform1 = Class (tform) Procedure formclick (Sender: tobject); end; vaR form1: tform1; implementation {$ R *. DFM} var F: Boolean = false; Procedure tform1.formclick (Sender: tobject); const n = 50; var PS: array of tpoint; NS: array of integer; RGN: hrgn; i: integer; begin setlength (Ps, 7); setlength (NS, 2); refresh; PS [0]: = point (N, N Div 2 ); PS [1]: = point (n, clientheight-N); PS [2]: = point (clientwidth-N, clientheight-N); PS [3]: = point (clientwidth-N, N Div 2); PS [4]: = point (clientwidth Div 2, n); PS [5]: = point (N Div 2, clientheight-N Div 2); PS [6]: = point (clientwidth-N Div 2, clientheight-N Div 2); NS [0]: = 4; NS [1]: = 3; {create a region composed of multiple polygon} if F then begin RGN: = createpolypolygonrgn (PS [0], NS [0], length (NS), winding); text: = 'fill mode: winding'; end else begin RGN: = createpolypolygonrgn (PS [0], NS [0], length (NS), alternate); text: = 'fill mode: alternet'; end; F: = not F; {fill area} canvas. brush. color: = clsilver; canvas. brush. style: = bscross; fillrgn (canvas. handle, RGN, canvas. brush. handle); {draw area boundary} canvas. brush. color: = clred; canvas. brush. style: = bssolid; framergn (canvas. handle, RGN, canvas. brush. handle, 2, 2); canvas. brush. color: = self. color; for I: = 0 to length (PS) Do canvas. textout (PS [I]. x, PS [I]. y, inttostr (I); deleteobject (RGN); end.