当前位置:网站首页>VB. Net class library to obtain the color under the mouse in the screen (Advanced - 3)
VB. Net class library to obtain the color under the mouse in the screen (Advanced - 3)
2022-06-26 21:56:00 【Xiaoyu 163】
In the solution :
Create a new one new class:myScreen

quote :
One more this time System.Windows.Forms, Because we need to use button event
Then write the three segment function
Public Class myScreen
Public Image As Bitmap
Private ispick As Boolean = False
Private bmp As Bitmap
Private g As Graphics
''' <summary>
''' Be careful , Please do not call this function alone , also , This function corresponds to button The event is MouseDown. Get the mouse status and return the mouse style
''' </summary>
''' <param name="e"> Mouse events , It's the left key </param>
''' <param name="cur"> Incoming mouse style , And returns a mouse style of Cross</param>
''' <returns></returns>
Public Function PickColorDown(e As MouseEventArgs, cur As Cursor)
If e.Button = MouseButtons.Left Then
ispick = True
Dim scr As Screen = Screen.PrimaryScreen
Dim recSc As Rectangle = scr.Bounds
bmp = New Bitmap(recSc.Width, recSc.Height)
g = Graphics.FromImage(bmp)
g.CopyFromScreen(New Point(0, 0), New Point(0, 0), New Size(recSc.Width, recSc.Height))
cur = Cursors.Cross
Return cur
End If
End Function
''' <summary>
''' Be careful , Please do not call this function alone , also , This function corresponds to button The event is MouseMove. Get the mouse condition and return the color of the mouse pointer area
''' </summary>
''' <param name="e"> Mouse events </param>
''' <param name="but"> obtain button</param>
''' <returns></returns>
Public Function PickColorMove(e As MouseEventArgs, but As Button)
Dim x, y As Integer
Dim p As Point = New Point(e.X, e.Y)
Dim colorpoint As Color
If ispick = True Then
x = but.PointToScreen(p).X
y = but.PointToScreen(p).Y
colorpoint = bmp.GetPixel(x, y)
Return colorpoint
End If
End Function
''' <summary>
''' Be careful , Please do not call this function alone , also , This function corresponds to button The event is MouseUp. Get the mouse status and return the mouse style
''' </summary>
''' <param name="cur"> Incoming mouse style , And returns a mouse style of Default</param>
''' <returns></returns>
Public Function PickColorUp(cur As Cursor)
ispick = False
cur = Cursors.Default
Return cur
End Function
End ClassHere is a reference VB.net Big guy's article .
Call on form :
in front : Make a statement myScreen Class
Public GDIscr As New GDI_Make_NET4_5.myScreenCode in :
Private Sub Button3_MouseDown(sender As Object, e As MouseEventArgs) Handles Button3.MouseDown
Cursor = GDIscr.PickColorDown(e, Cursor)
End Sub
Private Sub Button3_MouseMove(sender As Object, e As MouseEventArgs) Handles Button3.MouseMove
Pic.BackColor = GDIscr.PickColorMove(e, Button3)
End Sub
Private Sub Button3_MouseUp(sender As Object, e As MouseEventArgs) Handles Button3.MouseUp
Cursor = GDIscr.PickColorUp(Cursor)
End Sub have a look :
边栏推荐
- 「连续学习Continual learning, CL」最新2022研究综述
- 360 mobile assistant is the first to access the app signature service system to help distribute privacy and security
- 指南针能开户炒股吗?安全吗?
- leetcode:1567. 乘积为正数的最长子数组长度【dp[i]表示以i结尾的最大长度】
- Comprehensive evaluation of online collaboration documents: note, flowus, WOLAI, Feishu, YuQue, Microsoft office, Google Docs, Jinshan docs, Tencent docs, graphite docs, Dropbox paper, nutcloud docs,
- Unity 设置Material、Shader的方法
- Android mediacodec hard coded H264 file (four), ByteDance Android interview
- 网络爬虫终篇:向10万级网易云用户发送定向消息
- MacOS环境下使用HomeBrew安装[email protected]
- Flutter 中 ValueNotifier<List<T>> 监听问题解决
猜你喜欢

2022年,中轻度游戏出海路在何方?

MATLAB与Mysql数据库连接并数据交换(基于ODBC)
![leetcode:710. Random numbers in the blacklist [mapping thinking]](/img/ec/a3faeae6636bc3d0d9536962fdd9af.png)
leetcode:710. Random numbers in the blacklist [mapping thinking]

Introduction of classic wide & deep model and implementation of tensorflow 2 code

Godson China Science and technology innovation board is listed: the market value is 35.7 billion yuan, becoming the first share of domestic CPU

vulnhub之dc8

Using C to operate SQLSERVER database through SQL statement tutorial

Comprehensive evaluation of online collaboration documents: note, flowus, WOLAI, Feishu, YuQue, Microsoft office, Google Docs, Jinshan docs, Tencent docs, graphite docs, Dropbox paper, nutcloud docs,

KDD2022 | 基于知识增强提示学习的统一会话推荐系统

用C#通过sql语句操作Sqlserver数据库教程
随机推荐
CVPR 2022 | 美团技术团队精选论文解读
Is it safe to buy stocks and open accounts through the account QR code of the CICC securities manager? Want to open an account for stock trading
Release of dolphin scheduler video tutorial in Shangsi Valley
How to analyze financial expenses
Web crawler 2: crawl the user ID and home page address of Netease cloud music reviews
DAST black box vulnerability scanner part 5: vulnerability scanning engine and service capability
Common concurrent testing tools and pressure testing methods
DAST 黑盒漏洞扫描器 第五篇:漏洞扫描引擎与服务能力
Chapter 2 construction of self defined corpus
Module 5 operation
网络爬虫2:抓取网易云音乐评论用户ID及主页地址
Usage of MGrid in numpy
【题解】剑指 Offer 15. 二进制中1的个数(C语言)
Is this a bug? Whether the randomly filled letters can be closed
[fundamentals of image processing] GUI image curve adjustment system based on MATLAB [including Matlab source code 1923]
在哪家券商公司开户最方便最安全可靠
DLA模型(分类模型+改进版分割模型) + 可变形卷积
leetcode:1567. 乘积为正数的最长子数组长度【dp[i]表示以i结尾的最大长度】
leetcode:6103. Delete the minimum score of the edge from the tree [DFS + connected component + value record of the subgraph]
Talk about my remote work experience | community essay solicitation