Files
lazarus-ccr/components/lazbarcodes/examples/qrclock/main.pas

69 lines
1.2 KiB
ObjectPascal
Raw Normal View History

unit main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ubarcodes;
type
{ TMainForm }
TMainForm = class(TForm)
Timer: TTimer;
procedure FormCreate(Sender: TObject);
procedure TimerTimer(Sender: TObject);
private
BarcodeQR: TBarcodeQR;
function GetNowText: String;
public
end;
var
MainForm: TMainForm;
implementation
{$R *.lfm}
{ TMainForm }
procedure TMainForm.TimerTimer(Sender: TObject);
begin
BarcodeQR.Text := GetNowText;
Caption := 'QRClock: ' + StringReplace(BarcodeQR.Text, LineEnding, ' - ', []);
end;
procedure TMainForm.FormCreate(Sender: TObject);
var
w: Integer = 0;
h: Integer = 0;
begin
BarcodeQR := TBarcodeQR.Create(self);
BarcodeQR.Parent := self;
BarcodeQR.Scale := 16;
BarcodeQR.Text := GetNowText;
BarcodeQR.GetPreferredSize(w, h);
BarcodeQR.SetBounds(0, 0, w, h);
ClientWidth := w;
ClientHeight := h;
end;
function TMainForm.GetNowText: String;
var
dt: TDateTime;
sd, st: String;
begin
dt := Now();
sd := FormatDateTime('dddddd', dt);
st := FormatDateTime('hh:nn:ss', dt);
Result := sd + LineEnding + st;
end;
end.