用rectangle函数矩形中间就是白色,但是如果用fillrect函数填充颜色的话就没有黑色边框了,就一整块红色,请问有什么办法实现我的要求?
8 个解决方案
#1
设置一个PEN 和一个BRUSH再画
或者直接花两个同心的框
或者直接花两个同心的框
#2
GDI,先把矩形边框的四个角点的坐标确定下来,然后创建一个PEN
Moveto();
LineTo();
至于填充颜色,楼主已经实现,再重复做一下应该是轻车熟路了。
最后别忘了析构画笔和其他应该释放的不再应用的结构体。
Moveto();
LineTo();
至于填充颜色,楼主已经实现,再重复做一下应该是轻车熟路了。
最后别忘了析构画笔和其他应该释放的不再应用的结构体。
#3
pDC->SelectStockObject(NULL_BRUSH);
pDC->SelectStockObject(DC_PEN);
pDC->SetDCPenColor(RGB(0, 0, 0));
pDC->Rectangle(0, 0, 100, 100);
或者
pDC->SelectStockObject(DC_BRUSH);
pDC->SetDCBrushColor(GetSysColor(COLOR_WINDOW));
pDC->SelectStockObject(DC_PEN);
pDC->SetDCPenColor(RGB(0, 0, 0));
pDC->Rectangle(0, 0, 100, 100);
pDC->SelectStockObject(DC_PEN);
pDC->SetDCPenColor(RGB(0, 0, 0));
pDC->Rectangle(0, 0, 100, 100);
或者
pDC->SelectStockObject(DC_BRUSH);
pDC->SetDCBrushColor(GetSysColor(COLOR_WINDOW));
pDC->SelectStockObject(DC_PEN);
pDC->SetDCPenColor(RGB(0, 0, 0));
pDC->Rectangle(0, 0, 100, 100);
#4
自己画4条线。
#6
设置PEN
#7
case WM_PAINT:
{
hdc = BeginPaint(hWnd, &ps);
HBRUSH hbr = CreateSolidBrush(RGB(255, 0, 0));
HBRUSH hOldbr = (HBRUSH)SelectObject(hdc, hbr);
RECT rc = {0, 0, 100, 100};
FillRect(hdc, &rc, hbr);
Rectangle(hdc, 0, 0, 100, 100);
SelectObject(hdc, hOldbr);
DeleteObject(hbr);
EndPaint(hWnd, &ps);
}
break;
#8
CDC::Rectangle
Draws a rectangle using the current pen. The interior of the rectangle is filled using the current brush.
绘制之前 选入合适的画笔和背景画刷
Draws a rectangle using the current pen. The interior of the rectangle is filled using the current brush.
绘制之前 选入合适的画笔和背景画刷
#1
设置一个PEN 和一个BRUSH再画
或者直接花两个同心的框
或者直接花两个同心的框
#2
GDI,先把矩形边框的四个角点的坐标确定下来,然后创建一个PEN
Moveto();
LineTo();
至于填充颜色,楼主已经实现,再重复做一下应该是轻车熟路了。
最后别忘了析构画笔和其他应该释放的不再应用的结构体。
Moveto();
LineTo();
至于填充颜色,楼主已经实现,再重复做一下应该是轻车熟路了。
最后别忘了析构画笔和其他应该释放的不再应用的结构体。
#3
pDC->SelectStockObject(NULL_BRUSH);
pDC->SelectStockObject(DC_PEN);
pDC->SetDCPenColor(RGB(0, 0, 0));
pDC->Rectangle(0, 0, 100, 100);
或者
pDC->SelectStockObject(DC_BRUSH);
pDC->SetDCBrushColor(GetSysColor(COLOR_WINDOW));
pDC->SelectStockObject(DC_PEN);
pDC->SetDCPenColor(RGB(0, 0, 0));
pDC->Rectangle(0, 0, 100, 100);
pDC->SelectStockObject(DC_PEN);
pDC->SetDCPenColor(RGB(0, 0, 0));
pDC->Rectangle(0, 0, 100, 100);
或者
pDC->SelectStockObject(DC_BRUSH);
pDC->SetDCBrushColor(GetSysColor(COLOR_WINDOW));
pDC->SelectStockObject(DC_PEN);
pDC->SetDCPenColor(RGB(0, 0, 0));
pDC->Rectangle(0, 0, 100, 100);
#4
自己画4条线。
#5
#6
设置PEN
#7
case WM_PAINT:
{
hdc = BeginPaint(hWnd, &ps);
HBRUSH hbr = CreateSolidBrush(RGB(255, 0, 0));
HBRUSH hOldbr = (HBRUSH)SelectObject(hdc, hbr);
RECT rc = {0, 0, 100, 100};
FillRect(hdc, &rc, hbr);
Rectangle(hdc, 0, 0, 100, 100);
SelectObject(hdc, hOldbr);
DeleteObject(hbr);
EndPaint(hWnd, &ps);
}
break;
#8
CDC::Rectangle
Draws a rectangle using the current pen. The interior of the rectangle is filled using the current brush.
绘制之前 选入合适的画笔和背景画刷
Draws a rectangle using the current pen. The interior of the rectangle is filled using the current brush.
绘制之前 选入合适的画笔和背景画刷