Rubrik: Grafik & Zeichnen | 22.03.05 |
CreatePolyPolygonRgn-Funktion Diese Funktion erstellt eine Region, wobei mehre Figuren mit mehreren Punkten angegeben werden können. | ||
Betriebssystem: Win95, Win98, WinNT 3.1, Win2000, WinME | Views: 6.680 |
Deklaration:
Declare Function CreatePolyPolygonRgn Lib "gdi32.dll" ( _ lpPoint As POINT_TYPE, _ lpPolyCounts As Long, _ ByVal nCount As Long, _ ByVal nPolyFillMode As Long) As Long
Beschreibung:
Diese Funktion erstellt eine Region, wobei mehre Figuren mit mehreren Punkten angegeben werden können.
Parameter:
lpPoint | Erwartet ein Array von POINTAPI-Strukturen, dessen Felder mit den Koordinaten der Punkte jeder Figur gefüllt sind. |
lpPolyCounts | Erwartet ein Long-Array, in dem jedes Feld die Anzahl der Punkte je Figur in "lpPoint" enthält. |
nCount | Erwartet die Anzahl der Arrayfelder von "lpPolyCounts". |
nPolyFillMode | Erwartet eine der folgenden Konstanten die beschreiben wie der Inhalt der Region gefüllt werden soll. |
nPolyFillMode Konstanten:
Const ALTERNATE = 1 ' Alternative zwischen gefüllt und ungefüllt, je nach dem welches die Randfarbe ist Const WINDING = 2 ' Die Region wird komplett gefüllt.
Rückgabewert:
Ist die Funktion erfolgreich, so wird das Handle der erstellten Region zurückgegeben, andernfallswird der wert "0" zurückgegeben.
Beispiel:
Private Declare Function CreatePolyPolygonRgn Lib "gdi32.dll" ( _ lpPoint As POINTAPI, _ lpPolyCounts As Long, _ ByVal nCount As Long, _ ByVal nPolyFillMode As Long) As Long Private Declare Function DeleteObject Lib "gdi32.dll" ( _ ByVal hObject As Long) As Long Private Declare Function InvertRgn Lib "gdi32.dll" ( _ ByVal hdc As Long, _ ByVal hRgn As Long) As Long Private Type POINTAPI x As Long y As Long End Type ' CreatePolyPolygonRgn/SetPolyFillMode nPolyFillMode-Konstanten Private Const ALTERNATE = 1 ' Alternative zwischen gefüllt und ungefüllt, je nach dem welches die Randfarbe ist Private Const WINDING = 2 ' Die Region wird komplett gefüllt.
' Multiple Region erstellen Private Sub Form_Load() Dim hRegion As Long, Points(7) As POINTAPI, Figures(1) As Long Me.ScaleMode = vbPixels Me.AutoRedraw = True ' Figur 1 With Points(0) .x = 10 .y = 10 End With With Points(1) .x = Me.ScaleWidth - 10 .y = 10 End With With Points(2) .x = Me.ScaleWidth / 2 .y = Me.ScaleHeight / 2 End With With Points(3) .x = 10 .y = 10 End With Figures(0) = 4 ' Figur 2 With Points(4) .x = 10 .y = Me.ScaleHeight / 2 End With With Points(5) .x = Me.ScaleWidth - 10 .y = Me.ScaleHeight / 2 End With With Points(6) .x = Me.ScaleWidth / 2 .y = Me.ScaleHeight End With With Points(7) .x = 10 .y = Me.ScaleHeight / 2 End With Figures(1) = 4 hRegion = CreatePolyPolygonRgn(Points(0), Figures(0), 2, WINDING) Call InvertRgn(Me.hdc, hRegion) Call DeleteObject(hRegion) End Sub