Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 05-08-2007
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Poder: 25
Caral Va por buen camino
Componente TLabel

Hola a todos y gracias de antemano por vuestra ayuda.
Estoy tratando de incursionar en este asunto de los componentes y no logro entender el concepto.
Lo que tengo:
Consegui un componente label que parpadea, esta simpatico, es este:
Código:
unit Blinklbl;

interface

uses
  Classes, StdCtrls, ExtCtrls;    { TTimer se declara en ExtCtrls }

type
  TBlinkLabel = class(TLabel)    {TBlinkLabel deriva de TLabel}
  private
    FVelocidad : integer;        {Frecuencia de parpadeo}
    FTimer : TTimer;             {Timer para la frecuencia}
    procedure SetVelocidad(valor : integer);  {Almacena la velocidad}
  protected
    procedure parpadea(Sender : TObject);
  public
    constructor Create(AOwner : TComponent); override;    {Constructor}
    destructor Destroy; override;                         {Destructor}
  published
    property Velocidad : integer read FVelocidad write SetVelocidad default 400;
  end;

procedure Register;

implementation

constructor TBlinkLabel.Create(AOwner : TComponent);
begin
  inherited Create(AOwner);       {Llama al constructor original (heredado)}
  FTimer := TTimer.Create(Self);  {Creamos el timer}
  FVelocidad := 400;              {Frecuencia (velocidad) por defecto}
  FTimer.Enabled:=True;           {Activamos el timer}
  FTimer.OnTimer:=parpadea;       {Asiganamos el método parpadea}
  FTimer.Interval:=FVelocidad;    {Asignamos el intervalo del timer = frecuencia parpadeo}
end;

destructor TBlinkLabel.Destroy;
begin
  FTimer.Free;          {Liberamos el timer}
  inherited destroy;    {Llamamos al destructor original (heredado)}
end;

procedure TBlinkLabel.SetVelocidad (valor : integer);
begin
  If FVelocidad <> valor then        {Sólo si el valor introducido es distinto del almacenado}
  begin
    if valor < 0 then FVelocidad:=0;
    FVelocidad:=Valor;               {Asigna la velocidad}
    if FVelocidad=0 then FTimer.Enabled:=False else FTimer.Enabled:=True;
    {Si Fvelocidad=0 el mensaje debe estar siempre visible}
    FTimer.Interval:=FVelocidad;
    Visible:=True;
  end;
end;

procedure TBlinkLabel.parpadea(Sender : TObject);
begin
  if FTimer.Enabled then Visible := not(Visible);  {Alternativamente muestra y oculta el mensaje si el timer esta activado}
end;

procedure Register;        {Registro del componente}
begin
  RegisterComponents('Curso', [TBlinkLabel]);
end;

end.
Tambien consegui gracias a Egostar el codigo de un label que hace que el mensage se vea como una pantallita que corre, este es el codigo:
Código:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, ComCtrls, Buttons;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    btnStartStop: TButton;
    BitBtn1: TBitBtn;
    lblMarquee: TLabel;
    edText: TEdit;
    Label2: TLabel;
    UpDown1: TUpDown;
    edSpeed: TEdit;
    Label1: TLabel;
    rgDirection: TRadioGroup;
    procedure BitBtn1Click(Sender: TObject);
    procedure edTextChange(Sender: TObject);
    procedure btnStartStopClick(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure UpDown1Changing(Sender: TObject; var AllowChange: Boolean);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.edTextChange(Sender: TObject);
begin
lblMarquee.Caption := edText.Text;
end;

procedure TForm1.btnStartStopClick(Sender: TObject);
begin
  Timer1.Enabled := not Timer1.Enabled;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var txt : string;
begin
txt:= lblMarquee.Caption;
if rgDirection.ItemIndex = 0 then //left
 lblMarquee.Caption:= Copy(txt, 2, length(txt)-1)   Copy(txt,1,1)
else //right
 lblMarquee.Caption:= Copy(txt,length(txt)-1,1)   Copy(txt, 1, length(txt)-1);

end;

procedure TForm1.UpDown1Changing(Sender: TObject;
  var AllowChange: Boolean);
begin
  Timer1.Interval := 1000 div UpDown1.Position;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 edTextChange(Self);
end;

end.
Que quiero hacer:
Quiero hacer un componente Label, que se coloque en un form y que colocando un edit en el mismo, pase la informacion de este de lado a lado, como lo hace el programa.
Gracias por vuestro tiempo y ayuda.
Saludos
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
tlabel enabled anubis Varios 12 10-05-2007 08:32:50
un TLabel como Hipervínculo zuriel_zrf Internet 9 06-01-2006 22:11:49
tlabel como Centrar ? Pascual Montes Varios 4 11-06-2005 02:53:33
un TLabel para ir a pagina web zuriel_zrf Internet 1 19-02-2004 11:16:29
Tlabel enlazado a un TDBedit CORBATIN OOP 2 15-09-2003 00:29:10


La franja horaria es GMT +2. Ahora son las 15:45:12.


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