Barva mimo formulář

Postup:
Na formulář přidejte PictureBox, TextBox a Timer. Interval pro Timer nastavte na 10. Do deklarační části formuláře zapište:


Private Declare Function CreateDC& Lib "gdi32" _
   Alias "CreateDCA" (ByVal lpDriverName As String, _
   ByVal lpDeviceName As String, ByVal lpOutput As String, _
   lpInitData As Any)
Private Declare Function DeleteDC& Lib "gdi32" (ByVal hdc As Long)
Private Declare Function GetPixel Lib "gdi32" _
   (ByVal hdc As Long, ByVal x As Long, _
   ByVal y As Long) As Long

Private Type POINTAPI
   x As Long
   y As Long
End Type

Private Declare Function GetCursorPos Lib "user32" _
   (lpPoint As POINTAPI) As Long

Dim z As POINTAPI

Private Sub Timer1_Timer()

   GetCursorPos z
   screendc = CreateDC("DISPLAY", "", "", 0&)
   Text1 = Hex(GetPixel(screendc, z.x, z.y))
   
'text, zobrazený v TextBoxu je kódování barvy pro HTML
   Picture1.BackColor = GetPixel(screendc, z.x, z.y)
   DeleteDC (screendc)

End Sub

Zpět

Autor: The Bozena