vb.net系统屏幕画图 vbs编写图形窗口
VB.net中如何画图?
分类: 电脑/网络 程序设计 其他编程语言
新蔡网站制作公司哪家好,找成都创新互联!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。成都创新互联2013年至今到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联。
问题描述:
VB6中的form1.circle (100,200),rgb(0,255,0)的语句如何在VB中使用啊?
急用啊!!!!!!!!
解析:
VB与VB不同。
VB已经有专门绘图的类。
可以定义笔刷然后用Drawing类中的方法绘制。
Private Sub DrawEllipse()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawEllipse(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
Private Sub DrawRectangle()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawRectangle(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
vb.net桌面中bitmap类如何直接绘制到屏幕?
可以直接显示的。你看下面的示例,使用vb.net画的齿轮:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
b = New Bitmap(PictureBox1.Width, PictureBox1.Height)
g = Graphics.FromImage(b)
'g.RotateTransform(90)
g.Clear(Color.White)
g.TranslateTransform(PictureBox1.Width / 2, PictureBox1.Height / 2)
g.ScaleTransform(1, -1)
'g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
DrawCL(g, New PointF(Val(TextBox1.Text), Val(TextBox2.Text)), Val(TextBox3.Text), Val(TextBox4.Text), Val(TextBox5.Text), Val(TextBox6.Text), Val(TextBox7.Text), Val(TextBox8.Text), Val(TextBox9.Text))
DrawCL(g, New PointF(Val(TextBox18.Text), Val(TextBox17.Text)), Val(TextBox16.Text), Val(TextBox15.Text), Val(TextBox14.Text), Val(TextBox13.Text), Val(TextBox12.Text), Val(TextBox11.Text), Val(TextBox10.Text))
PictureBox1.Image = b
End Sub
vb.net绘图问题
代码:
Public Class Form1
'*********************************************************************
'作者:章鱼哥,QQ:3107073263 群:309816713
'如有疑问或好的建议请联系我,大家一起进步
'*********************************************************************
'绘制圆角矩形函数
Private Function GetRoundedRectPath(ByVal rect As Rectangle, ByVal radius As Integer) As System.Drawing.Drawing2D.GraphicsPath
rect.Offset(-1, -1)
Dim RoundRect As New Rectangle(rect.Location, New Size(radius - 1, radius - 1))
Dim path As New System.Drawing.Drawing2D.GraphicsPath
path.AddArc(RoundRect, 180, 90) '左上角
RoundRect.X = rect.Right - radius '右上角
path.AddArc(RoundRect, 270, 90)
RoundRect.Y = rect.Bottom - radius '右下角
path.AddArc(RoundRect, 0, 90)
RoundRect.X = rect.Left '左下角
path.AddArc(RoundRect, 90, 90)
path.CloseFigure()
Return path
End Function
'绘制矩形
Private Sub DrawingRect()
Dim g As Graphics = Me.CreateGraphics
Dim Pen As New Pen(Brushes.DarkRed, 2)
Dim Hei As Integer = Me.Height
Dim Wid As Integer = Me.Width
'矩形的位置和长宽随着窗体的变化而改变
Dim Rec As New Rectangle(Int(Wid / 5), Int(Hei / 5), Int(Wid / 2), Int(Hei / 2))
' g.DrawRectangle(Pen, Rec)
'清楚现有的矩形
g.Clear(Me.BackColor)
g.DrawPath(Pen, GetRoundedRectPath(Rec, 30))
End Sub
Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
DrawingRect()
End Sub
Private Sub Form1_SizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
Me.Invalidate() '此函数可引发Paint事件
End Sub
End Class
效果截图:
原窗口:
缩小后:
分享标题:vb.net系统屏幕画图 vbs编写图形窗口
路径分享:http://pwwzsj.com/article/dosdphp.html