VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > VB.net教程 >
  • vb.net2019-获取键盘信号

Public Class Form1
    Dim beginDraw As Boolean
    Dim m_ptNow As Point = New Point(0, 0)

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        beginDraw = False
    End Sub
    Private Sub PictureBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseMove
        If My.Computer.Keyboard.CtrlKeyDown Then
            beginDraw = True
        Else
            beginDraw = False
        End If
        If beginDraw Then
            m_ptNow.X = e.X
            m_ptNow.Y = e.Y
            Me.PictureBox1.Refresh()
        End If
    End Sub

    Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
        If beginDraw Then
            e.Graphics.DrawEllipse(Pens.Red, m_ptNow.X, m_ptNow.Y, 50, 50)
        End If
    End Sub

End Class
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

在按下ctrl键后,随着鼠标移动,在鼠标移动处画圆 在这里插入图片描述


相关教程