Hello, I am trying to draw a couple of trapezoids on an OCX control... I am using the following code:

VB Code:
  1. Private Type COORD
  2.  x As Long
  3.  y As Long
  4. End Type
  5.  
  6. Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As Any, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
  7. Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As Any, ByVal nCount As Long) As Long
  8. Private Declare Function FillRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long
  9. Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
  10. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  11.  
  12. Const ALTERNATE = 1 ' ALTERNATE and WINDING are
  13. Const WINDING = 2 ' constants for FillMode.
  14. Const BLACKBRUSH = 4 ' Constant for brush type.
  15. Const WHITEBRUSH = 1
  16.  
  17. Private Sub dibujaTrapecio(x As Long, y As Long, width As Long, height As Long, color As Long)
  18.  Dim iXBorder As Long
  19.  Dim iYBorder As Long
  20.  
  21.  iXBorder = 10
  22.  iYBorder = 1
  23.  
  24.  x = x - iXBorder
  25.  width = width + iXBorder
  26.  
  27.  y = y - iYBorder
  28.  height = height + iYBorder
  29.  
  30.  Dim poly(1 To 4) As COORD, NumCoords As Long, hBrush As Long, hRgn As Long
  31.  UserControl.Cls
  32.  ' Number of vertices in polygon.
  33.  NumCoords = 4
  34.  ' Set scalemode to pixels to set up points of trapezoid.
  35.  UserControl.ScaleMode = vbPixels
  36.  ' Assign values to points.
  37.  poly(1).x = x + iXBorder
  38.  poly(1).y = y
  39.  poly(2).x = x
  40.  poly(2).y = y + height
  41.  poly(3).x = x + iXBorder + width
  42.  poly(3).y = y + height
  43.  poly(4).x = x + width
  44.  poly(4).y = y
  45.  ' Polygon function creates unfilled polygon on screen.
  46.  ' Remark FillRgn statement to see results.
  47.  Polygon UserControl.hdc, poly(1), NumCoords
  48.  ' Gets stock black brush.
  49.  hBrush = GetStockObject(color)
  50.  ' Creates region to fill with color.
  51.  hRgn = CreatePolygonRgn(poly(1), NumCoords, ALTERNATE)
  52.  ' If the creation of the region was successful then color.
  53.  If hRgn Then FillRgn UserControl.hdc, hRgn, hBrush
  54.  DeleteObject hRgn
  55. End Sub

(I took the code from si_geek and changed it a little for my own needs, thank you, si_geek)

As you can imagine, I am trying to emulate the behavior Frontpage has with its different files.

I wonder if there is a way to get the WindowBackground color for the brush... And also how could I redraw an array... Meaning I have to have something like a ZOrder... I am just starting and I would like some help.

Thanks in advance.