PathGradientBrush::GetCenterPoint 方法获取此路径渐变画笔的中心点。
语法
Status GetCenterPoint(
  [out] Point *point
);
参数
[out] point
类型: 点*
指向接收中心点的 Point 对象的指针。
返回值
类型: 状态
如果该方法成功,则返回 Ok,这是 Status 枚举的元素。
如果方法失败,它将返回 Status 枚举的其他元素之一。
注解
默认情况下,PathGradientBrush 对象的中心点位于画笔边界路径的质心处,但可以通过调用 PathGradientBrush 对象的 SetCenterPoint 方法,将中心点设置为路径内部或外部的任何位置。
示例
以下示例演示 PathGradientBrush 类的几种方法,包括 PathGradientBrush::GetCenterPoint 和 PathGradientBrush::SetCenterColor。 该代码创建 PathGradientBrush 对象,然后设置画笔的中心颜色和边界颜色。 该代码调用 PathGradientBrush::GetCenterPoint 方法来确定路径渐变画笔的中心点,然后绘制一条从原点到该中心点的线。
VOID Example_GetCenterPoint(HDC hdc)
{
   Graphics graphics(hdc);
   // Create a path that consists of a single ellipse.
   GraphicsPath path;
   path.AddEllipse(0, 0, 200, 100);
   // Use the path to construct a brush.
   PathGradientBrush pthGrBrush(&path);
   // Set the color at the center of the path to blue.
   pthGrBrush.SetCenterColor(Color(255, 0, 0, 255));
   // Set the color along the entire boundary of the path to aqua.
   Color colors[] = {Color(255, 0, 255, 255)};
   INT count = 1;
   pthGrBrush.SetSurroundColors(colors, &count);
   // Fill the ellipse with the path gradient brush.
   graphics.FillEllipse(&pthGrBrush, 0, 0, 200, 100);
   // Obtain information about the path gradient brush.
   Point  centerPoint;
   pthGrBrush.GetCenterPoint(¢erPoint);
   // Draw a line from the origin to the center of the ellipse.
   Pen pen(Color(255, 0, 255, 0));
   graphics.DrawLine(&pen, Point(0, 0), centerPoint);
}
要求
| 要求 | 值 | 
|---|---|
| 最低受支持的客户端 | Windows XP、Windows 2000 Professional [仅限桌面应用] | 
| 最低受支持的服务器 | Windows 2000 Server [仅限桌面应用] | 
| 目标平台 | Windows | 
| 标头 | gdipluspath.h (包括 Gdiplus.h) | 
| Library | Gdiplus.lib | 
| DLL | Gdiplus.dll | 
另请参阅
PathGradientBrush::GetCenterColor