Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (0)


Drawing a Shaded RectangleGo to Serhiy Perevoznyk's websiteFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi all versions
Category:
Graphic
Skill Level:
Scoring:
Last Update:
03/18/2003
Search Keys:
delphi delphi3000 article borland vcl code-snippet Delphi,API,GradientFill
Times Scored:
1
Visits:
2624
Uploader: Serhiy Perevoznyk
Company: http://users.chello.be/ws36637
Reference: N/A
 
Question/Problem/Abstract:
Using GradientFill API function
Answer:



The GradientFill function fills rectangle and triangle structures. To add smooth shading to a triangle, call the GradientFill function with the three triangle endpoints. GDI will linearly interpolate and fill the triangle.
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. First, you need the GradientFill function declaration (Windows.pas contains wrong dectaration of GradientFill function):

type
  TRIVERTEX = packed record
    X, Y : DWORD;
    Red, Green, Blue, Alpha : Word;
  end;

function GradientFill(DC : hDC; pVertex : Pointer; dwNumVertex : DWORD;
  pMesh : Pointer; dwNumMesh, dwMode: DWORD) : DWord; stdcall;
  external 'msimg32.dll';

The following example shows a horizontal rectangle call.

procedure TForm1.Button1Click(Sender: TObject);
var
vert : array[0..1] of TRIVERTEX;
gRect   : GRADIENT_RECT;
begin
  vert [0] .x      := 0;
  vert [0] .y      := 0;
  vert [0] .Red    := $0000;
  vert [0] .Green  := $0000;
  vert [0] .Blue   := $0000;
  vert [0] .Alpha  := $0000;

  vert [1] .x      := 100;
  vert [1] .y      := 32;
  vert [1] .Red    := $0000;
  vert [1] .Green  := $0000;
  vert [1] .Blue   := $ff00;
  vert [1] .Alpha  := $0000;

  gRect.UpperLeft  := 0;
  gRect.LowerRight := 1;
  GradientFill(Form1.Canvas.Handle, @vert,2,@gRect,1,GRADIENT_FILL_RECT_H);
end;






Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment













 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
Peganza
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)