vb.net窗体椭圆代码 vb中窗体是什么意思

vb.net中绘制圆的代码是什么?

Dim myGraphics As Graphics = Me.CreateGraphics '声明并创建一个Graphics对象

成都创新互联公司专业为企业提供盱眙网站建设、盱眙做网站、盱眙网站设计、盱眙网站制作等企业网站建设、网页设计与制作、盱眙企业网站模板建站服务,十年盱眙做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

Dim myPen As Pen = New Pen(Drawing.Color.Black, 3) '声明一个画笔,并设定颜色和粗细

myPen.DashStyle = Drawing.Drawing2D.DashStyle.Solid '线型,Solid是实线

myGraphics.DrawEllipse(myPen, 200, 200, 100, 100) '画圆,数值依次是:横坐标、纵坐标、宽度和高度(宽高相同为正圆,否则为椭圆)

myGraphics.Dispose() '释放Graphics占用的资源

怎么用vb制作圆形窗体?

这是代码:Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, _

ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, _

ByVal hRgn As Long, ByVal bRedraw As Long) As LongPrivate Sub Form_Load()

Dim a, b As Long

Dim w, h As Long

w = Form1.Width / Screen.TwipsPerPixelX

h = Form1.Height / Screen.TwipsPerPixelY

a = CreateEllipticRgn(0, 0, w, h)

b = SetWindowRgn(Me.hWnd, a, True) '设置椭圆形窗体

End Sub

Private Sub Form_Activate()

Picture1(0).Visible = True

End SubPrivate Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

Picture1(0).Visible = False

Picture1(1).Visible = False

Picture1(2).Visible = False

Picture1(3).Visible = False

Select Case Index

Case Is = 0

Picture1(0).Visible = True '鼠标所在位置图形突起

Case Is = 1

Picture1(1).Visible = True '鼠标所在位置图形突起

Case Is = 2

Picture1(2).Visible = True '鼠标所在位置图形突起

Case Is = 3

Picture1(3).Visible = True '鼠标所在位置图形突起

End Select

End SubPrivate Sub Picture1_Click(Index As Integer)

End

End Sub

如何用VB.NET画同心圆

窗体上添加一个按钮,在该按钮的单击事件里编写代码如下:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'声明窗体的Me.CreateGraphics对象

Dim MyGraphics As Graphics = Me.CreateGraphics

Dim Cx As Integer = 150 '圆心的X坐标

Dim Cy As Integer = 150 '圆心的Y坐标

Dim R As Integer '圆的半径

'绘制半径为R的圆

For R = 5 To 100 Step 5

MyGraphics.DrawEllipse(Pens.Black, New Rectangle(Cx - R, Cy - R, 2 * R, 2 * R))

Next

End Sub

‘用黑色画笔绘制一组同心圆,半径从5开始,增量为5。

说明:

DrawEllipse是VB.Net的Graphics类的绘制椭圆的方法;他有几种格式,上面使用的是一种;

DrawEllipse(画笔的颜色,绘制椭圆所需要的矩形区域)

其中:绘制椭圆所需要的矩形区域,如果被定义为正方形,就演变成绘制圆,定义该区域由死个数值确定,第1个数值,确定该区域左上角的X坐标,第2个数值,确定该区域左上角的Y坐标,第3个数值,确定该区域的宽度,第4个数值,确定该区域的高度。

例如1:

DrawEllipse(Pens.Black, New Rectangle(150, 150, 50, 50))

就是以圆心坐标为(100,100),绘制半径为50 的圆。其实在VB.NET中,是告诉系统在以左上角坐标(150,150),边长为50的正方形里绘制内切圆。理解了是在正方形里绘制内切圆,就可以通过数学计算,知道如何绘制了。

同理例如2:

DrawEllipse(Pens.Black, New Rectangle(150, 150, 100, 50))

就是以圆心坐标为(100,100),绘制半径为50 的圆。其实在VB.NET中,是告诉系统在以左上角坐标(150,150),长轴为100,短轴为50的内切椭圆。


标题名称:vb.net窗体椭圆代码 vb中窗体是什么意思
分享网址:http://azwzsj.com/article/doegghh.html