BCX_POLYGON function

Purpose: BCX_POLYGON function draws a polygon consisting of two or more vertices connected by straight lines. The polygon is outlined by using the current pen and filled by using the current brush and polygon fill mode.


Syntax:

 RetVal% = BCX_POLYGON(hWnd, _
                     pVertX, _
                  numVertX%, _
                     [, Pen] _
                 [, DrawHDC])

Parameters:

  • hWnd Identifies the window where drawing takes place.
  • pVertX Pointer to an array of POINT structures that specify the vertices of the polygon.
  • numVertX% Specifies the number of vertices in the array. This value must be greater than or equal to 2.
  • Pen [OPTIONAL] integer representing the RGB color code. The default is 0 which is a black pen.
  • DrawHDC [OPTIONAL] HDC (Handle to Device Context) pointing to an already open HDC. This is useful if a device context is to be written to many times. In this case the programmer is responsible for closing the HDC at the appropriate time.

Return Value:

  • RetVal% is a nonzero integer if the function succeeds, zero if the function fails.

Here is an example of the BCX_POLYGON function.


 GUI "BCX_POLYGON"
 
 DIM pVertX[10] AS POINT
 
 SUB FORMLOAD
   GLOBAL Form1 AS HWND
   DIM i%
   DIM pi2#
   pi2# = 8.0 * ATN(1.0)
   FOR i = 0 TO 9
     pVertX[i].x = 125 + SIN(pi2# * i% / 10) * 55
     pVertX[i].y =  95 + COS(pi2# * i% / 10) * 55
   NEXT
   Form1 = BCX_FORM("BCX_POLYGON", 0, 0, 130, 110)
   BCX_SET_FORM_COLOR(Form1,QBCOLOR(31))
   CENTER(Form1)
   SHOW(Form1)
 END SUB
 
 BEGIN EVENTS
   SELECT CASE CBMSG
   CASE WM_PAINT
     CALL DrawStuff
 
   CASE WM_CLOSE
     DestroyWindow(Form1)
     EXIT FUNCTION
 
   END SELECT
 END EVENTS
 
 SUB DrawStuff
   DIM RAW RetVal%
   RetVal% = BCX_POLYGON(Form1, pVertX , 10 ,QBCOLOR(4))
 END SUB