如果API是
BOOL Polygon(
HDC hdc,
const POINT* lpPoints,
int nCount
); 如果MFC是
CDC::CDC::Polygon
BOOL Polygon(
LPPOINT lpPoints,
int nCount
);
Parameters
lpPoints
Points to an array of points that specifies the vertices of the polygon. Each point in the array is a POINT structure or a CPoint object.nCount
Specifies the number of vertices in the array
BOOL Polygon(
HDC hdc,
const POINT* lpPoints,
int nCount
); 如果MFC是
CDC::CDC::Polygon
BOOL Polygon(
LPPOINT lpPoints,
int nCount
);
Parameters
lpPoints
Points to an array of points that specifies the vertices of the polygon. Each point in the array is a POINT structure or a CPoint object.nCount
Specifies the number of vertices in the array
CPoint pt[5];
pt[0].x = 100;
pt[0].y = 100;pt[1].x = 800;
pt[1].y = 100;pt[2].x = 800;
pt[2].y = 500;pt[3].x = 100;
pt[3].y = 800;pt[4].x = 100;
pt[4].y = 100;pDC->Polygon(pt,5);
pDC->SelectObject(old);
{
CPoint pt[5];
for(int i=0;i<5;i++)
{
pt[i].x = startpt.x;
pt[i].y = startpt.y;
}
CClientDC dc(this);
endpt.x=point.x;
endpt.y=point.y; if(startpt.x != -1) { dc.MoveTo(startpt.x,startpt.y);
dc.Polygon(pt,5);
startpt.x=endpt.x;
startpt.y=endpt.y; }
我写的是上面的程序,放在mousemove里的
编译没错 但是运行后不能实现画五边形的功能 为什么啊?? }
HDC hdc, // handle to DC
CONST POINT *lpPoints, // polygon vertices
int nCount // count of polygon vertices
);
Parameters
hdc
[in] Handle to the device context.
lpPoints
[in] Pointer to an array of POINT structures that specify the vertices of the polygon, in logical coordinates.
nCount
[in] Specifies the number of vertices in the array. This value must be greater than or equal to 2.
Return Values
If the function succeeds, the return value is nonzero.If the function fails, the return value is zero.Windows NT/2000/XP: To get extended error information, call GetLastError. Res
The polygon is closed automatically by drawing a line from the last vertex to the first. The current position is neither used nor updated by the Polygon function. Windows 95/98/Me: Polygon is limited in the number of points it can draw, depending on the line width (that is, the width of the pen selected into the DC), as shown in the following table.Line width Maximum number of points
line width is 1 16K
line width > 1 (that is, wideline) and device supports wideline 16K
line width > 1 but the device does not support wideline approximately 1360 (that is, a few less than 16K / 12)
Any extra points are ignored. To draw a line with more points, divide your data into groups, each of which have less than the maximum number of points, and call the function for each group of points. Remember to connect the line segments. Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Use Gdi32.lib.