You've already forked lazarus-ccr
LazBarcodes: Create qrcode in qrclock demo at runtime.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8357 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -3,23 +3,9 @@ object MainForm: TMainForm
|
||||
Height = 260
|
||||
Top = 130
|
||||
Width = 260
|
||||
AutoSize = True
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'QRClock'
|
||||
ClientHeight = 260
|
||||
ClientWidth = 260
|
||||
OnCreate = FormCreate
|
||||
object BarcodeQR: TBarcodeQR
|
||||
Left = 0
|
||||
Height = 260
|
||||
Top = 0
|
||||
Width = 260
|
||||
ParentColor = False
|
||||
Text = 'TBarcodeQR'
|
||||
Scale = 12
|
||||
AutoSize = True
|
||||
RecommendedSymbolSize = False
|
||||
end
|
||||
object Timer: TTimer
|
||||
Interval = 250
|
||||
OnTimer = TimerTimer
|
||||
|
@ -12,11 +12,12 @@ type
|
||||
{ TMainForm }
|
||||
|
||||
TMainForm = class(TForm)
|
||||
BarcodeQR: TBarcodeQR;
|
||||
Timer: TTimer;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure TimerTimer(Sender: TObject);
|
||||
private
|
||||
BarcodeQR: TBarcodeQR;
|
||||
function GetNowText: String;
|
||||
|
||||
public
|
||||
|
||||
@ -32,15 +33,9 @@ implementation
|
||||
{ TMainForm }
|
||||
|
||||
procedure TMainForm.TimerTimer(Sender: TObject);
|
||||
var
|
||||
dt: TDateTime;
|
||||
sd, st: String;
|
||||
begin
|
||||
dt := Now();
|
||||
sd := FormatDateTime('dddddd', dt);
|
||||
st := FormatDateTime('hh:nn:ss', dt);
|
||||
Caption := 'QRClock: ' + sd + ' - ' + st;
|
||||
BarcodeQR.Text := sd + LineEnding + st;
|
||||
BarcodeQR.Text := GetNowText;
|
||||
Caption := 'QRClock: ' + StringReplace(BarcodeQR.Text, LineEnding, ' - ', []);
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormCreate(Sender: TObject);
|
||||
@ -48,11 +43,25 @@ var
|
||||
w: Integer = 0;
|
||||
h: Integer = 0;
|
||||
begin
|
||||
// Avoid switching to final form size while form is already visible
|
||||
TimerTimer(nil);
|
||||
BarcodeQR := TBarcodeQR.Create(self);
|
||||
BarcodeQR.Parent := self;
|
||||
BarcodeQR.Scale := 16;
|
||||
BarcodeQR.Text := GetNowText;
|
||||
BarcodeQR.GetPreferredSize(w, h);
|
||||
Width := w;
|
||||
Height := 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.
|
||||
|
@ -44,6 +44,7 @@
|
||||
<Filename Value="main.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="MainForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
|
Reference in New Issue
Block a user