第2个回答 2011-09-11
Option Explicit
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
'创建一个由一系列点围成的区域。windows在需要时自动将最后点与第一点相连以封闭多边形
Public Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private MyRegion As Long
Private Sub Form_Load()
Dim point(9) As POINTAPI
point(0).X = 145
point(0).Y = 76
point(1).X = 131
point(1).Y = 117
point(2).X = 90
point(2).Y = 117
point(3).X = 121
point(3).Y = 142
point(4).X = 107
point(4).Y = 185
point(5).X = 145
point(5).Y = 159
point(6).X = 182
point(6).Y = 185
point(7).X = 168
point(7).Y = 142
point(8).X = 200
point(8).Y = 117
point(9).X = 159
point(9).Y = 117
MyRegion = CreatePolygonRgn(point(0), 10, 1)
Me.ScaleMode = 3
Me.Move ScaleX(110, vbPixels, vbTwips), ScaleX(96, vbPixels, vbTwips), ScaleX(230, vbPixels, vbTwips), ScaleX(210, vbPixels, vbTwips)
Call SetWindowRgn(Me.hWnd, MyRegion, True)
End Sub
Private Sub Timer1_Timer()
Form1.BackColor = RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)
End Sub