Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   como usar el componente lblmarquee ? (https://www.clubdelphi.com/foros/showthread.php?t=69548)

gaston260 25-08-2010 03:18:13

como usar el componente lblmarquee ?
 
Hola perdon creo que mi consulta era para acá , la repeti en api de windows pido disculpas es que hace mucho que no uso el foro y espero no se enojen por mi estupidez , mi consulta es la siguiente ... amigos me gustaria saber cuando se llega al final del comentario en el componente lblmarquee que esta en rad studio para poder repetir un sonido cada vez que se repita el mensaje , tengo este codigo y e probado con eof pero nada !


Código Delphi [-]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.




la unica diferencia es que uso un memo en vez de un edText

gracias de antemano amigos !

ecfisa 25-08-2010 09:21:28

Hola gaston.

Primero tengo que apuntar un error en el código y creo que no es de copiado, si no de 'fabrica' por que lo he visto igual en dos o tres lados.

La línea:
Código Delphi [-]
 lblMarquee.Caption:= Copy(txt, length(txt) -1, 1) + Copy(txt, 1, length(txt) -1);
Tendría que poner el último caracter al principio y agregarle el resto -1, pero pone el anteúltimo y le agrega el resto -1. :)

Debería ser:
Código Delphi [-]
 lblMarquee.Caption:= Copy(txt, length(txt), 1) + Copy(txt, 1, length(txt) -1);

Ahora con lo del sonido, se me ocurre algo así: (Reduje el código para simplificar, pero es completamente funcional en ambos sentidos)
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, SysUtils, Forms, ExtCtrls, Classes;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    FCaption: string;
  public
  end;

var
  Form1: TForm1;

implementation {$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Caption:= 'prueba1234';
  FCaption:= Caption;
  Timer1.Interval := 1000 div 5;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  txt: string;
begin
  txt:= Self.Caption;
  Caption:= Copy(txt, length(txt), 1) + Copy(txt, 1, length(txt) -1);
  // ó,  Caption:= Copy(txt, 2, length(txt)-1) + Copy(txt,1,1);
  // si FCaption = Caption , implica que el último o primer caracter llegaron a su lugar
  if FCaption = Caption then
    Windows.MessageBeep(MB_ICONEXCLAMATION);
end;

end.


Saludos.

gaston260 26-08-2010 00:06:58

Gracias anda perfecto ! ! !


La franja horaria es GMT +2. Ahora son las 11:05:06.

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