vb.net 如何获取鼠标点的RGB?

hyb2cs 2017-11-28 02:20:14
vb.net 如何获取鼠标点的RGB?求源码。
...全文
944 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
清晨曦月 元老 2018-01-04
  • 打赏
  • 举报
回复
哈,其实那啥,vb.net也不是不能直接做。写一个简单的演示,然后鼠标在窗体上按下,随便拖动。。。。。。。 dim bmp as new bitmap(1,1) dim g as graphics=graphics.fromimage(bmp) private sub form1_mousemove(s as object,e as mouseeventargs)handles me.mousemove g.copyFromScreen(PointooScreen(e.Location), Point.Empty, New Size(1, 1), CopyPixelOperation.SourceCopy) Debug.Print(bmp.GetPixel(0, 0).ToString) end sub 哦,这就可以了。。。大约还是把pointtoscreen(e.location)直接换成mouseposition比较好。。。。
NewScar 2017-12-29
  • 打赏
  • 举报
回复
不错,学习了。当年在VB6时代也是如是操作的。
baidu_38121684 2017-12-20
  • 打赏
  • 举报
回复

    Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Integer) As Integer
    Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer) As Integer
    Private Function GetRGB() As Integer
          Dim ScreenDC = GetDC(0)
          Dim TheRGB = GetPixel(ScreenDC, MousePosition.X, MousePosition.Y)
          Return TheRGB
    End Function

hyb2cs 2017-11-28
  • 打赏
  • 举报
回复
大约也知道这个方法,但用VB.net怎么写?
  • 打赏
  • 举报
回复
看看这个通过winapi获取

16,552

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧