AllApi.net

[an error occurred while processing this directive]
 
Private Type POINTAPI
        x As Long
        y As Long
End Type
Private Declare Function CreatePolyPolygonRgn Lib "gdi32" (lpPoint As POINTAPI, lpPolyCounts As Long, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function InvertRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Sub Form_Load()
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Me.AutoRedraw = True
    ' Invert the points lying within a multi-polygonal region on window Form1. The
    ' region is made up of a triangle and a diamond. The triangle has vertices (25,25), (50,50),
    ' and (25,50). The diamond has vertices (150,150), (200,200), (150,250), and (100,200).
    Dim vertex(0 To 6) As POINTAPI ' holds vertices of each polygon
    Dim numvertices(0 To 1) As Long ' holds how many vertices belong to each polygon
    Dim hRgn As Long ' handle to the multi-polygonal region
    Dim retval As Long ' return value

    ' Load the vertices of the triangle into the vertex array.
    vertex(0).x = 25: vertex(0).y = 25 ' 1st point: (25,25)
    vertex(1).x = 50: vertex(1).y = 50 ' 2nd point: (50,50)
    vertex(2).x = 25: vertex(2).y = 50 ' 3rd point: (25,50)
    numvertices(0) = 3 ' three vertices for the triangle

    ' Load the vertices of the diamond into the vertex array.
    vertex(3).x = 150: vertex(3).y = 150 ' 1st point: (150,150)
    vertex(4).x = 200: vertex(4).y = 200 ' 2nd point: (200,200)
    vertex(5).x = 150: vertex(5).y = 250 ' 3rd point: (150,250)
    vertex(6).x = 100: vertex(6).y = 200 ' 4th point: (100,200)
    numvertices(1) = 4 ' four vertices for the triangle

    ' Create the multi-polygonal region and get a handle to it.
    hRgn = CreatePolyPolygonRgn(vertex(0), numvertices(0), 2, ALTERNATE)
    ' Invert the pixels within this region on Form1.
    retval = InvertRgn(Me.hdc, hRgn)
    ' Delete the region to free up resources.
    retval = DeleteObject(hRgn)
End Sub


 
Copyright © 1998-2000, The KPD-Team.
Send mail to KPDTeam@Allapi.net with comments about this web site.
This site is located at
http://www.Allapi.net/