Es un sencillo procedure para darle un efecto grandiente a los forms sin componentes.
Código Delphi
[-]
procedure GradientForm (frm : TForm; startcolor, endcolor : TColor);
var
startr : integer;
startg : integer;
startb : integer;
endr : integer;
endg : integer;
endb : integer;
curr : integer;
curg : integer;
curb : integer;
i : integer;
r : TRect;
nolines: byte;
curpct : integer;
bitspix: longint;
begin
startr := startcolor and $000000FF;
startg := (startcolor and $0000FF00) div 256;
startb := (startcolor and $00FF0000) div 256 div 256;
endr := endcolor and $000000FF;
endg := (endcolor and $0000FF00) div 256;
endb := (endcolor and $00FF0000) div 256 div 256;
if frm.Height < 250 then
nolines:=frm.Height
else
nolines:=250;
bitspix:=GetDeviceCaps(frm.Canvas.Handle, BITSPIXEL);
if (bitspix = 8) and (nolines > 50) then
nolines:=50
else if bitspix < 8 then
nolines:=4;
r.Left:=0;
r.Right:=frm.Width;
for i:=0 to nolines do
begin
curpct:= (i * 100) div nolines;
if startr > endr then
curr := startr - (curpct * (startr-endr) div 100)
else
curr := startr + (curpct * (endr-startr) div 100);
if startg > endg then
curg := startg - (curpct * (startg-endg) div 100)
else
curg := startg + (curpct * (endg-startg) div 100);
if startb > endb then
curb := startb - (curpct * (startb-endb) div 100)
else
curb := startb + (curpct * (endb-startb) div 100);
frm.Canvas.Brush.Color:=RGB(curr, curg, curb);
r.Top:=i + (i*(frm.Height div nolines));
r.Bottom:=r.Top + (frm.Height div nolines)+1;
frm.Canvas.FillRect(r);
end;
end;
Para llamarlo
Código Delphi
[-]
procedure TForm1.FormPaint(Sender: TObject);
begin
GradientForm(Form1,RGB(60,140,210), RGB(1,1,2));
end;
Salu2