Delphi 7 'windows.pas': Correcting error in function GradientFill

By: Maksim Grusha

Abstract: Delphi 7 'windows.pas': Correcting error in function GradientFill

Original declaration в Windows.pas

type
  {$EXTERNALSYM COLOR16}
  COLOR16 = Shortint;

function GradientFill(DC: HDC; var Vertex: TTriVertex; NumVertex: ULONG; Mesh: Pointer; NumMesh, Mode: ULONG): BOOL; stdcall;

the RIGHT declaration:


type
  {$EXTERNALSYM COLOR16}
  COLOR16 = Word;

function GradientFill(DC: HDC; Vertex: PTriVertex; dwNumVertex: ULONG; pMesh: Pointer; dwNumMesh, dwMode: ULONG): BOOL; stdcall;

 

Example from MSDN for testing:

procedure TForm1.Button2Click(Sender: TObject);
const
  // Create a GRADIENT_RECT structure that
  // references the TRIVERTEX vertices
.

  gRect: GRADIENT_RECT = (
    UpperLeft:0;
    LowerRight:1
  );
var
  DC: HDC;
  // Create an array of TRIVERTEX structures that describe
  // positional and color values for each vertex. For a rectangle,
  // only two vertices need to be defined: upper-left and lower-right.

  vertex: array[0..1] of TTriVertex;
begin
  vertex[0].x     := 0;
  vertex[0].y     := 0;
  vertex[0].Red   := $00;
  vertex[0].Green := $8000;
  vertex[0].Blue  := $8000;
  vertex[0].Alpha := 0;

  vertex[1].x     := 300;
  vertex[1].y     := 80;
  vertex[1].Red   := $00;
  vertex[1].Green := $D000;
  vertex[1].Blue  := $D000;
  vertex[1].Alpha := $00;

  DC := GetWindowDC(Handle);
  try
    // Draw a shaded rectangle.
    GradientFill(DC, @Vertex, 2, @gRect, 1, GRADIENT_FILL_RECT_H);
  finally
    ReleaseDC(Handle, DC);
  end;
end;

 



Server Response from: ETNASC01