问题illegal else without matching if
代码:
else if(MenuDrawType=2)
{
if (PressNum == 0)
{
//第一次点击
startP = point;
endP = point;//使线段一直都在,终点始终是鼠标
PressNum++;
}
else
{
//第二次点击
endP = point;
int dx = endP.x - startP.x;
int dy = endP.y - startP.y;
int steps, k;
float xincrement, yincrement, x = startP.x, y = startP.y;
if (abs(dx) > abs(dy))
steps = abs(dx);
else steps = abs(dy);
xincrement = dx /float(steps);
yincrement = dy / float(steps);
SetPixel(dc, startP.x, startP.y, RGB(255, 0, 0));
for (k = 0; k < steps; k++) {
x += xincrement;
y += yincrement;
SetPixel(dc, x, y, RGB(255, 0, 0));
}
}
if(MenuDrawType=3 )
{
if (PressNum == 0)
{//第一次点击
startP = point;
endP = point;//使线段一直都在,终点始终是鼠标
PressNum++;
}
else
{//第二次点击
endP = point;
double k, e;
int p, deltaX, deltaY, x1, y1, x2, y2;
x1 = startP.x;
y1 = startP.y;
x2 = endP.x;
y2 = endP.y;
deltaX = abs(x2 - x1);
deltaY = abs(y2 - y1);
p = 2 * deltaY - deltaX;
int twoDy = 2 * deltaY;
int twoDx = 2 * deltaX;
int twoDyDx = 2 * (deltaY - deltaX);
int twoDxDy = 2 * (deltaX - deltaY);
int x, y, xEnd, yEnd;
for(k;k<deltaX;k++)
{
SetPixel(dc, startP.x, startP.y, RGB(255, 0, 0));
x1=x1+1;
if(p>=0)
{
y1=y+1;
p+=twoDxDy;
}
p+=twoDy;
}
}
}