poly lines

Started by paulDiagnos, January 06, 2006, 06:47:36 AM

Previous topic - Next topic

paulDiagnos

Hi all once again,

having trouble with the winapi function for polyines

the problem is actually sending the polyarray for the winapi call. (PolylineTo (hdc,MyPolyline, MyPolyline.count   ) ) the compiler complains. looking on various sites they indicate that i can just pass the mypolyline to the winapi.

what am i doing wrong :-(


TYPE PolyPoint
   x AS SINGLE  
   y AS SINGLE
End Type
TYPE PolyArray  
   count AS LONG  
   xy(1 TO 1024) AS PolyPoint
End TYPE

global MyPolyline AS PolyArray

Function testsomething EXPORT as long


Dim PT AS LONG
MyPolyline.count = 1024
FOR pt=0 TO MyPolyline.count
'for each point, specify the x and y co-ordinates
MyPolyline.xy(pt).x= pt
MyPolyline.xy(pt).y= PT

NEXT

Polyline (hdc,MyPolyline, MyPolyline.count   )
End Function


thanks Paul

TechSupport

You seem to have a couple of problems in your code:
(1) Your loop starts at 0 but your point array is 1 based.
(2) It is easier to use the built in POINTAPI structure to deal with points. No need to define your own.

The following example draws a line on the Form when a button is clicked. I hope that it works in your example.


Type PolyArray
 count As Long
 xy(1 To 1024) As POINTAPI
End Type

Global MyPolyline As PolyArray
 

'----------------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
                                  ControlIndex     As Long,  _  ' index in Control Array
                                  hWndForm         As Dword, _  ' handle of Form
                                  hWndControl      As Dword, _  ' handle of Control
                                  idButtonControl  As Long   _  ' identifier of button
                                  ) As Long
 
 
  Local i   As Long
  Local hDC As Dword
 
  MyPolyline.count = 1024

  For i = 1 To MyPolyline.count
 
     'for each point, specify the x and y co-ordinates
     MyPolyline.xy(i).x = i
     MyPolyline.xy(i).y = i
 
  Next
 
  hDC = GetDC( hWndForm )
 
  Polyline hDC, MyPolyline.xy(1), MyPolyline.count
 
  ReleaseDC hWndForm, hDC                                    
 
End Function

paulDiagnos

brillian you guys are stars.

in the api help it chats about a tagpoint of type point. but as it wasnt reconised under basic i tried my own .

thanks again mr TechSupport