Polyline The Polyline function draws a series of line segments by connecting the points in the specified array. BOOL Polyline( HDC hdc, // handle to device context CONST POINT *lppt, // pointer to array containing endpoints int cPoints // number of points in the array );
可以用 API 函数来实现Windows可以画直线、椭圆线(椭圆圆周上的曲线)和贝塞尔曲线。Windows 98支援的7个画线函数是:LineTo 画直线。
网上有很多现成的例子
也比较容易找到各个点。
The Polyline function draws a series of line segments by connecting the points in the specified array. BOOL Polyline(
HDC hdc, // handle to device context
CONST POINT *lppt, // pointer to array containing endpoints
int cPoints // number of points in the array
);
Polyline和PolylineTo 画一系列相连的直线。
PolyPolyline 画多组相连的线。
Arc 画椭圆线。
PolyBezier和PolyBezierTo 画贝塞尔曲线。
另外,Windows NT还支持3种画线函数:ArcTo和AngleArc 画椭圆线。
PolyDraw 画一系列相连的线以及贝塞尔曲线。
这三个函数Windows 98不支援。在本章的后面我将介绍一些既画线也填入所画图形的封闭区域的函数,这些函数是:Rectangle 画矩形。
Ellipse 画椭圆。
RoundRect 画带圆角的矩形。
Pie 画椭圆的一部分,使其看起来像一个扇形。
Chord 画椭圆的一部分,以呈弓形。
设备内容的五个属性影响着用这些函数所画线的外观:目前画笔的位置(仅用于LineTo、PolylineTo、PolyBezierTo和ArcTo )、画笔、背景方式、背景色和绘图模式。画一条直线,必须呼叫两个函数。第一个函数指定了线的开始点,第二个函数指定了线的终点:MoveToEx (hdc, xBeg, yBeg, NULL) ;
LineTo (hdc, xEnd, yEnd) ;
MoveToEx实际上不会画线,它只是设定了设备内容的「目前位置」属性。然后LineTo函数从目前的位置到它所指定的点画一条直线。目前位置只是用于其它几个GDI函数的开始点。在内定的设备内容中,目前位置最初设定在点(0,0)。如果在呼叫LineTo之前没有设定目前位置,那么它将从显示区域的左上角开始画线。