Mega Code Archive

 
Categories / Delphi / System
 

PolyDraw API for Windows 98,ME

Title: PolyDraw API for Windows 98,ME Question: One of the most powerfull GDI API PolyDraw is not available in WIndows 98,ME.What to do then.Lets try this code. Answer: My code is in VB but is as sample as peanut butter so I hope that even novice here can translate it into what so ever language they want. Const PT_CLOSEFIGURE = &H1 Const PT_LINETO = &H2 Const PT_BEZIERTO = &H4 Const PT_MOVETO = &H6 Public function PolyDraw (byval HDC as long,byref POINTARRAY a Pointapi,byref POINTTYPE a byte,byref Count a integer) Dim lastmovex as integer Dim lastmovey as integer Dim P1 as POINTAPI Dim PTARRAY(3) as pointapi lastmovex = 0 lastmovey = 0 Call BeginPath(HDC) for i = 0 to Count select case POINTTYPE(i) case PT_MOVE: Call Movetoex(HDC,POINTARRAY(i).x,POINTARRAY(i).y,P1) case PT_LINETO: Call Lineto(HDC,POINTARRAY(i).x,POINTARRAY(i).y) lastmovex = POINTARRAY(i).x lastmovey = POINTARRAY(i).y case PT_LINETO | PT_CLOSEFIGURE: Call Lineto(HDC,POINTARRAY(i).x,POINTARRAY(i).y) Call Lineto(HDC,lastmovex,lastmovey) case PT_BEZIERTO: PTARRAY(0).x = POINTARRAY(i).x PTARRAY(0).y = POINTARRAY(i).y PTARRAY(1).x = POINTARRAY(i+1).x PTARRAY(1).y = POINTARRAY(i+1).y PTARRAY(2).x = POINTARRAY(i+2).x PTARRAY(2).y = POINTARRAY(i+2).y PTARRAY(3).x = POINTARRAY(i+3).x PTARRAY(3).y = POINTARRAY(i+3).y Call PolyBezierTo(HDC,PTARRAY(0),4) i = i + 4 case PT_BEZIERTO | PT_CLOSEFIGURE: PTARRAY(0).x = POINTARRAY(i).x PTARRAY(0).y = POINTARRAY(i).y PTARRAY(1).x = POINTARRAY(i+1).x PTARRAY(1).y = POINTARRAY(i+1).y PTARRAY(2).x = POINTARRAY(i+2).x PTARRAY(2).y = POINTARRAY(i+2).y PTARRAY(3).x = POINTARRAY(i+3).x PTARRAY(3).y = POINTARRAY(i+3).y Call PolyBezierTo(HDC,PTARRAY(0),4) Call Lineto(HDC,lastmovex,lastmovey) i = i + 4 Next i Call EndPath(HDC) rt = StrokePath(HDC) if rt then PolyDraw=true End function What this function does is actually begins a path in the given DC and then draw the series of lines and bezier curves that the user want to draw.This is an inspired version of PolyDraw procedure given by Feng Yuan in his book. Regards, Asim Siddiqui.