From Clomosy Docs

No edit summary
No edit summary
Line 9: Line 9:
<span style="color:blue"> xCaption</span> : You can add a title.
<span style="color:blue"> xCaption</span> : You can add a title.


{| class="wikitable" style="border: 2px solid #c3d7e0"
! style="background-color: #c3d7e0"| Feature !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"|Definition
|-
|TclQRCodeGenerator || QRGen : TclQRCodeGenerator;  || A variable belonging to the TclQRCodeGenerator class is created.
|-
|AddNewQRCodeGenerator || QRGen = MyForm.AddNewQRCodeGenerator(MyForm,'QRGen','Test QRGen Caption'); || A new TclQRCodeGenerator is added to the form.
|-
|Width || QRGen.Width = 150; ||Allows adjusting the width of the QRCodeGenerator.
|-
|Height || QRGen.Height = 50; ||Allows adjusting the height of the QRCodeGenerator.
|-
|Align  || QRGen.Align = alTop; ||With the Align parameter, you can specify where you want our component to be aligned in the form. This parameter has multiple positioning properties. See the [[Object_Properties#Align | page]] to learn about these features.
|-
|Margins || QRGen.Margins.Left = 50; // Right, Top, Bottom ||With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.<br>[[File:QRCodeGeneratorMargins.jpg|frameless|200px]]<br>
|-
|Text  || QRGen.Text = FormatDateTime('ddmmyy hhnnss', Now); || Another use of QRCodeGenerator is to add text. If we add text to our component by saying QRGen.text, when the project is run, the title does not appear and the value you have written in the text starts to appear.
|-
|Caption ||QRGen.Caption = 'QRGen's Text'; || It represents the text displayed on the component. The Caption specifies the textual label that the component presents to the user.
|}


Let's create a QrCodeGenerator.<br>
'''Example:'''<br>


1. Create a new project.<br>
:'''TRObject Syntax'''
<pre>
var
  MyForm:TclForm;
  QRGen :  TClQRCodeGenerator;
  LytNewQrCode :TclLayout;
  BtnNewQrCode:TclProButton;


2. You need to define TclQRCodeGenerator on the form. To do this, you should add under the ''var'' parameter on the ide as follows. It is the name of your variable you typed at the beginning. You should define this as you want and add it as TclQRCodeGenerator.<br>
void BtnNewQrCodeClick;
'''var'''
{
QRGen : TclQRCodeGenerator;
  QRGen.Text = FormatDateTime('ddmmyy hhnnss', Now); //dd=day,mm=moon,yy=year -- hh=hour,nn=minute, ss= second
  BtnNewQrCode.Caption = QRGen.Text;
}


3. Add the TclQRCodeGenerator to the form. For this, you must add the begin end block and add it inside the form after the form is defined. By saying MyForm.AddNewQRCodeGenerator, we actually add to the form we have defined. Here, you need to add your form definition as whatever you wrote it.<br>
{
  MyForm = TclForm.Create(Self);
 
  LytNewQrCode = MyForm.AddNewLayout(MyForm,'LytNewQrCode');
  LytNewQrCode.Align=ALTop;
  LytNewQrCode.Height = 200;
  LytNewQrCode.Margins.Top = 30;
 
  QRGen= MyForm.AddNewQRCodeGenerator(LytNewQrCode,'QRGen','QRCode');
  QRGen.Height = 200;
  QRGen.Width = 200;
  QRGen.Align = alCenter;
  MyForm.AddNewEvent(QRGen,tbeOnGetQRCode,'');
 
  BtnNewQrCode = MyForm.AddNewProButton(MyForm,'BtnNewQrCode','RENEW');
  BtnNewQrCode.Align = alCenter;
  BtnNewQrCode.Width = 200;
  BtnNewQrCode.Height = 50;
  BtnNewQrCode.clProSettings.BorderColor = clAlphaColor.clHexToColor('#003399');
  BtnNewQrCode.clProSettings.FontColor = clAlphaColor.clHexToColor('#4682B4');
  BtnNewQrCode.clProSettings.RoundHeight = 10;
  BtnNewQrCode.clProSettings.RoundWidth = 10;
  BtnNewQrCode.clProSettings.BorderWidth = 2;
  BtnNewQrCode.clProSettings.FontSize = 20;
  BtnNewQrCode.clProSettings.IsFill = True;
  BtnNewQrCode.clProSettings.IsRound = True;
  BtnNewQrCode.SetclProSettings(BtnNewQrCode.clProSettings);
 
  MyForm.AddNewEvent(BtnNewQrCode,tbeOnClick,'BtnNewQrCodeClick');
 
  MyForm.Run;


QRGen := ''MyForm''.AddNewQRCodeGenerator(MyForm,'QRGen','Test QRGen Caption');
}
</pre>


4. If you do not want to define it in the form, you can add it in another component (such as Layout, Panel). Of course, before that, that component must be defined.
:'''Base Syntax'''
<span style="color:blue">testLayout</span> := MyForm.AddNewLayout(MyForm,'testLayout');
<pre>
QRGen:= MyForm.AddNewQRCodeGenerator(<span style="color:blue">testLayout</span>,'QRGen','Test QRGen Caption');
var
 
  MyForm:TclForm;
5. While defining the component, you can define it manually by typing. Another method is to write its shortcut. If you type "AddNewQRCodeGenerator" while the shortcut is in the code block, a pop-up menu will appear.<br>
  QRGen : TClQRCodeGenerator;
  LytNewQrCode :TclLayout;
[[File:TclQRCodeGeneratorShortcut.png|frameless|400px]]<br><br>
  BtnNewQrCode:TclProButton;
 
As soon as you click, the following block will come automatically.<br>
 
  AddNewQRCodeGenerator(TComponent, xName, xCaption);
 
6. We gave the variable name while defining the TclQRCodeGenerator in var. Now when you add this in begin end you should use this variable name in all definitions. Your code will throw an error when you write these variable names incorrectly.
 
9. Another use of QRCodeGenerator is to add text. If we add text to our component by saying QRGen.text, when the project is run, the title does not appear and the value you have written in the text starts to appear.
 
QRGen.Text := 'QRGen's Text';
 
For example, take the value written in an TClEdit component and put it in the QrCodeGenerator and show me this. Below we show you how to do this.


QRGen.Text := testEdit.Text;
Procedure BtnNewQrCodeClick;
ShowMessage(QRGen.Text);
begin
  QRGen.Text := FormatDateTime('ddmmyy hhnnss', Now); //dd=day,mm=moon,yy=year -- hh=hour,nn=minute, ss= second
  BtnNewQrCode.Caption := QRGen.Text;
End;


10. Now let's design our TclQRCodeGenerator component. Let's set the width and height first. For this, you must make the following definitions.
begin
 
   MyForm := TclForm.Create(Self);
QRGen.Height := 50;
 
QRGen.Width := 150;
 
11. With the Align parameter, you can specify where you want our component to be aligned in the form. This parameter has multiple positioning properties. See the [https://www.docs.clomosy.com/index.php/Object_Properties#Align page] to learn about these features. We're going to call it the top part here. So we have to write "AlTop".
QRGen.Align := alTop;
 
12. With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.
 
QRGen.Margins.Left:= 50;
QRGen.Margins.Right:= 10;
QRGen.Margins.Top:= 50;
QRGen.Margins.Bottom:= 10;
 
[[File:QRCodeGeneratorMargins.jpg|frameless|400px]]<br><br>
 
13. You may want to activate the click feature on the QRCode. For this, we can activate the click feature by saying "tbeOnGetQRCode" in the AddNewEvent parameter. When clicked, whatever operation will be performed will be written in the last parameter.<br>
 
MyForm.AddNewEvent(QRGen,'''tbeOnGetQRCode''',<nowiki>''</nowiki>);
 
14. As soon as you add the QRCode component to the form, a ready-made QR Code comes automatically. By saying "variableName.Text" into the QRCode, you can send data with data types such as integer, date, string. (Don't forget to convert this data to string type.)<br>
 
In our example, we will pull the date data. If you do not know the FormatDateTime function definition, check the [[FormatDateTime]] page. In this way, every value we get is thrown into the QR Code when the button is pressed, and it returns us a new Qr code.<br>
 
QRGen.Text := FormatDateTime('ddmmyy hhnnss', Now); //dd=day,mm=moon,yy=year  hh=hour,nn=minute, ss= second
BtnNewQrCode.Caption := QRGen.Text;
 
13. To tell you the truth, you have created a simple application that does nothing yet. Let's save and start using our project. You can save in one of two ways:<br>
Click the save icon (the button in the upper right corner) or press Ctrl + S to save the project and see what you've done on the platforms now.
 
'''Example:'''<br>
 
:'''Base Syntax'''
'''var'''
  MyForm:TclForm;
  QRGen :  TClQRCodeGenerator;
  LytNewQrCode :TclLayout;
  BtnNewQrCode:TclProButton;<br>
'''Procedure''' BtnNewQrCodeClick;
'''begin'''
  QRGen.Text := FormatDateTime('ddmmyy hhnnss', Now); //dd=day,mm=moon,yy=year -- hh=hour,nn=minute, ss= second
  BtnNewQrCode.Caption := QRGen.Text;
'''End;'''<br> 
'''begin'''
   MyForm := TclForm.Create(Self);<br>
   LytNewQrCode := MyForm.AddNewLayout(MyForm,'LytNewQrCode');
   LytNewQrCode := MyForm.AddNewLayout(MyForm,'LytNewQrCode');
   LytNewQrCode.Align:=ALTop;
   LytNewQrCode.Align:=ALTop;
   LytNewQrCode.Height := 200;
   LytNewQrCode.Height := 200;
   LytNewQrCode.Margins.Top := 30;<br>
   LytNewQrCode.Margins.Top := 30;
 
   QRGen:= MyForm.AddNewQRCodeGenerator(LytNewQrCode,'QRGen','QRCode');
   QRGen:= MyForm.AddNewQRCodeGenerator(LytNewQrCode,'QRGen','QRCode');
   QRGen.Height := 200;
   QRGen.Height := 200;
   QRGen.Width := 200;
   QRGen.Width := 200;
   QRGen.Align := alCenter;
   QRGen.Align := alCenter;
   MyForm.AddNewEvent(QRGen,tbeOnGetQRCode,<nowiki>''</nowiki>);<br>
   MyForm.AddNewEvent(QRGen,tbeOnGetQRCode,'');
   BtnNewQrCode:= MyForm.AddNewProButton(MyForm,'BtnNewQrCode',<nowiki>''</nowiki>);
 
   clComponent.SetupComponent(BtnNewQrCode,'{"caption":"RENEW","Align" : "Center","Width" :200,"Height":50,
   BtnNewQrCode := MyForm.AddNewProButton(MyForm,'BtnNewQrCode','RENEW');
  "RoundHeight":20,"RoundWidth":10,"BorderColor":"#003399","BorderWidth":2,"TextSize":20,"TextColor":"#4682B4"}');<br>
   BtnNewQrCode.Align := alCenter;
   MyForm.AddNewEvent(BtnNewQrCode,tbeOnClick,'BtnNewQrCodeClick');<br>
   BtnNewQrCode.Width := 200;
  MyForm.Run;<br>
   BtnNewQrCode.Height := 50;
'''end;'''
   BtnNewQrCode.clProSettings.BorderColor := clAlphaColor.clHexToColor('#003399');
 
  BtnNewQrCode.clProSettings.FontColor := clAlphaColor.clHexToColor('#4682B4');
:'''TRObject Syntax'''
  BtnNewQrCode.clProSettings.RoundHeight := 10;
   var
  BtnNewQrCode.clProSettings.RoundWidth := 10;
    MyForm:TclForm;
  BtnNewQrCode.clProSettings.BorderWidth := 2;
    QRGen :  TClQRCodeGenerator;
  BtnNewQrCode.clProSettings.FontSize := 20;
    LytNewQrCode :TclLayout;
  BtnNewQrCode.clProSettings.IsFill := True;  
    BtnNewQrCode:TclProButton;
  BtnNewQrCode.clProSettings.IsRound := True;
 
  BtnNewQrCode.SetclProSettings(BtnNewQrCode.clProSettings);
   void BtnNewQrCodeClick;
 
  {
  MyForm.AddNewEvent(BtnNewQrCode,tbeOnClick,'BtnNewQrCodeClick');
    QRGen.Text = FormatDateTime('ddmmyy hhnnss', Now); //dd=day,mm=moon,yy=year -- hh=hour,nn=minute, ss= second
 
    BtnNewQrCode.Caption = QRGen.Text;
  MyForm.Run;
  }
   
  {
    MyForm = TclForm.Create(Self);
   
    LytNewQrCode = MyForm.AddNewLayout(MyForm,'LytNewQrCode');
    LytNewQrCode.Align=ALTop;
    LytNewQrCode.Height = 200;
    LytNewQrCode.Margins.Top = 30;
   
    QRGen= MyForm.AddNewQRCodeGenerator(LytNewQrCode,'QRGen','QRCode');
    QRGen.Height = 200;
    QRGen.Width = 200;
    QRGen.Align = alCenter;
    MyForm.AddNewEvent(QRGen,tbeOnGetQRCode,<nowiki>''</nowiki>);
   
    BtnNewQrCode= MyForm.AddNewProButton(MyForm,'BtnNewQrCode',<nowiki>''</nowiki>);
    clComponent.SetupComponent(BtnNewQrCode,'{"caption":"RENEW","Align" : "Center","Width" :200,"Height":50,
    "RoundHeight":20,"RoundWidth":10,"BorderColor":"#003399","BorderWidth":2,"TextSize":20,"TextColor":"#4682B4"}');
   
    MyForm.AddNewEvent(BtnNewQrCode,tbeOnClick,'BtnNewQrCodeClick');
   
    MyForm.Run;
  }


end;
</pre>





Revision as of 15:27, 22 August 2024

QR codes are actually barcodes using cryptology. So there is no visible information. Only when the QR code is deciphered, information is available at the address you go to.

AddNewQRCodeGenerator(TComponent, xName, xCaption): TclQRCodeGenerator

TComponent : The variable name of the defined component is written. Here you should write the component variable name of whatever your component will be in.

xName : The name of the defined QrCodeGenerator should be written.

xCaption : You can add a title.

Feature Use of Definition
TclQRCodeGenerator QRGen : TclQRCodeGenerator; A variable belonging to the TclQRCodeGenerator class is created.
AddNewQRCodeGenerator QRGen = MyForm.AddNewQRCodeGenerator(MyForm,'QRGen','Test QRGen Caption'); A new TclQRCodeGenerator is added to the form.
Width QRGen.Width = 150; Allows adjusting the width of the QRCodeGenerator.
Height QRGen.Height = 50; Allows adjusting the height of the QRCodeGenerator.
Align QRGen.Align = alTop; With the Align parameter, you can specify where you want our component to be aligned in the form. This parameter has multiple positioning properties. See the page to learn about these features.
Margins QRGen.Margins.Left = 50; // Right, Top, Bottom With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.
QRCodeGeneratorMargins.jpg
Text QRGen.Text = FormatDateTime('ddmmyy hhnnss', Now); Another use of QRCodeGenerator is to add text. If we add text to our component by saying QRGen.text, when the project is run, the title does not appear and the value you have written in the text starts to appear.
Caption QRGen.Caption = 'QRGen's Text'; It represents the text displayed on the component. The Caption specifies the textual label that the component presents to the user.

Example:

TRObject Syntax
var
  MyForm:TclForm;
  QRGen :  TClQRCodeGenerator;
  LytNewQrCode :TclLayout;
  BtnNewQrCode:TclProButton;

void BtnNewQrCodeClick;
{
  QRGen.Text = FormatDateTime('ddmmyy hhnnss', Now); //dd=day,mm=moon,yy=year -- hh=hour,nn=minute, ss= second
  BtnNewQrCode.Caption = QRGen.Text;
}

{
  MyForm = TclForm.Create(Self);
  
  LytNewQrCode = MyForm.AddNewLayout(MyForm,'LytNewQrCode');
  LytNewQrCode.Align=ALTop;
  LytNewQrCode.Height = 200;
  LytNewQrCode.Margins.Top = 30;
  
  QRGen= MyForm.AddNewQRCodeGenerator(LytNewQrCode,'QRGen','QRCode');
  QRGen.Height = 200;
  QRGen.Width = 200;
  QRGen.Align = alCenter;
  MyForm.AddNewEvent(QRGen,tbeOnGetQRCode,'');
  
  BtnNewQrCode = MyForm.AddNewProButton(MyForm,'BtnNewQrCode','RENEW');
  BtnNewQrCode.Align = alCenter;
  BtnNewQrCode.Width = 200;
  BtnNewQrCode.Height = 50;
  BtnNewQrCode.clProSettings.BorderColor = clAlphaColor.clHexToColor('#003399');
  BtnNewQrCode.clProSettings.FontColor = clAlphaColor.clHexToColor('#4682B4');
  BtnNewQrCode.clProSettings.RoundHeight = 10;
  BtnNewQrCode.clProSettings.RoundWidth = 10;
  BtnNewQrCode.clProSettings.BorderWidth = 2;
  BtnNewQrCode.clProSettings.FontSize = 20;
  BtnNewQrCode.clProSettings.IsFill = True; 
  BtnNewQrCode.clProSettings.IsRound = True;
  BtnNewQrCode.SetclProSettings(BtnNewQrCode.clProSettings);
  
  MyForm.AddNewEvent(BtnNewQrCode,tbeOnClick,'BtnNewQrCodeClick');
  
  MyForm.Run;

}
Base Syntax
var
  MyForm:TclForm;
  QRGen :  TClQRCodeGenerator;
  LytNewQrCode :TclLayout;
  BtnNewQrCode:TclProButton;

Procedure BtnNewQrCodeClick;
begin
  QRGen.Text := FormatDateTime('ddmmyy hhnnss', Now); //dd=day,mm=moon,yy=year -- hh=hour,nn=minute, ss= second
  BtnNewQrCode.Caption := QRGen.Text;
End;

begin
  MyForm := TclForm.Create(Self);
  
  LytNewQrCode := MyForm.AddNewLayout(MyForm,'LytNewQrCode');
  LytNewQrCode.Align:=ALTop;
  LytNewQrCode.Height := 200;
  LytNewQrCode.Margins.Top := 30;
  
  QRGen:= MyForm.AddNewQRCodeGenerator(LytNewQrCode,'QRGen','QRCode');
  QRGen.Height := 200;
  QRGen.Width := 200;
  QRGen.Align := alCenter;
  MyForm.AddNewEvent(QRGen,tbeOnGetQRCode,'');
  
  BtnNewQrCode := MyForm.AddNewProButton(MyForm,'BtnNewQrCode','RENEW');
  BtnNewQrCode.Align := alCenter;
  BtnNewQrCode.Width := 200;
  BtnNewQrCode.Height := 50;
  BtnNewQrCode.clProSettings.BorderColor := clAlphaColor.clHexToColor('#003399');
  BtnNewQrCode.clProSettings.FontColor := clAlphaColor.clHexToColor('#4682B4');
  BtnNewQrCode.clProSettings.RoundHeight := 10;
  BtnNewQrCode.clProSettings.RoundWidth := 10;
  BtnNewQrCode.clProSettings.BorderWidth := 2;
  BtnNewQrCode.clProSettings.FontSize := 20;
  BtnNewQrCode.clProSettings.IsFill := True; 
  BtnNewQrCode.clProSettings.IsRound := True;
  BtnNewQrCode.SetclProSettings(BtnNewQrCode.clProSettings);
  
  MyForm.AddNewEvent(BtnNewQrCode,tbeOnClick,'BtnNewQrCodeClick');
  
  MyForm.Run;

end;


Output:

See Also