Lines, Polygons and PolyBezier(?) with the API 
Author Message
 Lines, Polygons and PolyBezier(?) with the API

Hi, I need some help with using the following API declerations: (I am an API
newbie)

Declare Function LineTo Lib "gdi32" Alias "LineTo" (ByVal hdc As Long, ByVal
x As Long, ByVal y As Long) As Long
Declare Function Polygon Lib "gdi32" Alias "Polygon" (ByVal hdc As Long,
lpPoint As POINTAPI, ByVal nCount As Long) As Long
Declare Function PolyBezier Lib "gdi32" Alias "PolyBezier" (ByVal hdc As
Long, lppt As POINTAPI, ByVal cPoints As Long) As Long
Type POINTAPI
        x As Long
        y As Long
End Type

LineTo:
  How does the API know where to start drawing (how do I tell it)?
Polygon:
  How do I go about using this function? What is nCount for?
PolyBezier:
  What does this do? Is it a fill? How do I use this?

I'm new to the API and can't find any place with a description on how to use
these. I'd appreciate it if someone could explain these to me, as I need to
use the first two and learning a little more about the API might help me
understand it.

Kind regards

Ross Norton



Tue, 21 May 2002 03:00:00 GMT  
 Lines, Polygons and PolyBezier(?) with the API


Quote:
>Hi, I need some help with using the following API declerations: (I am an API
>newbie)

>Declare Function LineTo Lib "gdi32" Alias "LineTo" (ByVal hdc As Long, ByVal
>x As Long, ByVal y As Long) As Long
>Declare Function Polygon Lib "gdi32" Alias "Polygon" (ByVal hdc As Long,
>lpPoint As POINTAPI, ByVal nCount As Long) As Long
>Declare Function PolyBezier Lib "gdi32" Alias "PolyBezier" (ByVal hdc As
>Long, lppt As POINTAPI, ByVal cPoints As Long) As Long
>Type POINTAPI
>        x As Long
>        y As Long
>End Type

>LineTo:
>  How does the API know where to start drawing (how do I tell it)?
>Polygon:

I'd guess that it is like the old LineTo with an initial start point
that was given usually by using Pset(x1,y1).  Reading the actual function
keyword 'LineTo' we take it to mean that it's a line ending somewhere
having started from a previous x,y point.  This saves having to use;

Line(Old_X,Old_Y) - (New_X, New_Y)

Quote:
>  How do I go about using this function? What is nCount for?
>PolyBezier:
>  What does this do? Is it a fill? How do I use this?

If ever you used one of those foam covered lead strips in technical
drawing then that's a great tool for drawing Bezier curves.  An 'S'
shape is a two-point Bezier curve (putting a point or handle on the
peaks) and a snake - well, take it from there.

There must be a structure that holds the number of x's and y's values
for n number of points.  If you think of a 5 pointed start then you need
5 x and y values in some structure somewhere and your nCount is the
number of points.

If you look through the various archives on this newsgroup then you
should find something.  I might even be arsed and scan through the
overwhelming amount of archive stuff I have. :-)

Maybe not, Miss World is tonight!

Richard.

-------------------------------------------------------------------------
For a visit to Hill House from the original horror film "The Haunting" look up
         Ettington Park Hotel near Stratford Upon Avon.
"No one comes any nearer than town!...In the dark!.....In the night!"



Wed, 22 May 2002 03:00:00 GMT  
 Lines, Polygons and PolyBezier(?) with the API
This will give you an idea on how to handle these...
Private Type COORD
    x As Integer
    y As Integer
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.
Private Sub Form_Paint()
    'KPD-Team 1999
    'URL: http://kpdweb.cjb.net/

    Dim poly(1 To 3) As COORD, NumCoords As Long, hBrush As Long, hRgn As
Long
    Me.Cls
    ' Number of vertices in polygon.
    NumCoords = 3
    ' Set scalemode to pixels to set up points of triangle.
    Me.ScaleMode = vbPixels
    ' Assign values to points.
    poly(1).x = Form1.ScaleWidth / 2
    poly(1).y = Form1.ScaleHeight / 2
    poly(2).x = Form1.ScaleWidth / 4
    poly(2).y = 3 * Form1.ScaleHeight / 4
    poly(3).x = 3 * Form1.ScaleWidth / 4
    poly(3).y = 3 * Form1.ScaleHeight / 4
    ' Polygon function creates unfilled polygon on screen.
    ' Remark FillRgn statement to see results.
    Polygon Me.hdc, poly(1), NumCoords
    ' Gets stock black brush.
    hBrush = GetStockObject(BLACKBRUSH)
    ' 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 Me.hdc, hRgn, hBrush
    DeleteObject hRgn
End Sub
Private Sub Form_Resize()
    Form_Paint
End Sub

--

Have a good day.
Don

Quote:



>>Hi, I need some help with using the following API declerations: (I am an
API
>>newbie)

>>Declare Function LineTo Lib "gdi32" Alias "LineTo" (ByVal hdc As Long,
ByVal
>>x As Long, ByVal y As Long) As Long
>>Declare Function Polygon Lib "gdi32" Alias "Polygon" (ByVal hdc As Long,
>>lpPoint As POINTAPI, ByVal nCount As Long) As Long
>>Declare Function PolyBezier Lib "gdi32" Alias "PolyBezier" (ByVal hdc As
>>Long, lppt As POINTAPI, ByVal cPoints As Long) As Long
>>Type POINTAPI
>>        x As Long
>>        y As Long
>>End Type

>>LineTo:
>>  How does the API know where to start drawing (how do I tell it)?
>>Polygon:

>I'd guess that it is like the old LineTo with an initial start point
>that was given usually by using Pset(x1,y1).  Reading the actual function
>keyword 'LineTo' we take it to mean that it's a line ending somewhere
>having started from a previous x,y point.  This saves having to use;

>Line(Old_X,Old_Y) - (New_X, New_Y)

>>  How do I go about using this function? What is nCount for?
>>PolyBezier:
>>  What does this do? Is it a fill? How do I use this?

>If ever you used one of those foam covered lead strips in technical
>drawing then that's a great tool for drawing Bezier curves.  An 'S'
>shape is a two-point Bezier curve (putting a point or handle on the
>peaks) and a snake - well, take it from there.

>There must be a structure that holds the number of x's and y's values
>for n number of points.  If you think of a 5 pointed start then you need
>5 x and y values in some structure somewhere and your nCount is the
>number of points.

>If you look through the various archives on this newsgroup then you
>should find something.  I might even be arsed and scan through the
>overwhelming amount of archive stuff I have. :-)

>Maybe not, Miss World is tonight!

>Richard.

>-------------------------------------------------------------------------
>For a visit to Hill House from the original horror film "The Haunting" look
up
>         Ettington Park Hotel near Stratford Upon Avon.
>"No one comes any nearer than town!...In the dark!.....In the night!"



Wed, 22 May 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. PolyBezier API - Please Help!!!

2. PolyBezier API - Please Help!!!

3. PolyBezier API - Please Help!!!

4. Scan-line polygon filling

5. polygon - polygon intersection

6. picturebox.scale command with Polyline or Polygon API Call

7. Polygon API calls.....

8. VB5 Polygon API calling ?

9. help...create polygon region API

10. HELP: API Polygon Functions

11. Problems with Polygon API Function

12. Someone please help with Polygon API??

 

 
Powered by phpBB® Forum Software