draw_3d_rect

来源:互联网 发布:java 节假日api 编辑:程序博客网 时间:2024/06/06 03:09


void FillSolidRect(HDC hdc, int x, int y, int cx, int cy, COLORREF clr)
{
  RECT rect;
  SetBkColor(hdc, clr);
  rect.left = x;
  rect.top = y;
  rect.right = x + cx;
  rect.bottom = y + cy;
    ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
}






void Draw3dRect_1(HDC hdc, int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight)
{
  FillSolidRect(hdc, x, y, cx-1, 1, clrTopLeft); // top
  FillSolidRect(hdc, x, y, 1, cy-1, clrTopLeft); // left
  FillSolidRect(hdc, x+cx, y, -1, cy, clrBottomRight); // right
  FillSolidRect(hdc, x, y+cy, cx, -1, clrBottomRight); // bottom
}






void Draw3dRect(HDC hdc, LPCRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight)
{
  Draw3dRect_1(hdc, lpRect->left, lpRect->top, lpRect->right - lpRect->left, lpRect->bottom - lpRect->top, clrTopLeft, clrBottomRight);
}
原创粉丝点击