LinearGradientBrush::GetRectangle (Rect*) 方法 (gdiplusbrush.h)
LinearGradientBrush::GetRectangle 方法获取定义渐变边界的矩形。
语法
Status GetRectangle(
[out] Rect *rect
);
参数
[out] rect
类型: Rect*
指向 Rect 对象的指针,该对象接收定义渐变边界的矩形。 例如,如果线性渐变画笔的起点在 (20,50) ,终点在 (60,110) ,则定义矩形的左上角点 (20,50) ,宽度为 40,高度为 60。
返回值
类型: 状态
如果方法成功,则返回 Ok,这是 Status 枚举的元素。
如果 方法失败,它将返回 Status 枚举的其他元素之一。
备注
矩形通过以下方式定义渐变的边界:矩形的右侧和左侧构成水平渐变的边界。 顶部和底部边构成了垂直渐变的边界。 两个对角角位于对角渐变的边界上。 在上述每种情况下,任一侧/角都可能位于起始边界上,具体取决于起始点和终点传递给构造函数的方式。
示例
以下示例创建线性渐变画笔。 然后,代码获取画笔的矩形并绘制它。
VOID Example_GetRect(HDC hdc)
{
Graphics myGraphics(hdc);
// Create a linear gradient brush.
LinearGradientBrush linGrBrush(
Point(20, 10),
Point(60, 110),
Color(255, 0, 0, 0), // black
Color(255, 0, 0, 255)); // blue
// Obtain information about the linear gradient brush.
Rect rect;
linGrBrush.GetRectangle(&rect);
// Draw the retrieved rectangle.
Pen myPen(Color(255, 0, 0, 0));
myGraphics.DrawRectangle(&myPen, rect);
}
要求
最低受支持的客户端 | Windows XP、Windows 2000 Professional [仅限桌面应用] |
最低受支持的服务器 | Windows 2000 Server [仅限桌面应用] |
目标平台 | Windows |
标头 | gdiplusbrush.h (包括 Gdiplus.h) |
Library | Gdiplus.lib |
DLL | Gdiplus.dll |