掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
円を描画するには? (ID:143168)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
'円のところは、自分で改良出来ますよね? 'comboboxを追加して動かしてみてください。 Dim Bolder As Integer Dim Drawflag As Boolean Dim X As Integer Dim Y As Integer Dim aX As Integer Dim aY As Integer Dim g As Graphics Dim DrawMode As Integer Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown DrawMode = Val(ComboBox1.Text) Drawflag = True '旗を揚げる X = e.X Y = e.Y aX = e.X aY = e.Y End Sub Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove If Drawflag = True Then Bolder = 5 '線の太さ Dim myPen As New Pen(Color.Black, Bolder) Dim myClear As New Pen(PictureBox1.BackColor, 15) If DrawMode = 0 Then g.DrawLine(myClear, X, Y, e.X, e.Y) ElseIf DrawMode = 1 Then g.DrawLine(myPen, X, Y, e.X, e.Y) ElseIf DrawMode = 2 Then g.DrawEllipse(myPen, X, Y, 30, 30) End If X = e.X Y = e.Y End If End Sub Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp If DrawMode = 2 And Drawflag = True Then Dim pPen = New Pen(Color.Red, Bolder) g.DrawEllipse(pPen, CInt((e.X + aX) / 2), CInt((e.Y + aY) / 2), e.X - aX, e.Y - aY) 'g.DrawEllipse(pPen, aX, aY, e.X - aX, e.Y - aY) 'X - aX, Y - aY) End If Drawflag = False End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Items.Add("0") ComboBox1.Items.Add("1") ComboBox1.Items.Add("2") g = PictureBox1.CreateGraphics End Sub
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.