BackColor Invert


Ein einfaches Script um die BackColor-Farbe eines Controls zu invertieren.
Laden Sie sich die Zip-Datei mit VB 6 Source Code hinunter und probieren Sie es mal aus.

Projekt - Download
© FienauBerlin   Web-ComputerEcke.de
 

Quell-Code
Option Explicit
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, _
                       ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetCursorPos Lib "user32" ( _
                       lpPoint As POINTAPI) As Long
Private Declare Function GetWindowDC Lib "user32" ( _
                       ByVal hwnd As Long) As Long
 
Private Type POINTAPI
    X As Long
    Y As Long
End Type

Private Sub Command1_Click() Dim u As Integer For u = Pic1.LBound To Pic1.UBound P.Picture = LoadPicture() 'PictureBox P muß sichtbar bleiben! P.Cls P.BackColor = Pic1(u).BackColor P.AutoRedraw = True P.Picture = P.Image 'BackColor als Bild 'Bild invertieren Call P.PaintPicture(P.Picture, 0, 0, , , , , , , vbDstInvert) P.Refresh P.AutoRedraw = False 'Label wandelt den Farb-Long-Wert des 1. Pixels. Label1.BackColor = P.Point(1, 1) Pic1(u).BackColor = Label1.BackColor Next
End Sub Private Sub Timer1_Timer() Dim mPOSITION As POINTAPI Dim col As Long Dim DC As Long DC = GetWindowDC(0) Call GetCursorPos(mPOSITION) col = GetPixel(DC, mPOSITION.X, mPOSITION.Y) Text1.Text = "&H" & toHex((col), 8) & "&" End Sub
Public Function toHex(ByVal Number As Long, _ ByVal NumLen As Integer) As String Dim H As String H = Hex(Number) If Len(H) < NumLen Then H = String(NumLen - Len(H), "0") & H End If toHex = H End Function