椭圆等简单的我知道,我是问象组合型(如圆和矩形等)或五角星型等。
最好给点例子,谢了

解决方案 »

  1.   

    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
    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 Type POINTAPI
            X As Long
            Y As Long
           End Type
    Dim ap(4) As POINTAPI
    Dim hx As Integer
    Dim hy As Integer
    '棱形,其有边和点组成的图形都可以模仿,把ap得坐标点变一下就成了
    Private Sub Command1_Click()
            ap(0).X = 0: ap(0).Y = hy
            ap(1).X = hx: ap(1).Y = 0
            ap(2).X = Form1.Width \ Screen.TwipsPerPixelX: ap(2).Y = hy
            ap(3).X = hx: ap(3).Y = Form1.Height \ Screen.TwipsPerPixelY
            ap(4) = ap(0)
            reRgn = CreatePolygonRgn(ap(0), 5, 1)
            SetWindowRgn Form1.hWnd, reRgn, True
    End Sub
    '圆形
    Private Sub Command2_Click()
     Dim hr As Long
     Dim dl As Long
     hr = CreateEllipticRgn(0, 0, hx, hy)
     dl = SetWindowRgn(Me.hWnd, hr, True)
    End SubPrivate Sub Form_Load()
        Dim reRgn As Long
        hy = Form1.Height \ (2 * Screen.TwipsPerPixelY)
        hx = Form1.Width \ (2 * Screen.TwipsPerPixelX)
    End Sub
    那五角星只要算出那十个点的坐标就成了,
    圆和矩形组合倒是没试过
      

  2.   

    这样的话,比较重要的是CombineRgn函数了。参考这个例子,把setWindowFigure()放到FORM_LOAD里。
    Public Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Public Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Public Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
    Public Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As LongPublic Const RGN_AND = 1
    Public Const RGN_DIFF = 4
    Public Const RGN_XOR = 3Function setWindowFigure() As Boolean
        'Set windows figure
        Dim rgnDes As Long
        Dim rgnSrc1 As Long
        Dim rgnSrc2 As Long
        Dim rgnTmp As Long
        Dim rgnOri As Long
        
        'rgnOri = CreateRectRgn(me.Left / Screen.TwipsPerPixelX, me.Top / Screen.TwipsPerPixelX, (me.Left + me.Width) / Screen.TwipsPerPixelX, (me.Top + me.Height) / Screen.TwipsPerPixelY)
        rgnOri = CreateRectRgn(0, 0, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY)
        
        rgnSrc1 = CreateRectRgn(0, 0, 10, 10)
        rgnSrc2 = CreateEllipticRgn(0, 0, 20, 20)
        rgnTmp = CreateRectRgn(0, 0, 1, 1)
        rgnDes = CreateRectRgn(0, 0, 1, 1)
        CombineRgn rgnTmp, rgnSrc1, rgnSrc2, RGN_DIFF
        CombineRgn rgnDes, rgnOri, rgnTmp, RGN_XOR    rgnOri = rgnDes    rgnSrc1 = CreateRectRgn((Me.Width / Screen.TwipsPerPixelX - 10), 0, (Me.Width / Screen.TwipsPerPixelX), 10)
        rgnSrc2 = CreateEllipticRgn((Me.Width / Screen.TwipsPerPixelX - 20), 0, (Me.Width / Screen.TwipsPerPixelX), 20)
        rgnTmp = CreateRectRgn(0, 0, 1, 1)
        rgnDes = CreateRectRgn(0, 0, 1, 1)    CombineRgn rgnTmp, rgnSrc1, rgnSrc2, RGN_DIFF
        CombineRgn rgnDes, rgnOri, rgnTmp, RGN_XOR
        
        SetWindowRgn Me.hWnd, rgnDes, True
        
    End Function