LinearGradientBrush.GetRectangle(Rect*) method

Applies to: desktop apps only

The LinearGradientBrush::GetRectangle method gets the rectangle that defines the boundaries of the gradient.

Syntax

Status GetRectangle(
  [out]  Rect *rect
) const;

Parameters

  • rect [out]
    Type: Rect*

    Pointer to a Rect object that receives the rectangle that defines the boundaries of the gradient. For example, if a linear gradient brush is constructed with a starting point at (20, 50) and an ending point at (60, 110), then the defining rectangle has its upper-left point at (20, 50), a width of 40, and a height of 60.

Return value

Type:

Type: Status****

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Remarks

The rectangle defines the boundaries of the gradient in the following ways: The right and left sides of the rectangle form the boundaries of a horizontal gradient. The top and bottom sides form the boundaries of a vertical gradient. Two of the diagonally opposing corners lie on the boundaries of a diagonal gradient. In each of these cases, either side/corner may be on the starting boundary, depending on how the starting and ending points are passed to the constructor.

Examples

The following example creates a linear gradient brush. Then the code gets the brush's rectangle and draws it.

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);
}

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusbrush.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

LinearGradientBrush

Pen

Point

Rect

Creating a Linear Gradient

Using a Pen to Draw Lines and Rectangles

Brushes and Filled Shapes

Pens, Lines, and Rectangles

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012