在窗體上拉一個(gè)Timer控件,enabled設(shè)為true,Interval設(shè)為20。完整代碼如下: Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)

成都創(chuàng)新互聯(lián)專注于成都做網(wǎng)站、成都網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站制作、網(wǎng)站開發(fā)。公司秉持“客戶至上,用心服務(wù)”的宗旨,從客戶的利益和觀點(diǎn)出發(fā),讓客戶在網(wǎng)絡(luò)營(yíng)銷中找到自己的駐足之地。尊重和關(guān)懷每一位客戶,用嚴(yán)謹(jǐn)?shù)膽B(tài)度對(duì)待客戶,用專業(yè)的服務(wù)創(chuàng)造價(jià)值,成為客戶值得信賴的朋友,為客戶解除后顧之憂。
Dim formGraphics As System.Drawing.Graphics
Dim num As Integer = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Refresh() '清屏
formGraphics = Me.CreateGraphics()
formGraphics.DrawEllipse(myPen, New Rectangle(100, 100, num, num)) '在坐標(biāo)(100,100)的位置畫圓
If num 200 Then '如果大于200則停止畫圓
myPen.Dispose()
formGraphics.Dispose()
Timer1.Enabled = False
Else
num = num + 1
End If
End Sub
VB.net與VB不同。
VB.net已經(jīng)有專門繪圖的類。
可以定義筆刷然后用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
Paint事件是在控件需要重畫時(shí)發(fā)生,就比如說(shuō)窗體的Paint事件,只要窗體被其他窗口覆蓋后又被重新顯示時(shí)就會(huì)觸發(fā)Paint事件
沒(méi)有看到其他代碼,暫無(wú)法判斷哪里有問(wèn)題
希望回答對(duì)你有幫助
參考一下下面這段代碼:
‘?首先picturebox1?加載一張圖像
FolderBrowserDialog1.Description?=?"選擇圖片文件夾導(dǎo)入圖片"
FolderBrowserDialog1.ShowDialog()
path?=?FolderBrowserDialog1.SelectedPath()
If?path?=?""?Then?Return
strSrcFile?=?Dir(path??"\*.tif")
PictureBox1.Image?=?Image.FromFile(path??"\"??strSrcFile)
’??然后再在picturebox1中用graphic畫圖而不清空原圖像
'?建立一個(gè)畫圖對(duì)象
Dim?g?As?Graphics?=?Me.PictureBox1.CreateGraphics
‘?定義畫筆
Dim?myPen?As?System.Drawing.Pen?=?New?System.Drawing.Pen(Color.Blue)
’?畫出矩形框并且填充顏色(顏色保持50%的透明度,使得下面原來(lái)的圖片背景能看得到)
g.DrawRectangle(myPen,?New?System.Drawing.Rectangle(50,?50,?30,?20))
g.FillRectangle(New?SolidBrush(Color.FromArgb(50,?Color.YellowGreen)),?New?System.Drawing.Rectangle(50,?50,?30,?20))
'?最后釋放畫圖對(duì)象
g.Dispose()
效果大致如下圖所示:
dim myGraphics as new
System.Drawing .Graphics
Dim myStartPoint As New Point(4, 2)
Dim myEndPoint As New Point(12, 6)
myGraphics.DrawLine(myPen, myStartPoint, myEndPoint)
當(dāng)前題目:包含vb.netmypen的詞條
標(biāo)題來(lái)源:http://chinadenli.net/article33/dsephps.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、面包屑導(dǎo)航、網(wǎng)站策劃、網(wǎng)站設(shè)計(jì)公司、關(guān)鍵詞優(yōu)化、微信公眾號(hào)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容