Už jsem na to přišel :)
Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
<StructLayout(LayoutKind.Sequential)> Private Structure POINTAPI
Dim x As Integer
Dim y As Integer
End Structure
Private Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Integer
Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Integer) As Integer
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer) As Integer
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim structCursorPosition As POINTAPI
Call GetCursorPos(structCursorPosition)
Dim lColor As Integer = GetPixel(GetDC(0), structCursorPosition.x, structCursorPosition.y)
BackColor = System.Drawing.ColorTranslator.FromOle(lColor)
Dim strRgb As String = VB.Right("000000" & Hex(lColor), 6)
Text = "R:" & VB.Right(strRgb, 2) & " G:" & Mid(strRgb, 3, 2) & " B:" & VB.Left(strRgb, 2)
End Sub
End Class
Ještě se sluší dodat zdroj: http://www.vbforums.com/showthread.php?t...
|