Polyline function
Synopsis
BOOL Polyline(
HDC hdc,
const POINT *lppt,
INT cPoints
);
Parameters
hdc- Handle to the device context.
lppt- Pointer to an array of
POINTstructures that define the line's vertices. cPoints- Number of points in the
lpptarray.
Return value
Returns nonzero if successful; otherwise, zero. Call GetLastError for extended error information.
Remarks
- The function draws straight line segments connecting the points in order.
- Current pen, background mode, and clipping region affect the rendering.
- Use
SetDCPenColororSelectObjectto change the pen.
Example
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
POINT pts[] = { {20,20}, {200,20}, {200,200}, {20,200}, {20,20} };
Polyline(hdc, pts, _countof(pts));
EndPaint(hwnd, &ps);
} return 0;
case WM_DESTROY: PostQuitMessage(0); return 0;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}