CreatePolygonRegion API function

Started by nandagopal, May 18, 2009, 05:52 PM

Previous topic - Next topic

nandagopal

Use the CreatePolygonRegion API function to make a polygonal region. Then use SetWindowRgn to make the button use the region.

Unfortunately this makes the button lose its shaded borders. My book Custom Controls Library shows how to build some shaped buttons that still have beveled borders.


' Make the button arrow-shaped.
Private Sub Form_Load()
Dim pts(1 To 7) As POINTAPI

    pts(1).X = 5
    pts(1).Y = 15
    pts(2).X = 35
    pts(2).Y = 15
    pts(3).X = 35
    pts(3).Y = 5
    pts(4).X = 55
    pts(4).Y = 25
    pts(5).X = 35
    pts(5).Y = 45
    pts(6).X = 35
    pts(6).Y = 35
    pts(7).X = 5
    pts(7).Y = 35
   
    Command1.Width = ScaleX(pts(4).X + 5, vbPixels, vbTwips)
    Command1.Height = ScaleY(pts(5).Y + 5, vbPixels, _
        vbTwips)

    m_ButtonRegion = CreatePolygonRgn(pts(1), UBound(pts), _
        ALTERNATE)
    SetWindowRgn Command1.hWnd, m_ButtonRegion, True
End Sub