求救大叔!!!为什么用polygon画多边形不能实现
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As pointapi, ByVal nCount As Long) As LongPrivate Type pointapi
X As Long
Y As Long
End Type
Dim xy(100) As pointapi
Dim npoint As Integer
Private Sub Pictfore_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
xy(npoint).X = X
xy(npoint).Y = Y
If npoint > 0 Then
Pictfore.Line (xy(npoint).X, xy(npoint).Y)-(xy(npoint - 1).X, xy(npoint - 1).Y), CommonDialog2.Color
npoint = npoint + 1
If npoint > 100 Then End
End If
End If
end sub
Private Sub Pictfore_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
xy(npoint).X = xy(0).X
xy(npoint).Y = xy(0).Y
If npoint > 1 Then
Pictfore.Line (xy(npoint).X, xy(npoint).Y)-(xy(npoint - 1).X, xy(npoint - 1).Y), CommonDialog2.Color
Pictfore.AutoRedraw = False
Polygon Pictfore.hdc, xy(0), npoint
npont = 0
Pictfore.AutoRedraw = True
End If
End If
end sub
可实现不出来!!!!跪谢。。。。 --------------------编程问答-------------------- Pictfore.AutoRedraw = True
一直使用它 --------------------编程问答-------------------- 顶 --------------------编程问答-------------------- 还是用不了啊,有点急,删去也不能用啊 --------------------编程问答-------------------- 我不是大叔,是个老婆婆。 --------------------编程问答--------------------
.. --------------------编程问答--------------------
哦,大妈求教一下 --------------------编程问答--------------------
老婆婆对蛋帖不敢兴趣 --------------------编程问答-------------------- npoint = npoint + 1 应该放在外面的一层循环中.(你的代码是没有触发此变量的自加)
如果用Polygon画,应该先创建笔刷!
--------------------编程问答-------------------- 我找的,实现了
Option Explicit
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, _
lpPoint As pointapi, ByVal nCount As Long) As Long
Private Type pointapi
X As Long
Y As Long
End Type
Dim xx(6) As pointapi
Dim npoint As Integer
Private Sub Form_Click()
Call Polygon(Picture1.hdc, xx(0), 7)
End Sub
Private Sub Form_Load()
Me.Show
xx(0).X = 0: xx(0).Y = 0
xx(1).X = 50: xx(1).Y = 0
xx(2).X = 50: xx(2).Y = 50
xx(3).X = 0: xx(3).Y = 50
xx(4).X = 5: xx(4).Y = 25
xx(5).X = 122: xx(5).Y = 111
xx(6).X = 111: xx(6).Y = 111
End Sub
但是如果将Call Polygon(Picture1.hdc, xx(0), 7)放在FORM_LOAD中就不会实现。
补充:VB , 基础类