Imports System.Drawing Imports System.Windows.Forms Imports System.IO Imports System.Text Public Class Form1 Public k As String Public x As Long Public y As Long Public kchar As String Public m() As String Public xp() As Long Public yp() As Long Public key() As String Public cnt As Long Dim col As Color 'https://social.msdn.microsoft.com/Forums/ja-JP/4086f247-9821-4f94-a610-335428ea4629/brushescolor12392rgb12420argb1239833394124791245212503123982279325563 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.KeyPreview = True 'https://docs.microsoft.com/ja-jp/office/vba/api/access.form.keypreview 'http://rucio.cloudapp.net/ThreadDetail.aspx?ThreadId=30670 End Sub Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp Me.Text = $"MouseUp:{e.Button} , {e.Location}" cnt = cnt + 1 ReDim Preserve m(cnt), xp(cnt), yp(cnt), key(cnt) 'フォーム上の座標でマウスポインタの位置を取得する '画面座標でマウスポインタの位置を取得する Dim sp As System.Drawing.Point = System.Windows.Forms.Cursor.Position '画面座標をクライアント座標に変換する Dim cp As System.Drawing.Point = Me.PointToClient(sp) 'X座標を取得する Dim x As Integer = cp.X 'Y座標を取得する Dim y As Integer = cp.Y 'https://dobon.net/vb/dotnet/system/cursorposition.html Dim rc, gc, bc As Long If e.Button = MouseButtons.Left Then 'MsgBox(kchar & "クリックしました!(" & x & "," & y & ")") ' Me.CreateGraphics.Clear(Me.BackColor) m(cnt) = "L" col = Color.FromArgb(255, 0, 0) End If If e.Button = MouseButtons.Right Then 'MsgBox(kchar & "クリックしました!(" & x & "," & y & ")") ' Me.CreateGraphics.Clear(Me.BackColor) m(cnt) = "R" col = Color.FromArgb(0, 255, 0) End If key(cnt) = k xp(cnt) = x yp(cnt) = y 'https://dobon.net/vb/bbs/log3-46/27779.html Dim myBrush As New SolidBrush(col) myBrush.Color = Color.FromArgb(200, col) Dim g As Graphics = Me.CreateGraphics g.FillEllipse(myBrush, x - 5, y - 5, 10, 10) g.Dispose() 'http://hanatyan.sakura.ne.jp/dotnet/zu05.htm End Sub