真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb點(diǎn)虐 鐘表控件 vbs時(shí)鐘代碼

vb 點(diǎn)虐 動(dòng)態(tài)創(chuàng)建Timer控件

我從來(lái)不加到Controls中也能用,大概這個(gè)不是從Control繼承而來(lái)的,所有非可視部件(漏信慶即組返握件)估計(jì)坦螞都不需要add。

創(chuàng)新互聯(lián)建站專注于龍崗網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供龍崗營(yíng)銷型網(wǎng)站建設(shè),龍崗網(wǎng)站制作、龍崗網(wǎng)頁(yè)設(shè)計(jì)、龍崗網(wǎng)站官網(wǎng)定制、成都小程序開(kāi)發(fā)服務(wù),打造龍崗網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供龍崗網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。

vb點(diǎn)虐 開(kāi)發(fā)簡(jiǎn)單的時(shí)鐘程序??高手救救我!

個(gè)

Hand類的代碼:

Public MustInherit Class Hand

Protected gp As GraphicsPath = New GraphicsPath()

Protected gpBase As GraphicsPath = Nothing

Protected midX As Integer = 150 ‘默認(rèn)的窗體

Protected midY As Integer = 150 ‘中心位置

‘構(gòu)造器,得到窗體中心位置

Public Sub New(ByVal theForm As Form1)

midX = (theForm.ClientRectangle.Left + theForm.ClientRectangle.Right) / 2

midY = (theForm.ClientRectangle.Top + theForm.ClientRectangle.Bottom) / 2

End Sub

MustOverride Sub Transform(ByVal d As DateTime)

‘繪制指針路徑

Overridable Sub Draw(ByVal g As Graphics)

Dim aPen As Pen = New Pen(Brushes.Black, 4F)

g.DrawPath(aPen, gp)

g.FillPath(Brushes.Black, gp)

aPen.Dispose()

End Sub

‘使用矩陣實(shí)現(xiàn)路徑(gp)的旋轉(zhuǎn)

Public Sub Rotate(ByVal angle As Double)

gp = CType(gpBase.Clone(), GraphicsPath)

Dim mTransform As Matrix = New Matrix()

mTransform.RotateAt(CType(angle,Single),NewPointF(midX,midY))

gp.Transform(mTransform)

End Sub

End Class

為了節(jié)省篇幅,上面的代碼省略了引入命名空間的語(yǔ)句。

下面是分針(MinuteHand)類的定義:

Public Class MinuteHand

Inherits Hand

‘構(gòu)造器,生成繪制分針的路徑(gp)

Public Sub New(ByVal myForm As Form1)

MyBase.New(myForm)

gp.AddLine(midX, midY, midX, 45)

gp.AddLine(midX, 45, midX - 3, 50)

gp.AddLine(midX - 3, 50, midX + 3, 50)

gp.AddLine(midX + 3, 50, midX, 45)

gpBase = CType(gp.Clone(), GraphicsPath)

End Sub

‘Transform方法取得系統(tǒng)當(dāng)前時(shí)間,并旋轉(zhuǎn)時(shí)鐘指針。

Public Overrides Sub Transform(ByVal d As DateTime)

Dim minuteTime As Double = (CDbl(d.Minute) + CDbl(d.Second / 60))

Dim angle As Double = (CDbl(minuteTime) / 60) * 360

Rotate(angle)

End Sub

End Class

對(duì)所有的指針旋轉(zhuǎn)的方法都是相同的,因此在基類中實(shí)現(xiàn)。由于時(shí)針和秒針的實(shí)沖絕現(xiàn)與分針相似,所不同者,只在于構(gòu)造器中繪制的指針路徑不同和Transform方法中轉(zhuǎn)動(dòng)的角度不同,在局哪這里就不在贅述了。

另外還需要提一下的是畫時(shí)鐘表面的代碼,時(shí)鐘表面用ClockFace類來(lái)實(shí)現(xiàn)。這個(gè)類首先畫一個(gè)圓代表時(shí)鐘,然后畫上米老鼠的圖案,最后在相應(yīng)的桐判碼位置畫上數(shù)字1~12代表12個(gè)小時(shí)。

Public Sub Draw(ByVal g As Graphics)

DrawClockFace(g)

DrawImage(g)

DrawNumbers(g)

DrawPin(g)

End Sub

下面是ClockFace類的屬性:

Private ClockRectangle As Rectangle

Private ClockFont As Font = New Font("Arial", 12)

Private midPoint As Point

Private ClockImage As Bitmap

Private Const IMAGEX As Integer = 50

Private Const IMAGEY As Integer = 50

DrawClockFace方法用來(lái)畫時(shí)鐘表面:

Private Sub DrawClockFace(ByVal g As Graphics)

g.FillEllipse(Brushes.White, ClockRectangle.Left + 10, ClockRectangle.Top + 10, ClockRectangle.Width - 20, ClockRectangle.Height - 20)

g.DrawEllipse(Pens.Black, ClockRectangle.Left + 10, ClockRectangle.Top + 10, ClockRectangle.Width - 20, ClockRectangle.Height - 20)

End Sub

然后用Graphics對(duì)象的DrawImage方法畫出米老鼠的圖片:

Private Sub DrawImage(ByVal g As Graphics)

Dim nWidth As Integer = ClockImage.Width

Dim nHeight As Integer = ClockImage.Height

Dim destRect As Rectangle = New Rectangle(midPoint.X - IMAGEX / 2, midPoint.Y - IMAGEY / 2, IMAGEX, IMAGEY)

g.DrawImage(ClockImage, destRect)

End Sub

數(shù)字在時(shí)鐘上的位置是用sin和cos函數(shù)計(jì)算的:

Private Sub DrawNumbers(ByVal g As Graphics)

Dim count As Integer = 1

Dim a As Double

For a = 0 To 2 * Math.PI Step 2 * Math.PI / 12

Dim x As Double = (ClockRectangle.Width - 70) / 2 * Math.Cos(a - Math.PI / 3) + (ClockRectangle.Width - 70) / 2 + 25

Dim y As Double = (ClockRectangle.Width - 70) / 2 * Math.Sin(a - Math.PI / 3) + (ClockRectangle.Width - 70) / 2 + 20

g.DrawString(Convert.ToString(count), ClockFont, Brushes.Black, CType(x, Single), CType(y, Single), New StringFormat())

count += 1

Next

End Sub

最后是窗體文件(Form1.vb):

Public Class Form1

Inherits System.Windows.Forms.Form

Private MyMinuteHand As MinuteHand

Private MyHourHand As HourHand

Private MySecondHand As SecondHand

Private TheClockFace As ClockFace

Private FirstTick As Boolean = False

‘在窗體的OnPaint事件中取得Graphics對(duì)象

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

If (FirstTick = False) Then Exit Sub

Dim g As Graphics = e.Graphics

TheClockFace.Draw(g)

MyHourHand.Draw(g)

MyMinuteHand.Draw(g)

MySecondHand.Draw(g)

TheClockFace.DrawPin(g)

End Sub

‘計(jì)時(shí)器事件

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

MySecondHand.Transform(DateTime.Now)

MyHourHand.Transform(DateTime.Now)

MyMinuteHand.Transform(DateTime.Now)

FirstTick = True

Invalidate()

跪求用vb點(diǎn)虐 做一個(gè)小鬧鐘??!

'加個(gè)定瞎掘做時(shí)器,textbox ,button,label Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Label1.Text = Now

If FF = Now And FF "2001-1-1" And Timer1.Tag = "" Then

Timer1.Tag = "1"

MsgBox("ff")

End If

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

FF = TextBox1.Text

Timer1.Tag = ""

End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

FF = "散罩2001-1-1"

End Sub'聲音加個(gè) AxMMControl控件 AxMMControl1.DeviceType = "waveaudio" ''''''''定義播放*.wav格式 AxMMControl1.FileName = "c:\1.wav" ''''''''載入文件, AxMMControl1.Command = "open" ''''''''打開(kāi)載入的文件

AxMMControl1.From = 0 '從頭開(kāi)始

AxMMControl1.Command = "play"'保存時(shí)間,只要設(shè)定時(shí)把時(shí)間保存到文本文件就行,load 事件中磨衡讀取,并對(duì)比是不是超時(shí),.


本文名稱:vb點(diǎn)虐 鐘表控件 vbs時(shí)鐘代碼
網(wǎng)頁(yè)網(wǎng)址:http://weahome.cn/article/ddpiojd.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部