Private Sub ShapeForm(ByVal offset As Single)
Const ALTERNATE = 1 Const NUM_POINTS = 20 Const PI = 3.14159265 Dim rgn As Long Dim wid As Single Dim hgt As Single Dim theta As Single Dim dtheta As Single Dim i As Integer Dim w(0 To 1) As Single Dim h(0 To 1) As Single Dim cx As Single Dim cy As Single Dim points() As POINTAPI If WindowState = vbMinimized Then Exit Sub ' Create the points for the polygon. ' This example uses sines and cosines to make ' a many pointed star. You could enter points ' explicitly to create a polygon of any shape. wid = ScaleX(Width, vbTwips, vbPixels) hgt = ScaleY(Height, vbTwips, vbPixels) cx = wid / 2 cy = hgt / 2 w(0) = wid * 0.2 w(1) = wid * 0.5 h(0) = hgt * 0.2 h(1) = hgt * 0.5 dtheta = 2 * PI / NUM_POINTS theta = PI / 2 ReDim points(1 To NUM_POINTS) For i = 1 To NUM_POINTS With points(i) .x = cx + w(i Mod 2) * Cos(theta + offset) .y = cy + h(i Mod 2) * Sin(theta + offset) theta = theta + dtheta End With Next i ' Create the region. rgn = CreatePolygonRgn(points(1), _ NUM_POINTS, ALTERNATE) ' Restrict the window to the region. SetWindowRgn hWnd, rgn, True End Sub |