Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #3  
Antiguo 30-07-2019
bucanero bucanero is offline
Miembro
 
Registrado: nov 2013
Ubicación: Almería, España
Posts: 208
Poder: 14
bucanero Va camino a la fama
hola

prueba el siguiente código:

se basa en determinar en el tiempo de la transición el valor que han de tener los cuatro puntos del panel, para lo cual se utiliza una función lineal donde x=0 es la posición inicial y x=AStep es el valor final, tenindo AStep el numero de pasos en que se quiere hacer la transición

Código Delphi [-]
type
  // Estructura de datos que funciona similar a como lo hace en matemáticas una
  // funcion lineal del tipo f(x) = a * x + b
  // y devuelve el valor de la función en el punto X de la linea
  TFLineal = record
  private
    a, b: Extended;
    function GetPoint(const x: Integer): Integer;
  public
    // valores iniciales para calcular la funcion lineal
    procedure init(const X1, y1, x2, y2: Integer);
    property Point[const x: Integer]: Integer read GetPoint; default;
  end;

...

{ TFLineal }
function TFLineal.GetPoint(const x: Integer): Integer;
begin
  Result := round(a * x + b);
end;

procedure TFLineal.init(const X1, y1, x2, y2: Integer);
begin
  // valores iniciales para calcular la funcion lineal
  a := (y2 - y1) / (x2 - X1);
  b := y1 - a * X1;
end;

y en la parte del formulario:


Código Delphi [-]
var
    fLeft, fWidth, fTop, fHeight: TFLineal;

...

procedure TForm2.AnimeConfig(AWinControl: TWinControl; const AWidth, AHeight,
  AStep: Word);
begin
  // se configura las coordenadas de la animación 
  fLeft.init(0, AWinControl.left, AStep, (ClientWidth - AWidth) div 2);
  fWidth.init(0, AWinControl.width, AStep, AWidth);
  fTop.init(0, AWinControl.top, AStep, (ClientHeight - AHeight) div 2);
  fHeight.init(0, AWinControl.height, AStep, AHeight);
end;

procedure TForm2.AnimeExecute(AWinControl: TWinControl; const AStep: Word);
var
  i, Ai: longint;
  tSleep:Word;
begin
  // la transicion durara 300 ms
  tSleep := 300 div AStep;
  if Tag <= 0 then begin
    i := 1;
    Ai := 1
  end
  else begin
    i := AStep - 1;
    Ai := -1;
  end;

  repeat
    with AWinControl do begin
      Left := fLeft[i];
      Top := fTop[i];
      Width := fWidth[i];
      Height := fHeight[i];
    end;
    Sleep(tSleep);
    i := i + Ai;
  until (i <= 0) or (i >= AStep);
  self.Tag := i;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  // configuración del ancho y alto que se quiere obtener
  AnimeConfig(Panel1, Width - 50, height - 300);
end;

procedure TForm2.Panel1DblClick(Sender: TObject);
begin
  // Se ejecuta la animación
  AnimeExecute(Panel1);
end;
Responder Con Cita
 



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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Centrar un form en un panel choclito1 OOP 4 09-09-2015 11:04:25
Mover un panel en tiempo ejecución por el form CarlosAlberto Varios 3 10-08-2011 11:16:53
Mover un panel emiliu Varios 2 17-01-2006 13:25:06
Mover una ventana desde un panel elcigarra Varios 2 02-11-2005 11:49:26
Impedir mover el form y redimensionar al mover barra tareas jealousy API de Windows 0 15-06-2004 13:58:05


La franja horaria es GMT +2. Ahora son las 09:34:54.


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