先建立一些异形的Region,再SetWindowRgn()

解决方案 »

  1.   

    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 Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
    Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode 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 CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
    Private Declare Function DrawFocusRect Lib "user32" (ByVal hdc As Long, lpRect As RECT) As Long
    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Const RGN_AND = 1
    Private Const RGN_COPY = 5
    Private Const RGN_DIFF = 4
    Private Const RGN_OR = 2
    Private Const RGN_XOR = 3
    Private Type POINTAPI
            X As Long
            Y As Long
    End Type
    Private Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End TypeDim CanDraw As Boolean
    Dim xx, yy
    Dim rct As RECT
    Dim temprect As RECTPrivate Sub Form_Load()
        Dim pt(4) As POINTAPI
        pt(0).X = 12
        pt(0).Y = 19
        pt(1).X = 55
        pt(1).Y = 83
        pt(2).X = 95
        pt(2).Y = 0
        pt(3).X = 20
        pt(3).Y = 0
        
        Dim pt1(4) As POINTAPI
        pt1(0).X = 12 + 65
        pt1(0).Y = 19
        pt1(1).X = 55 + 65
        pt1(1).Y = 83
        pt1(2).X = 95 + 65
        pt1(2).Y = 0
        pt1(3).X = 20 + 65
        pt1(3).Y = 0
        
        Dim p, q As Long
        p = CreateEllipticRgn(8, 4, 163, 162)
        q = CreateEllipticRgn(23, 124, 155, 225)
        CombineRgn p, p, q, RGN_DIFF
        
        q = CreatePolygonRgn(pt(0), 4, 1)
        CombineRgn p, p, q, RGN_DIFF
        
        q = CreatePolygonRgn(pt1(0), 4, 1)
        CombineRgn p, p, q, RGN_DIFF
        
        SetWindowRgn hwnd, p, True
        Me.Refresh
    End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        GetWindowRect Form1.hwnd, rct
        temprect.Left = rct.Left + 6
        temprect.Top = rct.Top + 24
        temprect.Right = rct.Right - 6
        temprect.Bottom = rct.Bottom - 6
        DrawFocusRect GetWindowDC(GetDesktopWindow), temprect
        xx = X
        yy = Y
        CanDraw = True
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If CanDraw = True Then
        DrawFocusRect GetWindowDC(GetDesktopWindow), temprect
        temprect.Left = rct.Left + 6 + X - xx
        temprect.Top = rct.Top + 24 + Y - yy
        temprect.Right = rct.Right - 6 + X - xx
        temprect.Bottom = rct.Bottom - 6 + Y - yy
        DrawFocusRect GetWindowDC(GetDesktopWindow), temprect
        End If
    End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        DrawFocusRect GetWindowDC(GetDesktopWindow), temprect
        Form1.Left = (temprect.Left - 6) * 15
        Form1.Top = (temprect.Top - 24) * 15
        CanDraw = False
    End SubPrivate Sub Image1_Click()
        Unload Me
    End Sub
      

  2.   

    也可以用ACTIVESKIN 不过要收费哦!
      

  3.   

    http://www.21code.com/codebase/?pos=list&type=subclass&mainclass=1&subclass=3
    来这里看看,有很多原码