📄 getposcolor.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1545
ClientLeft = 60
ClientTop = 345
ClientWidth = 4890
LinkTopic = "Form1"
ScaleHeight = 1545
ScaleWidth = 4890
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Interval = 300
Left = 4080
Top = 360
End
Begin VB.CommandButton Command1
Caption = "退出"
Height = 315
Left = 3840
TabIndex = 4
Top = 1020
Width = 855
End
Begin VB.Label Label5
BorderStyle = 1 'Fixed Single
Height = 795
Left = 180
TabIndex = 5
Top = 375
Width = 855
End
Begin VB.Label Label4
Caption = "Label4"
Height = 195
Left = 1418
TabIndex = 3
Top = 1125
Width = 2055
End
Begin VB.Label Label3
Caption = "Label3"
Height = 195
Left = 1418
TabIndex = 2
Top = 825
Width = 2055
End
Begin VB.Label Label2
Caption = "Label2"
Height = 195
Left = 1418
TabIndex = 1
Top = 525
Width = 2055
End
Begin VB.Label Label1
Caption = "Label1"
Height = 195
Left = 1418
TabIndex = 0
Top = 225
Width = 2055
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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" (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
Option Explicit
Dim z As PointApi
Private Sub Command1_Click()
End
End Sub
Private Sub Timer1_Timer()
Dim a, b, c, d As Long
GetCursorPos z
Label1.Caption = "点的位置:(" & z.x & "," & z.y & ")"
a = GetPixel(GetDC(0), z.x, z.y)
b = a And &HFF
c = (a And 65280) \ 256
d = (a And &HFF0000) \ 65536
Label2.Caption = "RGB颜色:(" & b & "," & c & "," & d & ")"
Label3.Caption = "16进制颜色:0x" & Hex(a)
Label4.Caption = "网页颜色:#" & Hex(a)
Label5.BackColor = RGB(b, c, d)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -