Wednesday 7 May 2014

Mouse point Image Colour Vb programe

A method to get the pixel color under the mouse pointer
'A method to get the pixel color under the mouse pointer
option Explicit
'private Type POINTAPI
'x as Long
'y as Long
'End Type
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 Sub Form_Load()
'Timer1.Interval = 100
'End Sub

private Sub Timer1_Timer()
Dim tPOS as POINTAPI
Dim sTmp as string
Dim lColor as Long
Dim lDC as Long
'lDC = GetWindowDC(0)
'Call GetCursorPos(tPOS)
'lColor = GetPixel(lDC, tPOS.x, tPOS.y)
'Label2.BackColor = lColor
sTmp = Right$("000000" & Hex(lColor), 6)
Caption = "R:" &Right$(sTmp, 2) & " G:" &mid$(sTmp, 3, 2) & " B:" & Left$(sTmp, 2)
msgbox  Caption
End Sub
VB script Object model


No comments:

Post a Comment