|
-
Aug 25th, 2004, 11:27 AM
#1
Thread Starter
Frenzied Member
Trapezoid and Click?
Hello, I am trying to draw a couple of trapezoids on an OCX control... I am using the following code:
VB Code:
Private Type COORD
x As Long
y As Long
End Type
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As Any, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As Any, ByVal nCount As Long) As Long
Private Declare Function FillRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long
Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Const ALTERNATE = 1 ' ALTERNATE and WINDING are
Const WINDING = 2 ' constants for FillMode.
Const BLACKBRUSH = 4 ' Constant for brush type.
Const WHITEBRUSH = 1
Private Sub dibujaTrapecio(x As Long, y As Long, width As Long, height As Long, color As Long)
Dim iXBorder As Long
Dim iYBorder As Long
iXBorder = 10
iYBorder = 1
x = x - iXBorder
width = width + iXBorder
y = y - iYBorder
height = height + iYBorder
Dim poly(1 To 4) As COORD, NumCoords As Long, hBrush As Long, hRgn As Long
UserControl.Cls
' Number of vertices in polygon.
NumCoords = 4
' Set scalemode to pixels to set up points of trapezoid.
UserControl.ScaleMode = vbPixels
' Assign values to points.
poly(1).x = x + iXBorder
poly(1).y = y
poly(2).x = x
poly(2).y = y + height
poly(3).x = x + iXBorder + width
poly(3).y = y + height
poly(4).x = x + width
poly(4).y = y
' Polygon function creates unfilled polygon on screen.
' Remark FillRgn statement to see results.
Polygon UserControl.hdc, poly(1), NumCoords
' Gets stock black brush.
hBrush = GetStockObject(color)
' Creates region to fill with color.
hRgn = CreatePolygonRgn(poly(1), NumCoords, ALTERNATE)
' If the creation of the region was successful then color.
If hRgn Then FillRgn UserControl.hdc, hRgn, hBrush
DeleteObject hRgn
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.
We miss you, friend...  Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|