vb.netgdi表盘 vbnet tablelayoutpanel
vb.net GDI绘图刷新问题
绘图代码写在Paint事件中,如
创新互联专业为企业提供芒市网站建设、芒市做网站、芒市网站设计、芒市网站制作等企业网站建设、网页设计与制作、芒市企业网站模板建站服务,十余年芒市做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim g As Graphics = Me.CreateGraphics
g.DrawLine(Pens.Red, 100, 100, 200, 100)
End Sub
'方法二:在 PictureBox1上显示图像----图画在Bitmap
PictureBox1.Image = Nothing
Dim wid As Integer = PictureBox1.ClientSize.Width
Dim hgt As Integer = PictureBox1.ClientSize.Height
Dim bm As New Bitmap(wid, hgt)
Dim g As Graphics = Graphics.FromImage(bm)
'画图代码
'画图代码
PictureBox1.Image = bm
PictureBox1.Refresh()
g.Dispose()
VB用GDI使桌面时钟指针图片PNG旋转!
'秒、分、时
Dim Second, Minute, Hour As Integer
'表的中心位置
Dim X0, Y0 As Integer
'
Dim X, Y As Variant
Private Sub Form_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
'按下鼠标左键
If Button = 1 Then
'鼠标指针在表盘内
If X X0 - 950 And X X0 + 950 Then
If Y Y0 - 950 And Y Y0 + 950 Then
'移动表的位置
X0 = X
Y0 = Y
End If
End If
End If
Form1.Refresh
End Sub
Sub Form_Load()
'设置表的中心位置
Let X0 = 1100
Let Y0 = 1100
'时刻与对应坐标的转换表
X = Array(0, 104, 207, 309, 406, 500, 587, _
669, 743, 809, 866, 913, 951, 978, 994, 1000, _
994, 978, 951, 913, 866, 809, 743, 669, 587, 500, 406, 309, 207, 104, 0, -105, -208, -310, -407, -500, -588, -670, -744, -810, -867, -914, -952, -979, -995, -1000, -995, -979, -952, -914, -867, -810, -744, -670, -588, -500, -407, -310, -208, -105, -1)
Y = Array(1000, 994, 978, 951, 913, 866, 809, 743, 669, 587, 500, 406, 309, 207, 104, 0, -105, -208, -310, -407, -500, -588, -670, -744, -810, -867, -914, -952, -979, -995, -1000, -995, -979, -952, -914, -867, -810, -744, -670, -588, -500, -407, -310, -208, -105, -1, 104, 207, 309, 406, 500, 587, 669, 743, 809, 866, 913, 951, 978, 994, 1000)
'初始化定时器
Timer1.Enabled = True
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
'绘制表盘
Circle (X0, Y0), 950, RGB(255, 255, 255)
'绘制刻度
DrawPlots
'定位时、分、秒针的起点
Line1.X1 = X0
Line1.Y1 = Y0
Line2.Y1 = Y0
Line2.X1 = X0
Line3.X1 = X0
Line3.Y1 = Y0
'秒
Second = Mid(Time, 7, 2)
'分
Minute = Mid(Time, 4, 2)
'时
Hour = Mid(Time, 1, 2)
If Hour 11 Then Hour = Hour - 12
Hour = Hour * 5 + (Hour / 12)
'定位时、分、秒针的终点
Line1.X2 = X(Second) * 0.9 + X0
Line1.Y2 = Y0 - Y(Second) * 0.9
Line2.X2 = X(Minute) * 0.8 + X0
Line2.Y2 = Y0 - Y(Minute) * 0.8
Line3.X2 = X(Hour) * 0.4 + X0
Line3.Y2 = Y0 - Y(Hour) * 0.4
End Sub
'绘制刻度
Sub DrawPlots()
For xx = 0 To 60
If (xx Mod 5) = 0 Then
Line (X(xx) + X0, Y(xx) + Y0)-(X(xx) * 1.1 + X0, Y(xx) * 1.1 + Y0), RGB(256, 256, 256)
End If
Next xx
End Sub 希望可以帮到你.!
怎样用vb.net作一个指针转动的钟表?(可设置时间日期,有闹铃功能)
你需要会用GDI+,也就是那个System.Drawing命名空间下的类.
给你说个思路,设Timer,到时间就用Form.Invalidate()函数重画窗口,在重画窗口的Form_Paint事件下面编写代码得到当前时间,再根据当前时间用GDI+画时钟.
分享题目:vb.netgdi表盘 vbnet tablelayoutpanel
文章路径:http://azwzsj.com/article/doggpeg.html