GradientFill (Windows CE 5.0)

Send Feedback

This function fills rectangular regions with a background color that is interpolated from color values specified at the vertices.

BOOL GradientFill(HDChdc,PTRIVERTEXpVertex,ULONGnVertex,PVOIDpMesh,ULONGnCount,ULONGulMode);

Parameters

  • hdc
    [in] Handle to the destination device context.
  • pVertex
    [in] Pointer to an array of TRIVERTEX structures, each of which defines a triangle vertex.
  • nVertex
    [in] The number of vertices in pVertex.
  • pMesh
    [in] Array of GRADIENT_RECT structures in rectangle mode.
  • nCount
    [in] The number of rectangles in pMesh.
  • ulMode
    [in] Specifies gradient fill mode. The following table shows the possible values for ulMode.
    Value Description
    GRADIENT_FILL_RECT_H In this mode, two endpoints describe a rectangle.

    The rectangle is defined to have a constant color (specified by the TRIVERTEX structure) for the left and right edges.

    GDI interpolates the color from the left-to-right edge and fills the interior.

    GRADIENT_FILL_RECT_V In this mode, two endpoints describe a rectangle.

    The rectangle is defined to have a constant color (specified by the TRIVERTEX structure) for the top and bottom edges.

    GDI interpolates the color from the top-to-bottom edge and fills the interior.

    GRADIENT_FILL_TRIANGLE Not supported.

Return Values

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

To get extended error information, call GetLastError. If the display driver does not support the DrvGradientFill entry point, then GetLastError returns ERROR_NOT_SUPPORTED.

Remarks

To add smooth shading to a rectangle, call GradientFill with the upper-left and lower-right coordinates of the rectangle.

There are two shading modes used when drawing a rectangle:

  • In horizontal mode, the rectangle is shaded from left to right.
  • In vertical mode, the rectangle is shaded from top to bottom.

The GradientFill function uses a mesh method to specify the endpoints of the object to draw. All vertices are passed to GradientFill in the pVertex array. The pMesh parameter specifies how these vertices are connected to form an object. Each GRADIENT_RECT structure specifies the index of two vertices in the pVertex array. These two vertices form the upper left and lower right boundary of one rectangle.

For example, to draw a shaded rectangle from [0,0] to [100,32], define a TRIVERTEX array with two elements and a single GRADIENT_RECT structure.

The following example shows a horizontal GradientFill rectangle call.

Note   To make the following code example easier to read, error checking is not included. This code example should not be used in a release configuration unless it has been modified to include secure error handling.

TRIVERTEX        vert[2] ;
GRADIENT_RECT    gRect;
vert [0] .x      = 0;
vert [0] .y      = 0;
vert [0] .Red    = 0x0000;
vert [0] .Green  = 0x0000;
vert [0] .Blue   = 0x0000;
vert [0] .Alpha  = 0x0000;

vert [1] .x      = 100;
vert [1] .y      = 32; 
vert [1] .Red    = 0x0000;
vert [1] .Green  = 0x0000;
vert [1] .Blue   = 0xff00;
vert [1] .Alpha  = 0x0000;

gRect.UpperLeft  = 0;
gRect.LowerRight = 1;
GradientFill(hdc,vert,2,&gRect,1,GRADIENT_FILL_RECT_H);

If hdc specifies a mirrored device context, the horizontal coordinates increase from right to left rather than from left to right.

Requirements

OS Versions: Windows CE .NET 4.2 and later.
Header: Windows.h.
Link Library: Coredll.lib.

See Also

GRADIENT_RECT | TRIVERTEX | GDI Functions

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.