【发布时间】:2015-01-11 15:28:08
【问题描述】:
在我的代码中:
void Surface::paintBorders(const Color& color, int borderWidth){
HBRUSH colorBrush = CreateSolidBrush(color.getRGB());
RECT border;
//Top Border:
border.top = 0;
border.bottom = borderWidth;
border.left = 0;
border.right = mRect.right - mRect.left;
FillRect(mHDC, &border, colorBrush);
//Bottom border
border.top = mRect.bottom - mRect.top - borderWidth;
border.bottom = mRect.bottom - mRect.top;
border.left = 0;
border.right = mRect.right - mRect.left;
FillRect(mHDC, &border, colorBrush);
//Right border
border.top = 0;
border.bottom = mRect.bottom - mRect.top;
border.left = mRect.right - mRect.left - borderWidth;
border.right = mRect.right - mRect.left;
FillRect(mHDC, &border, colorBrush);
//Left border
border.top = 0;
border.bottom = mRect.bottom - mRect.top;
border.left = 0;
border.right = borderWidth;
FillRect(mHDC, &border, colorBrush);
DeleteObject(colorBrush);
}
只有顶部和左侧边框被绘制,底部和右侧不被绘制。 我引用 MSDN:
此函数包含矩形的左边框和上边框,但不包括矩形的右边框和下边框。
不知道有没有关系。 我确信所有的协调都正常,还有 HDC 和 HBRUSH 参数。 有什么想法吗?
【问题讨论】:
-
很明显你的计算有点不对劲。尝试将右下边框向左和上移。
-
您只展示了部分代码。我们只能猜测具体情况。为什么不展示一个完整的程序?
标签: c++ c winapi user-interface window