![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|
|
#1
|
||||
|
||||
|
Vamos a ver que te parece esto:
Código:
unit Blinklbl;
interface
uses
Classes, StdCtrls, ExtCtrls;
type
TAnimLabel = class(TLabel)
private
FVelocidad: integer;
FTimer: TTimer;
procedure SetVelocidad(Valor: Integer);
protected
procedure Animar(Sender: TObject); virtual; abstract;
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
published
property Velocidad: Integer read FVelocidad write SetVelocidad;
end;
TBlinkLabel = class(TAnimLabel)
protected
procedure Animar(Sender: TObject); override;
end;
TMarqueeLabel = class(TAnimLabel)
private
FInvertir: Boolean;
protected
procedure Animar(Sender: TObject); override;
published
property Invertir: Boolean read FInvertir write FInvertir;
end;
procedure Register;
implementation
{ TAnimLabel }
constructor TAnimLabel.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
FTimer := TTimer.Create(Self);
FTimer.OnTimer:= Animar;
FVelocidad:= 400;
FTimer.Interval:= FVelocidad;
FTimer.Enabled:= True;
end;
destructor TAnimLabel.Destroy;
begin
FTimer.Free;
inherited destroy;
end;
procedure TAnimLabel.SetVelocidad(Valor: Integer);
begin
If FVelocidad <> Valor then
begin
if Valor <= 0 then
begin
FVelocidad:= 0;
FTimer.Enabled:= FALSE;
end else
begin
FVelocidad:= 0;
FTimer.Enabled:= FALSE;
end;
FTimer.Interval:= FVelocidad;
end;
end;
{ TBlinkLabel }
procedure TBlinkLabel.Animar(Sender: TObject);
begin
Visible:= not(Visible);
end;
{ TMarqueeLabel }
procedure TMarqueeLabel.Animar(Sender: TObject);
begin
if FInvertir then
Caption:= Copy(Caption,Length(Caption),1) + Copy(Caption,1,Length(Caption)-1)
else
Caption:= Copy(Caption,2,MAXINT) + Copy(Caption,1,1);
end;
procedure Register;
begin
RegisterComponents('Curso', [TBlinkLabel]);
RegisterComponents('Curso', [TMarqueeLabel]);
end;
end.
|
|
#2
|
||||
|
||||
|
Mas claro imposible seoane el aunto es como tomar automaticamente el texto en otro edit de un formulario y se actualize en el caption.
pero ya tenemos tu componente de base, solo hay que agregarle las modificaciones, y caral si te fijas el timer esta dentro del componente, revisa el create...
__________________
...Yo naci en esta ribera del arauca vibr@d0r Soy hermano de la espuma, de la garza, de la rosa y del sol... Viva Venezuela |
|
#3
|
||||
|
||||
|
Hola
Cita:
Saludos |
|
#4
|
||||
|
||||
|
Si no hay otra solucion podriamos tomar la que coloque al principio, me sigue pareciendo razonable
Aunque ahora que lo pienso podriamos hacer esto Cita:
Noi es lo ideal pero deberia funcionar
__________________
...Yo naci en esta ribera del arauca vibr@d0r Soy hermano de la espuma, de la garza, de la rosa y del sol... Viva Venezuela Última edición por eduarcol fecha: 05-08-2007 a las 20:19:48. |
|
#5
|
||||
|
||||
|
Bueno, no entiendo por que intentar relacionar el TEdit con el label dentro del propio código del label, lo mas lógico seria usar el caption y el método OnChange del TEdit.
Pero el cliente siempre tiene razón ![]() Código:
unit Blinklbl;
interface
uses
Classes, StdCtrls, ExtCtrls;
type
TAnimLabel = class(TLabel)
private
FVelocidad: integer;
FTimer: TTimer;
procedure SetVelocidad(Valor: Integer);
protected
procedure Animar(Sender: TObject); virtual; abstract;
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
published
property Velocidad: Integer read FVelocidad write SetVelocidad;
end;
TBlinkLabel = class(TAnimLabel)
protected
procedure Animar(Sender: TObject); override;
end;
TMarqueeLabel = class(TAnimLabel)
private
FEdit: TEdit;
FIndice: Integer;
protected
procedure Animar(Sender: TObject); override;
published
property Edit: TEdit read FEdit write FEdit default nil;
end;
procedure Register;
implementation
{ TAnimLabel }
constructor TAnimLabel.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
FTimer := TTimer.Create(Self);
FTimer.OnTimer:= Animar;
FVelocidad:= 100;
FTimer.Interval:= FVelocidad;
FTimer.Enabled:= True;
end;
destructor TAnimLabel.Destroy;
begin
FTimer.Free;
inherited destroy;
end;
procedure TAnimLabel.SetVelocidad(Valor: Integer);
begin
If FVelocidad <> Valor then
begin
if Valor <= 0 then
begin
FVelocidad:= 0;
FTimer.Enabled:= FALSE;
end else
begin
FVelocidad:= 0;
FTimer.Enabled:= FALSE;
end;
FTimer.Interval:= FVelocidad;
end;
end;
{ TBlinkLabel }
procedure TBlinkLabel.Animar(Sender: TObject);
begin
Visible:= not(Visible);
end;
{ TMarqueeLabel }
procedure TMarqueeLabel.Animar(Sender: TObject);
var
Str: String;
begin
if Assigned(FEdit) then
Str:= FEdit.Text
else
Str:= '';
if Length(Str) > 0 then
begin
FIndice:= ((FIndice + 1) mod Length(Str)) + 1;
Caption:= Copy(Str,FIndice,MAXINT) + Copy(Str,1,FIndice - 1);
end else
Caption:= '';
end;
procedure Register;
begin
RegisterComponents('Curso', [TBlinkLabel]);
RegisterComponents('Curso', [TMarqueeLabel]);
end;
end.
¿Que te parece ahora? ![]() Última edición por seoane fecha: 05-08-2007 a las 20:48:04. |
|
#6
|
||||
|
||||
|
Magnifico amigo, a eso me referia tal como lo habia pensado
__________________
...Yo naci en esta ribera del arauca vibr@d0r Soy hermano de la espuma, de la garza, de la rosa y del sol... Viva Venezuela |
|
#7
|
||||
|
||||
|
Hola
No se por que no lo puedo compilar, me da este error: Cita:
Explico lo que hice, lo mas facil, crear un unit y tratar de instalarlo. Que hago mal, aparte de no saber. Saludos |
|
#8
|
||||
|
||||
|
Hola a todos, llevo unos minutos declarando ese componente. Lo tengo igual a seoane, el problema, que no se como resolver, es que cuando uno cambia el contenido del edit, deja de funcionar el efecto de animación.
La diferencia con respecto a lo que tiene seoane es esta: Código:
unit Blinklbl2;
interface
uses Blinklbl, StdCtrls, Classes;
type
TMarqueeLabelEdit = class(TMarqueeLabel)
private
FMyEdit: TEdit;
FInvertir: boolean;
procedure SetMyEdit(Value: TEdit);
protected
procedure Animar(Sender: TObject); override;
published
property MyEdit: TEdit read FmyEdit write SetMyEdit;
property Invertir: boolean read FInvertir write FInvertir;
end;
procedure Register;
implementation
procedure TMarqueeLabelEdit.Animar(Sender: TObject);
begin
if Assigned(MyEdit) then
if FInvertir then
Caption:= Copy(Caption,Length(MyEdit.Text),1) + Copy(Caption,1,Length(MyEdit.Text)-1)
else
Caption:= Copy(MyEdit.Text,2,MAXINT) + Copy(MyEdit.Text,1,1);
end;
procedure TMarqueeLabelEdit.SetMyEdit(Value: TEdit);
begin
FMyEdit := Value;
if Value <> nil then Value.FreeNotification(self);
end;
procedure Register;
begin
RegisterComponents('Curso', [TMarqueeLabelEdit]);
end;
end.
|
|
#9
|
||||
|
||||
|
Hola Seoane.
Impresionante Me queda una duda, estas creando dos componentes o uno solo? De todos modos lo voy a probar. Increible, maestro, a esto me referia, a que el componente hiciera su propia rutina. Saludos |
![]() |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
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 |
|