[DllImport("gdi32.dll", EntryPoint="GdiGradientFill", ExactSpelling = true)]
public static extern bool GradientFill(
IntPtr hdc, // handle to DC
TRIVERTEX[] pVertex, // array of vertices
uint dwNumVertex, // number of vertices
GRADIENT_RECT[] pMesh, // array of gradients
uint dwNumMesh, // size of gradient array
uint dwMode // gradient fill mode);
[DllImport("gdi32.dll", EntryPoint="GdiGradientFill", ExactSpelling = true)]
public static extern bool GradientFill(
IntPtr hdc, // handle to DC
TRIVERTEX[] pVertex, // array of vertices
uint dwNumVertex, // number of vertices
GRADIENT_TRIANGE[] pMesh, // array of gradients
uint dwNumMesh, // size of gradient array
uint dwMode // gradient fill mode);
Declare Function GradientFill Lib "gdi32.dll" (TODO) As TODO
The dwMode is one of the constants from GRADIENT_.
Do you know one? Please contribute it!
The GDI32.dll does not contain a GradientFill() function. The actual entry point is GdiGradientFill(). That's why the 'EntryPoint' attribute is present.
This method creates one entry each for rectangles and triangles. It's just a matter of convenience and error checking by the compiler.
Please add some!
public class Gradient
{
public const uint
GRADIENT_FILL_RECT_H = 0x00000000,
GRADIENT_FILL_RECT_V = 0x00000001,
GRADIENT_FILL_TRIANGLE = 0x00000002,
GRADIENT_FILL_OP_FLAG = 0x000000ff;
[DllImport("gdi32.dll", EntryPoint="GdiGradientFill", ExactSpelling = true)]
public static extern bool GradientFill(
IntPtr hdc, // handle to DC
TRIVERTEX[] pVertex, // array of vertices
uint dwNumVertex, // number of vertices
GRADIENT_RECT[] pMesh, // array of gradients
uint dwNumMesh, // size of gradient array
uint dwMode // gradient fill mode
);
public static void DrawNiceRectangle(hDC graphPort, Rectangle Frame)
{
// Draw from whitish blue at the top, to a light blue at the bottom
TRIVERTEX[] vert = new TRIVERTEX[]{
new TRIVERTEX(Frame.Left,Frame.Top,0xff00,0xff00,0xffff,0x0),
new TRIVERTEX(Frame.Right,Frame.Bottom,0x0000,0x0000,0xff00,0x0)};
GRADIENT_RECT[] gRect = new GRADIENT_RECT[]{
new GRADIENT_RECT(0,1)};
Gradient.GradientFill(graphPort, vert, 2, gRect, 1, Gradient.GRADIENT_FILL_RECT_V);
}