首页 > 上网技巧 > 电脑小技巧 > 正文

取色器工具源码

时间:2013-10-16 09:11 作者:admin 我要评论

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function getpixel Lib "gdi32" Alias "GetPixel" (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
Dim p As POINTAPI
 
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1
Private Const HWND_TOP = 0
Private Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
 
Dim rtn As Long
 
 
Private Sub Form_Load()
Timer1.Enabled = True
Me.AutoRedraw = True
Me.BackColor = vbBlack
Me.ForeColor = vbRed
rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
SetWindowLong Me.hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes Me.hwnd, vbBlack, 180, LWA_COLORKEY Or LWA_ALPHA
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
 
Private Sub Timer1_Timer()
GetCursorPos p
hd = GetDC(0)
r = getpixel(hd, p.X, p.Y)
Label4.Caption = r
csr = CStr(Hex(r))
t = Len(csr)
Select Case t
Case 1
sr = "00000" & csr
Case 2
sr = "0000" & csr
Case 3
sr = "000" & csr
Case 4
sr = "00" & csr
Case 5
sr = "0" & csr
Case 6
sr = csr
End Select
Label1.Caption = " &&H" & sr
Picture1.BackColor = r
End Sub

标签: 源码
顶一下
(2)
100%
踩一下
(0)
0%

Google提供的广告