Rubrik: Grafik & Zeichnen | 22.03.05 |
CreateEllipticRgn-Funktion Diese Funktion erstellt eine elliptische Region und gibt den Handle zu dieser zurück. | ||
Betriebssystem: Win95, Win98, WinNT 3.1, Win2000, WinME | Views: 7.822 |
Deklaration:
Declare Function CreateEllipticRgn Lib "gdi32.dll" ( _ ByVal X1 As Long, _ ByVal Y1 As Long, _ ByVal X2 As Long, _ ByVal Y2 As Long) As Long
Beschreibung:
Diese Funktion erstellt eine elliptische Region und gibt den Handle zu dieser zurück.
Parameter:
X1 | Erwartet die obere horizontale Koordinate eines Rechtecks, in dem die elliptische Region erstellt werden soll. |
Y1 | Erwartet die obere vertikale Koordinate eines Rechtecks, in dem die elliptische Region erstellt werden soll. |
X2 | Erwartet die untere horizontale Koordinate eines Rechtecks, in dem die elliptische Region erstellt werden soll. |
Y2 | Erwartet die untere vertikale Koordinate eines Rechtecks, in dem die elliptische Region erstellt werden soll. |
Rückgabewert:
Ist die Funktion erfolgreich, so liefert sie den Handle der neu erstellten Region zurück, andernfalls wird derWert "0" zurückgegeben.
Beispiel:
Private Declare Function CreateEllipticRgn Lib "gdi32.dll" ( _ ByVal X1 As Long, _ ByVal Y1 As Long, _ ByVal X2 As Long, _ ByVal Y2 As Long) As Long Private Declare Function DeleteObject Lib "gdi32.dll" ( _ ByVal hObject As Long) As Long Private Declare Function CreateRectRgn Lib "gdi32.dll" ( _ ByVal X1 As Long, _ ByVal Y1 As Long, _ ByVal X2 As Long, _ ByVal Y2 As Long) As Long Private Declare Function CombineRgn Lib "gdi32" ( _ ByVal hDestRgn As Long, _ ByVal hSrcRgn1 As Long, _ ByVal hSrcRgn2 As Long, _ ByVal nCombineMode As Long) As Long Private Declare Function FrameRgn Lib "gdi32.dll" ( _ ByVal hdc As Long, _ ByVal hRgn As Long, _ ByVal hBrush As Long, _ ByVal nWidth As Long, _ ByVal nHeight As Long) As Long Private Declare Function CreateHatchBrush Lib "gdi32.dll" ( _ ByVal nIndex As Long, _ ByVal crColor As Long) As Long Private Declare Function FillRgn Lib "gdi32.dll" ( _ ByVal hdc As Long, _ ByVal hRgn As Long, _ ByVal hBrush As Long) As Long Private Declare Function InvertRgn Lib "gdi32.dll" ( _ ByVal hdc As Long, _ ByVal hRgn As Long) As Long ' CreateHatchBrush nIndex-Konstanten Private Const HS_BDIAGONAL = 3 Private Const HS_CROSS = 4 Private Const HS_DIAGCROSS = 5 Private Const HS_FDIAGONAL = 2 Private Const HS_HORIZONTAL = 0 Private Const HS_VERTICAL = 1 Private hRgn1 As Long, hRgn2 As Long, hRgn3 As Long Private hBrush As Long
' 2 Regionen kombinieren und invertieren Private Sub Form_Load() Dim Retval As Long ' Autoredraw auf True stellen Me.AutoRedraw = True ' Brush erstellen hBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(0, 255, 0)) ' Elliptische Region erstellen hRgn1 = CreateEllipticRgn(20, 30, 150, 110) ' bounding rectangle (20,30)-(150,110) ' daneben eine rechteckige Region erstellen hRgn2 = CreateRectRgn(150, 30, 200, 110) ' eine dritte "leere" Region erstellen hRgn3 = CreateRectRgn(0, 0, 0, 0) ' kombinieren der beiden Regionen (Körper) zu einer Region CombineRgn hRgn3, hRgn1, hRgn2, 3 ' kombinierte Region mit dem Brush füllen FillRgn Me.hdc, hRgn3, hBrush ' invertieren der kombinierten Region InvertRgn Me.hdc, hRgn3 ' Rahmen mit dem Pen um die kombinierte Region zeichnen FrameRgn Me.hdc, hRgn3, hBrush, 5, 10 End Sub
' Ressourcen freigeben Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Dim Retval As Long ' löschen des Brushs DeleteObject hBrush ' löschen der erstellten Regionen DeleteObject hRgn1 DeleteObject hRgn2 DeleteObject hRgn3 End Sub