问题已经解决
谢谢大家的帮忙
尤其是斑竹,
还有各位高人,
我在使用getpixel的时候为什么总是返回-1
我的代码如下
窗体空件有:
3 个text
1 个timer
'模块声明
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 dc as long
Private Sub Timer1_Timer()
Dim hwnd As Long
Dc = GetCursorPos(pt) '获得鼠标的当前位置
hwnd = FindWindow(vbNullString, "计算器") '获得计算器的句柄
tmp = GetPixel(hwnd, pt.x, pt.y) '取得当前鼠标点的颜色
Text1.Text = " 计算器的句柄是 " & hwnd
Text2.Text = "当前颜色返回的长整形变量值是 " & tmp
Text3.Text = "pt的 X 值 是" & pt.x & " PT的 Y 值是" & pt.y
End Sub
我要获得"计算器"的某一点颜色,但总是-1
应当怎么做?
请指教.
最好VB的代码
[此贴子已经被作者于2006-9-19 2:05:39编辑过]