VC 用GDI函数画椭圆和矩形的问题,请高手帮忙
发布网友
发布时间:2023-04-13 07:30
我来回答
共1个回答
热心网友
时间:2023-10-09 04:57
要绘空心的图形 请事先将空刷子选入设备
相关部分改了一下
case WM_MOUSEMOVE:
hdc=GetDC(hWnd);
SelectObject(hdc, GetStockObject(NULL_BRUSH));
SetROP2(hdc,R2_NOT);
if(bDraw==TRUE)
{
if(drawcontrol==1)//rect
{
//SetROP2(hdc,R2_XORPEN);
MoveToEx(hdc,x1,y1,NULL);
Rectangle(hdc,x1,y1,x2,y2);
x2=LOWORD(lParam);
y2=HIWORD(lParam);
MoveToEx(hdc,x1,y1,NULL);
Rectangle(hdc,x1,y1,x2,y2);
SetROP2(hdc,R2_NOT);
}
else if(drawcontrol==2)//ellipse
{
//SetROP2(hdc,R2_XORPEN);
MoveToEx(hdc,x1,y1,NULL);
Ellipse(hdc,x1,y1,x2,y2);
x2=LOWORD(lParam);
y2=HIWORD(lParam);
MoveToEx(hdc,x1,y1,NULL);
Ellipse(hdc,x1,y1,x2,y2);
}
else if(drawcontrol==3)//freeline
{
MoveToEx(hdc,x1,y1,NULL);
x1=LOWORD(lParam);
y1=HIWORD(lParam);
LineTo(hdc,x1,y1);
ReleaseDC(hWnd,hdc);
}
else if(drawcontrol==4)//line
{
MoveToEx(hdc,x1,y1,NULL);
LineTo(hdc,x2,y2);
x2=LOWORD(lParam);
y2=HIWORD(lParam);
MoveToEx(hdc,x1,y1,NULL);
LineTo(hdc,x2,y2);
}
// "if ..." end here
}
ReleaseDC(hWnd,hdc);
return 0;