不太明白你的要求,是不是这样的?
Option Explicit
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Type POINTAPI
        X As Long
        Y As Long
End Type
Dim flag As Boolean
Dim pos() As POINTAPI
Dim i As Integer
Private Sub Form_Load()
flag = False
    Me.ScaleMode = 3
Me.AutoRedraw = False
i = 0
End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
flag = True
ReDim Preserve pos(i)
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim j As Integer
If (flag) Then
  ReDim Preserve pos(i)
  pos(i).X = X
  pos(i).Y = Y
  Me.Cls
  Polygon Me.hdc, pos(0), i
  For j = 0 To i
    Ellipse Me.hdc, pos(j).X, pos(j).Y, pos(j).X + 5, pos(j).Y + 5
  Next j
End If
End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (flag) Then
pos(i).X = X
pos(i).Y = Y
  If (i >= 3) Then
    Polygon Me.hdc, pos(0), i
    Ellipse Me.hdc, X, Y, X + 5, Y + 5
    i = i + 1
  End If
  If (i < 3) Then
    Polygon Me.hdc, pos(0), i
    i = i + 1
    Ellipse Me.hdc, X, Y, X + 5, Y + 5
    flag = False
    End If
End If
End Sub
--------------------------------------------------------------------
Made by Thirdapple's Studio(http://3rdapple.51.net/)

解决方案 »

  1.   

    楼上的,给你一个我做的长方形的原代码,你下载下来运行看看,我就要多边形作成哪个效果,代码如下:Option Explicit
    Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As Long
    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type
    Dim flag As Boolean
    Dim hdc1 As Long
    Dim pos As RECT
    Dim handle As Long
    Dim X1 As Long
    Dim x2 As Long
    Dim y2 As Long
    Dim Y1 As LongPrivate Sub Form_Load()
    DrawWidth = 10
    flag = False
        Me.ScaleMode = 3
    Me.AutoRedraw = FalseEnd SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    flag = True
    pos.Left = X
    pos.Top = Y
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (flag) Then
    pos.Right = X
    pos.Bottom = Y
    End If
    End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (flag) Then
    pos.Right = X
    pos.Bottom = Y
    Rectangle Me.hdc, pos.Left, pos.Bottom, pos.Right, pos.Top
    flag = False
    End If
    End Sub
      

  2.   

    你去这里下载一个东东:http://3rdapple.51.net/FantasiaPhoto.htm
    是不是那个软件的“背景过滤”模块中“手绘”的效果?
      

  3.   

    Option Explicit
    Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
    Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Private Type POINTAPI
            X As Long
            Y As Long
    End Type
    Dim flag As Boolean
    Dim hdc1 As Long
    Dim pos(0 To 10) As POINTAPI
    Dim i As Integer
    Dim nil As POINTAPI
    Private Sub Form_Load()
    flag = False
        Me.ScaleMode = 3
    Me.AutoRedraw = False
    i = 0
    End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    flag = True
    pos(i).X = X
    pos(i).Y = Y
    End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (flag) Then
    pos(i).X = X
    pos(i).Y = Y
    Ellipse Me.hdc, X, Y, X + 5, Y + 5
    If (i >= 4) Then
       Polygon Me.hdc, pos(0), 5
       i = 0
      End If
      If (i < 4) Then
         i = i + 1
        flag = False
        End If
    End If
    End Sub
      

  4.   

    不是,你那是点击生成事件,我要的是拖动事件楼上的,给你一个我做的长方形的原代码,你下载下来运行看看,我就要多边形作成哪个效果,代码如下:Option Explicit
    Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As Long
    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type
    Dim flag As Boolean
    Dim hdc1 As Long
    Dim pos As RECT
    Dim handle As Long
    Dim X1 As Long
    Dim x2 As Long
    Dim y2 As Long
    Dim Y1 As LongPrivate Sub Form_Load()
    DrawWidth = 10
    flag = False
        Me.ScaleMode = 3
    Me.AutoRedraw = FalseEnd SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    flag = True
    pos.Left = X
    pos.Top = Y
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (flag) Then
    pos.Right = X
    pos.Bottom = Y
    End If
    End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (flag) Then
    pos.Right = X
    pos.Bottom = Y
    Rectangle Me.hdc, pos.Left, pos.Bottom, pos.Right, pos.Top
    flag = False
    End If
    End Sub