|
用API函数实现。参见通用函数MakePolygon。 参数说明:iForm是窗体名称;iDot是多边形数;iRadius是半径。 调用范例:MakePolygon Me, 6, Me.ScaleWidth \ 4 Private Type POINTAPI x As Long y As Long End Type Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long Dim XY() As POINTAPI Function MakePolygon(iForm As Form, iDot As Integer, iRadius As Integer) Dim hRgn As Long Dim lRes As Long ReDim XY(iDot) As POINTAPI If iDot < 3 Then Exit Function For i = 0 To iDot - 1 XY(i).x = iForm.ScaleWidth \ 2 + iRadius * Cos(i * (360 \ iDot) * 3.1415927 / 180) XY(i).y = iForm.ScaleHeight \ 2 + iRadius * Sin(i * (360 \ iDot) * 3.1415927 / 180) Next i hRgn = CreatePolygonRgn(XY(0), iDot, 2) lRes = SetWindowRgn(iForm.hWnd, hRgn, True) End Function 注:在调用本函数前需要设置窗体ScaleMode属性值为3。
[1] [2] 下一页
|