Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #7  
Antiguo 24-08-2018
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola.

Un ejemplo simple que desplaza horizontalmente un TImage de forma cíclica:
Código Delphi [-]
...
implementation

type
  TSentido = (toLeft, toDown, toRight, toUp); //  Por si hubiera un futuro desplaz. vertical 

procedure MoveImage(Img: TImage; const Sense: TSentido; const Disp: Integer);
begin
  case Sense of
    toRight:
    begin
      if Img.Left >= Img.Parent.ClientWidth - Disp then
        Img.Left := -Img.Width + Disp;
      Img.Left := Img.Left + Disp;
    end;
    toLeft:
    begin
      if Img.Left + Img.Width <= Disp then
        Img.Left := Img.Parent.Width;
      Img.Left := Img.Left - Disp;
    end;
    // toDown:
    // toTop:
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Self.KeyPreview            := True;
  Self.HorzScrollBar.Visible := False;
  Self.DoubleBuffered        := True;
  Image1.Width  := Image1.Picture.Width;
  Image1.Height := Image1.Picture.Height;
end;

Luego podes llamar a la función en el/los eventos que prefieras, v.gr.:
Código Delphi [-]
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if Key = VK_LEFT then
    MoveImage(Image1, toLeft, 10);
  if Key = VK_RIGHT then
    MoveImage(Image1, toRight, 10);
end;
Resultado:


Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
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
Programar en Delphi el juego del Ajedrez josejp1 Varios 14 25-10-2020 19:29:40
¿Se pueden programar apps para iOS sin saber programar? nlsgarcia La Taberna 7 04-08-2014 11:09:36
Duda sobre como programar el juego Timbiriche mifiar Varios 16 26-11-2005 06:06:01
programar un juego en red gario Internet 7 28-10-2005 01:51:07
Muy básico mateamargo Internet 6 27-10-2003 15:41:23


La franja horaria es GMT +2. Ahora son las 12:29:41.


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