Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 26-08-2007
Khronos Khronos is offline
Miembro
 
Registrado: abr 2007
Posts: 298
Poder: 18
Khronos Va por buen camino
Form con fondo grandiente

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
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 21:17:40.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi