Const ALTERNATE = 1
成都創(chuàng)新互聯(lián)公司主要從事做網(wǎng)站、成都網(wǎng)站制作、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)忻城,十載網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):18982081108
Const WINDING = 2
Private Type POINTAPI
X As Long
Y As Long
End Type
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 CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function PtInRegion Lib "gdi32" (ByVal hRgn As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function FillRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long
Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Dim hRegion As Long
Dim hBrush As Long
Dim pic1 As New StdPicture
Private Sub Command1_Click()
Call FillRgn(Me.hdc, hRegion, hBrush)
End Sub
Private Sub Form_Load()
Dim p(8) As POINTAPI
Me.ScaleMode = 3
p(0).X = 100: p(0).Y = 100
p(1).X = 150: p(1).Y = 70
p(2).X = 110: p(2).Y = 70
p(3).X = 110: p(3).Y = 30
p(4).X = 50: p(4).Y = 30
p(5).X = 50: p(5).Y = 70
p(6).X = 30: p(6).Y = 70
p(7).X = 30: p(7).Y = 85
p(8).X = 85: p(8).Y = 85
hRegion = CreatePolygonRgn(p(0), 9, ALTERNATE)
hBrush = CreateSolidBrush(RGB(255, 0, 0))
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If PtInRegion(hRegion, X, Y) Then
Debug.Print "In 在多邊形區(qū)域"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
DeleteObject hRegion
DeleteObject hBrush
End Sub
可以用line填充,像這樣:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_Click()
sp = Me.DrawWidth * 15
For i = 0 To 1000 Step sp
Line (i, 0)-(i, 1000), vbRed
DoEvents
Sleep 20
Next
End Sub
調(diào)整drawwidth可以設(shè)置填充快慢,比如大半徑為r1,小半徑r2,那么r2的填充線寬度為drawwidth*r2/r1
Line 方法
在對(duì)象上畫直線和矩形。
語(yǔ)法
object.Line [Step] (x1,1) [Step] (x2,y2), [color], [B][F]
Line 方法的語(yǔ)法有以下對(duì)象限定符和部分:
部分 描述
object 可選的。 對(duì)象表達(dá)式,其值為“應(yīng)用于”列表中的對(duì)象。如果object 省略,具有焦點(diǎn) 的 窗體作為object。
Step 可選的。關(guān)鍵字,指定起點(diǎn)坐標(biāo),它們相對(duì)于由CurrentX 和 CurrentY 屬性提供的當(dāng)前圖形位置。
(x1, y1) 可選的。Single (單精度浮點(diǎn)數(shù)),直線或矩形的起點(diǎn)坐標(biāo)。ScaleMode 屬性決定了使用的度量單位。如果省略,線起始于由 CurrentX 和 CurrentY 指示的位置。
Step 可選的。關(guān)鍵字,指定相對(duì)于線的起點(diǎn)的終點(diǎn)坐標(biāo)。
(x2, y2) 必需的。Single (單精度浮點(diǎn)數(shù)),直線或矩形的終點(diǎn)坐標(biāo)。
color 可選的。Long (長(zhǎng)整型數(shù)),畫線時(shí)用的 RGB 顏色。如果它被省略,則使用ForeColor 屬性值??捎?RGB 函數(shù)或 QBColor 函數(shù)指定顏色。
B 可選的。如果包括,則利用對(duì)角坐標(biāo)畫出矩形。
F 可選的。如果使用了B 選項(xiàng),則 F 選項(xiàng)規(guī)定矩形以矩形邊框的顏色填充。不能不用 B 而用 F。如果不用 F 光用 B,則矩形用當(dāng)前的 FillColor 和 FillStyle 填充。FillStyle 的缺省值為 transparent。
說(shuō)明
畫聯(lián)結(jié)的線時(shí),前一條線的終點(diǎn)就是后一條線的起點(diǎn)。
線的寬度取決于DrawWidth 屬性值。在背景上畫線和矩形的方法取決于 DrawMode 和 DrawStyle 屬性值。
執(zhí)行Line 方法時(shí), CurrentX 和 CurrentY 屬性被參數(shù)設(shè)置為終點(diǎn)。
這個(gè)方法不能用于With...End With 語(yǔ)句塊。
網(wǎng)頁(yè)題目:vb.net多邊形填充 vb求多邊形面積
分享鏈接:http://www.rwnh.cn/article22/dopppjc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣、網(wǎng)站營(yíng)銷、服務(wù)器托管、微信小程序、響應(yīng)式網(wǎng)站、搜索引擎優(yōu)化
聲明:本網(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)