Changing the shape of a window

example by Simon de Kraa

This example program replaces the rectangular region of a window by a polygon. The technique is basically the same as described on page round widgets. You can download the example source from the attachments table.
A polygon is an array of points. The coordinates for the points in this example are calculated using the trigonometry functions sin and cos (found in the Visual C runtime module which is available on almost every PC). The number of points can be selected using the slider control; selecting a large number of points is somewhat slow but gives an interesting result as shown in the picture.
API declarations used in this example:

PROCEDURE CreatePolygonRgn EXTERNAL "gdi32.dll":
  DEFINE INPUT  PARAMETER lpPoint       AS MEMPTR.
  DEFINE INPUT  PARAMETER nCount        AS LONG.
  DEFINE INPUT  PARAMETER nPolyFillMode AS LONG.
  DEFINE RETURN PARAMETER ReturnValue   AS LONG.
END PROCEDURE.  
 
PROCEDURE sin EXTERNAL "MSVCRT40.DLL" CDECL:
  DEFINE INPUT  PARAMETER dblValue  AS DOUBLE NO-UNDO.
  DEFINE RETURN PARAMETER dblResult AS DOUBLE NO-UNDO.
END PROCEDURE.
 
PROCEDURE cos EXTERNAL "MSVCRT40.DLL" CDECL:
  DEFINE INPUT  PARAMETER dblValue  AS DOUBLE NO-UNDO.
  DEFINE RETURN PARAMETER dblResult AS DOUBLE NO-UNDO.
END PROCEDURE.

Attachments

polygon.zip : demo source