Em alguns de meus programas comerciais há um letreiro digital, similar àqueles eletrônicos feitos com LEDs vermelhos. Mas meu mecanismo para mover o texto pelo form era muito grosseiro. Um dos meus clientes questionou sobre o letreiro e resolvi pesquisar para ver se encontrava algo pronto. Rapidamente encontrei uma dica em Delphi que quase me atendia. Na realidade precisei adaptar o código para que a mensagem rolasse para o lado contrário. Rapidamente alterei o código para que me atendesse e está aí o resultado:
[]'s,
Ericson Benjamim.
Código-fonte: letreiro_digital.7z
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
Por Ericson Benjamim | |
30 de Novembro de 2010 | |
Adaptado da versao em Delphi publicado em http://www.delphidicas.com.br/dicas/163/Criando-um-letreiro-digital.html | |
} | |
unit Unit1; | |
{$mode objfpc}{$H+} | |
interface | |
uses | |
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, | |
ExtCtrls, StdCtrls, Spin; | |
type | |
{ TForm1 } | |
TForm1 = class(TForm) | |
Button1: TButton; | |
Button3: TButton; | |
Edit1: TEdit; | |
Label1: TLabel; | |
Label2: TLabel; | |
Label3: TLabel; | |
Panel1: TPanel; | |
SpinEdit1: TSpinEdit; | |
SpinEdit2: TSpinEdit; | |
Timer1: TTimer; | |
procedure Button1Click(Sender: TObject); | |
procedure Button3Click(Sender: TObject); | |
procedure FormCreate(Sender: TObject); | |
procedure SpinEdit1Change(Sender: TObject); | |
procedure Timer1Timer(Sender: TObject); | |
private | |
{ private declarations } | |
public | |
{ public declarations } | |
Inverter: Boolean; | |
end; | |
var | |
Form1: TForm1; | |
implementation | |
{ TForm1 } | |
procedure TForm1.FormCreate(Sender: TObject); | |
begin | |
Panel1.BevelOuter := bvNone; | |
Panel1.Caption := ''; | |
Inverter := false; | |
Label1.Left := Panel1.Width; | |
end; | |
procedure TForm1.SpinEdit1Change(Sender: TObject); | |
begin | |
Timer1.Interval := SpinEdit1.Value; | |
end; | |
procedure TForm1.Button3Click(Sender: TObject); | |
begin | |
Label1.Caption := Edit1.Text; | |
end; | |
procedure TForm1.Button1Click(Sender: TObject); | |
begin | |
Inverter := not Inverter; | |
end; | |
procedure TForm1.Timer1Timer(Sender: TObject); | |
begin | |
if Inverter then begin | |
if label1.Left = Panel1.Width then | |
Label1.Left := -(Label1.Width) | |
else | |
Label1.Left := Label1.Left + SpinEdit2.Value; | |
end else begin | |
if Label1.Left + Label1.Width <= 0 then | |
Label1.Left := Panel1.Width | |
else | |
Label1.Left := Label1.Left - SpinEdit2.Value; | |
end; | |
end; | |
initialization | |
{$I Unit1.lrs} | |
end. |