Rubrik: Grafik & Zeichnen | 22.03.05 |
InvertRect-Funktion Diese Funktion invertiert die Farben eines Bereiches auf einem angegeben Gerät. | ||
Betriebssystem: Win95, Win98, WinNT 3.1, Win2000, WinME | Views: 7.835 |
Deklaration:
Declare Function InvertRect Lib "user32.dll" ( _ ByVal hdc As Long, _ ByVal lpRect As RECT) As Long
Beschreibung:
Diese Funktion invertiert die Farben eines Bereiches auf einem angegeben Gerät.
Parameter:
hdc | Erwartet das Handle des Gerätes, auf dem die Farben invertiert werden sollen. |
lpRect | Erwartet eine gefüllte RECT-Struktur, die mit den Koordinaten gefüllt ist in denen die Farben invertiert werden sollen. |
Rückgabewert:
Ist die Funktion erfolgreich so wird ein Wert "ungleich 0" zurückgegeben, andernfallswird der Wert "0" zurückgegben.
Beispiel:
Private Declare Function FillRect Lib "user32" ( _ ByVal hdc As Long, _ lpRect As RECT, _ ByVal hBrush As Long) As Long Private Declare Function CreateHatchBrush Lib "gdi32" ( _ ByVal nIndex As Long, _ ByVal crColor As Long) As Long Private Declare Function DeleteObject Lib "gdi32" ( _ ByVal hObject As Long) As Long Private Declare Function InvertRect Lib "user32" ( _ ByVal hdc As Long, _ lpRect As RECT) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Const HS_BDIAGONAL = 3 ' Diagonal von links unten nach rechts oben (/) Private Const HS_CROSS = 4 ' Kreuz (+) Private Const HS_DIAGCROSS = 5 ' Diagonales Kreuz (x) Private Const HS_FDIAGONAL = 2 ' Diagonal von rechts unten nach links oben (\) Private Const HS_HORIZONTAL = 0 ' Horizontal (-) Private Const HS_VERTICAL = 1 ' Vertikal (|)
' Füllen des Fensters mit einem Muster Private Sub Form_Load() Dim Retval As Long, hBrush As Long, hOldBrush As Long, WndRect As RECT Dim FirstColor As Long Me.ScaleMode = vbPixels Me.AutoRedraw = True ' RECT-Struktur mit Fenstergröße füllen With WndRect .Right = Me.ScaleWidth .Bottom = Me.ScaleHeight End With ' Brush erstellen hBrush = CreateHatchBrush(HS_DIAGCROSS, vbGreen) ' Fenster mit einem Muster füllen Retval = FillRect(Me.hdc, WndRect, hBrush) ' Fensterfarbe invertieren Retval = InvertRect(Me.hdc, WndRect) ' erstellten Brush zerstören DeleteObject hBrush End Sub