Condividi tramite


CDrawingManager::FillGradient2

Fills a rectangular area with a specified color gradient.

void FillGradient2 (
   CRect rect,
   COLORREF colorStart,
   COLORREF colorFinish,
   int nAngle = 0
);

Parameters

  • [in] rect
    The rectangular area to fill.

  • [in] colorStart
    The first color of the gradient.

  • [in] colorFinish
    The last color of the gradient.

  • [in] nAngle
    An integer between 0 and 360. This parameter specifies the direction of the color gradient.

Remarks

Use nAngle to specify the direction of the color gradient. When you specify the direction of the color gradient, you also specify where the color gradient starts. A value of 0 for nAngle indicates the gradient starts from the top of the rectangle. As nAngle increases, the starting location for the gradient moves in a counter-clockwise direction based on the angle.

Example

The following example demonstrates how to use the FillGradient2 method of the CDrawingManager class. This code snippet is part of the New Controls sample.

// CRect rect 
    // CDC* pDC
    CDrawingManager dm(*pDC);
    // The last parameter is the angle that specifies the direction of the color gradient.
    dm.FillGradient2(rect, RGB(102, 200, 238), RGB(0, 129, 185), 45);

Requirements

Header: afxdrawmanager.h

See Also

Reference

CDrawingManager Class

Hierarchy Chart