这里有个问题..为什么 我的text1.text 内的值总是 在变化的呢?????
这样运行时间长了,会不回有问题?
另外,在使用API函数后,需要手动释放么??????????
高手给小弟解答下.
谢谢...
'*****************************************
'模块声明部分.
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Type POINTAPI
x As Long
y As Long
End Type
*********************************************
'窗体部分
*********************************************
Dim pt As POINTAPI
Dim tmp As Long
Dim My_getdc As Long
Private Sub Timer1_Timer()
My_getdc = GetDC(0) ' 获取当前屏幕的句柄
dc = GetCursorPos(pt) '获得鼠标的当前位置
tmp = GetPixel(My_getdc, pt.x, pt.y) '取得当前鼠标点的颜色
Text1.Text = " 屏幕的句柄是 " & my_getdc
Text2.Text = "当前颜色返回的长整形变量值是 " & tmp
Text3.Text = "当前鼠标的 X 值 是" & pt.x & " 当前鼠标的 Y 值是" & pt.y
End Sub
*******************************************************
控件列表
3 个text
1 个timer