标题:[求助]Getdc,GetCursorPos,getpixel, 的使用问题....
取消只看楼主
miker99
Rank: 1
等 级:新手上路
帖 子:45
专家分:0
注 册:2006-9-13
 问题点数:0 回复次数:0 
[求助]Getdc,GetCursorPos,getpixel, 的使用问题....


这里有个问题..为什么 我的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







搜索更多相关主题的帖子: GetCursorPos Getdc getpixel 
2006-09-17 13:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-90782-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.114765 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved