From Clomosy Docs

No edit summary
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
AddNewVertScrollBox (TClVertScrollBox) create scrolling areas within a form. Applications often need to display more information than will fit in a particular area. Some controls, such as list boxes, notes, and forms, can automatically scroll down their content.
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
AddNewVertScrollBox (TComponent, xName): TClVertScrollBox
function AddNewVertScrollBox(AComponent: TCLComponent; xName: string): TclVertScrollBox;
</div>


<span style="color:blue"> TComponent</span> : The variable name of the defined component is written. Here you should write the component variable name of whatever your component will be in.
<span style="color:blue"><b>AComponent</b></span> : Specifies the parent of the object to be defined.<br>


<span style="color:blue"> xName</span> : The name of the defined vertscrollbox should be written.
<span style="color:blue"><b>xName</b></span> : The name of the defined vertscrollbox should be written.<br>


Let's create a vertscrollbox.<br>
AddNewVertScrollBox (TClVertScrollBox) create scrolling areas within a form. Applications often need to display more information than will fit in a particular area. Some controls, such as list boxes, notes, and forms, can automatically scroll down their content.<br>


1. Create a new project.<br>
<div class="table-responsive">
{| class="wikitable" style="border: 2px solid #c3d7e0"
! style="background-color: #c3d7e0"| Feature  !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"| Definition
|-
|TclVertScrollBox || VertScrollBox1: TclVertScrollBox;  || A variable belonging to the TclVertScrollBox class is created.
|-
|AddNewVertScrollBox || VertScrollBox1 = Form1.AddNewVertScrollBox(Form1,'VertScrollBox1'); || A new TclVertScrollBox is added to the form.
|-
|ScrollBy(DeltaX,DeltaY: Integer); || VertScrollBox1.ScrollBy(0,-100); || To scroll the contents within the control, call ScrollBy.<br>
The DeltaX parameter is the change in pixels along the X-axis.<br>
A positive DeltaX value scrolls the content to the left; a negative value scrolls the content to the right.<br>
The DeltaY parameter is the change in pixels along the Y-axis.<br>
A positive DeltaY value scrolls the content upward; a negative value scrolls the content downward.
|-
|ScrollTo(X,Y: Integer); || VertScrollBox1.ScrollTo(0,-100); || To scroll the contents within the control, call ScrollTo.<br>
The X parameter is the change in pixels along the X-axis.<br>
A positive X value scrolls the content to the left; a negative value scrolls the content to the right.<br>
The Y parameter is the change in pixels along the Y-axis.<br>
A positive Y value scrolls the content upward; a negative value scrolls the content downward.
|-
|Width || VertScrollBox1.Width = 150; ||Allows adjusting the width of the scrollBox.
|-
|Height || VertScrollBox1.Height = 50; ||Allows adjusting the height of the scrollBox.
|-
|Align  || VertScrollBox1.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 || VertScrollBox1.Margins.Left = 50; // Right, Top, Bottom ||With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.<br>
|}
</div>


2. You need to define TclVertScrollBox 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 TclVertScrollBox.<br>
'''var'''
testVertScrollBox: TclVertScrollBox;


3. Add the TclVertScrollBox 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.AddNewVertScrollBox, we actually add to the form we have defined. Here, you need to add your form definition as whatever you wrote it.<br>
<b>Example</b><br>


testVertScrollBox := MyForm.'''AddNewVertScrollBox'''(MyForm,'Test');
In the example, a menu list has been created. The menu list includes headings such as vegetables, fruits, beverages, and types of meat. To enable a scrollable structure, a TCLVertScrollBox was created, containing buttons. When clicked, the specific button that was clicked is identified.


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.
<pre>
  <span style="color:blue">testLayout</span> := MyForm.AddNewLayout(MyForm,'testLayout');
var
testVertScrollBox := MyForm.AddNewVertScrollBox(<span style="color:blue">testLayout</span>,'testVertScrollBox');
  Form1: TclStyleForm;
 
  btnS : TclProButton;
5. While defining the component, you can define it manually by typing. Another method is to write its shortcut. If you type "AddNewVertScrollBox" while the shortcut is in the code block, a pop-up menu will appear.<br>
  vScroll:TCLVertScrollBox;
  BtnCaptionArr,BtnNameArr,btnImgArr  : array of String;
  i : Integer;
void BtnOnClick;
  var
  clickedBtn:TClProButton;
{
  clickedBtn = TClProButton(Form1.Clsender);
  ShowMessage(clickedBtn.Caption);
  ShowMessage(clickedBtn.Hint);
}
   
   
[[File:TclVertScrollBoxShortcut.png|frameless|400px]]<br><br>
{
 
  BtnNameArr = ['btnVegetables','btnFruits','btnBeverages','btnMeatTypes','btnCakes'];
As soon as you click, the following block will come automatically.<br>
  BtnCaptionArr = ['Vegetables','Fruits','Beverages','Meat Types','Cakes'];
 
  btnImgArr = ['https://clomosy.com/demos/aubergine.png',
AddNewVertScrollBox(xOwner:TComponent; xName:String);
  'https://clomosy.com/demos/watermelon.png',
 
  'https://clomosy.com/demos/fruitJuice.png',
6. We gave the variable name while defining the TclVertScrollBox 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.
  'https://clomosy.com/demos/meat.png',
 
  'https://clomosy.com/demos/cake.png'];
7. Now let's design our TclVertScrollBox component. Let's set the width and height first. For this, you must make the following definitions.
  Form1 = TclStyleForm.Create(Self);
 
  Form1.SetFormColor('#ffffff','', clGNone);
testVertScrollBox.Height := 50;
  Form1.clSetCaption('Menu List');
testVertScrollBox.Width := 150;
 
 
  vScroll = Form1.AddNewVertScrollBox(Form1,'ScrollBoxY');
8. 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".
  vScroll.Align = alMostTop;
testVertScrollBox.Align := alTop;
  vScroll.Height = Form1.clheight-70;
 
 
9. With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.
  for (i = 0 to 4)
 
  {
testVertScrollBox.Margins.Left:= 50;
    btnS = Form1.AddNewProButton(vScroll,BtnNameArr[i],BtnCaptionArr[i]);
testVertScrollBox.Margins.Right:= 10;  
    btnS.Align = AlTop;
testVertScrollBox.Margins.Top:= 50;
    btnS.Height = 150;
testVertScrollBox.Margins.Bottom:= 10;
    btnS.Margins.Bottom = 5;
 
    btnS.clProSettings.IsFill = True;
10. Nothing appears on the screen unless data is entered into our scrollable component.
    btnS.clProSettings.FontSize = 14;
    btnS.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
    btnS.clProSettings.TextSettings.Font.Style = [fsBold,fsItalic];
    btnS.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#4287f5');
    btnS.clProSettings.FontVertAlign = palLeading;
    btnS.clProSettings.FontHorzAlign = palcenter;
    btnS.clProSettings.PictureSource =btnImgArr[i];
    btnS.clProSettings.PictureAutoFit = True;
    btnS.SetclProSettings(btnS.clProSettings);
    btnS.Hint = BtnNameArr[i];
    Form1.AddNewEvent(btnS,tbeOnClick,'BtnOnClick');
  }
 
  Form1.Run;
}
</pre>


11. 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>
<b>Output:</b><br>
'''Var'''
[[File:MenuList.png|400px|frameless]]<br>
MyForm:TclForm;
testVertScrollBox: TclVertScrollBox;
testButton : TclButton;
counter : Integer;<br>
'''begin'''
Myform:=TclForm.Create(Self);
testVertScrollBox := MyForm.AddNewVertScrollBox(MyForm,'Test');
testVertScrollBox.Align := alClient;<br>
    '''for''' counter:= 1 '''to''' 10 '''do'''
    '''begin'''
    testButton := MyForm.AddNewButton(testVertScrollBox,'testButton'+IntToStr(counter),'Button '+IntToStr(counter));
    testButton.Align:=alTop;
    testButton.height:=100;
    testButton.StyledSettings:= ssFamily;
    testButton.TextSettings.FontColor:= clAlphaColor.clHexToColor('#8a067c');   
    '''end;'''<br>  
MyForm.Run;
'''end;'''
'''Output:'''<br>
[[File:VertScrollBox.png|500px|frameless]]


= See Also =
<h2> See Also </h2>
* [[Components]]
* [[Object Properties]]
* [[Object Properties]]
* [[AddNewEvent]]
* [[AddNewEvent]]
{{#seo:|description=Explore TclVertScrollBox in Clomosy! Implement seamless scrolling for efficient content navigation in mobile applications.}}

Latest revision as of 08:47, 24 April 2025

AComponent : Specifies the parent of the object to be defined.

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

AddNewVertScrollBox (TClVertScrollBox) create scrolling areas within a form. Applications often need to display more information than will fit in a particular area. Some controls, such as list boxes, notes, and forms, can automatically scroll down their content.

Feature Use of Definition
TclVertScrollBox VertScrollBox1: TclVertScrollBox; A variable belonging to the TclVertScrollBox class is created.
AddNewVertScrollBox VertScrollBox1 = Form1.AddNewVertScrollBox(Form1,'VertScrollBox1'); A new TclVertScrollBox is added to the form.
ScrollBy(DeltaX,DeltaY: Integer); VertScrollBox1.ScrollBy(0,-100); To scroll the contents within the control, call ScrollBy.

The DeltaX parameter is the change in pixels along the X-axis.
A positive DeltaX value scrolls the content to the left; a negative value scrolls the content to the right.
The DeltaY parameter is the change in pixels along the Y-axis.
A positive DeltaY value scrolls the content upward; a negative value scrolls the content downward.

ScrollTo(X,Y: Integer); VertScrollBox1.ScrollTo(0,-100); To scroll the contents within the control, call ScrollTo.

The X parameter is the change in pixels along the X-axis.
A positive X value scrolls the content to the left; a negative value scrolls the content to the right.
The Y parameter is the change in pixels along the Y-axis.
A positive Y value scrolls the content upward; a negative value scrolls the content downward.

Width VertScrollBox1.Width = 150; Allows adjusting the width of the scrollBox.
Height VertScrollBox1.Height = 50; Allows adjusting the height of the scrollBox.
Align VertScrollBox1.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 VertScrollBox1.Margins.Left = 50; // Right, Top, Bottom With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.


Example

In the example, a menu list has been created. The menu list includes headings such as vegetables, fruits, beverages, and types of meat. To enable a scrollable structure, a TCLVertScrollBox was created, containing buttons. When clicked, the specific button that was clicked is identified.

 var
   Form1: TclStyleForm;
   btnS : TclProButton;
   vScroll:TCLVertScrollBox;
   BtnCaptionArr,BtnNameArr,btnImgArr  : array of String;
   i : Integer;
 
 void BtnOnClick; 
 var
   clickedBtn:TClProButton;
 {
   clickedBtn = TClProButton(Form1.Clsender);
   ShowMessage(clickedBtn.Caption);
   ShowMessage(clickedBtn.Hint);
 
 }
 
 {
   BtnNameArr = ['btnVegetables','btnFruits','btnBeverages','btnMeatTypes','btnCakes'];
   BtnCaptionArr = ['Vegetables','Fruits','Beverages','Meat Types','Cakes'];
   btnImgArr = ['https://clomosy.com/demos/aubergine.png',
   'https://clomosy.com/demos/watermelon.png',
   'https://clomosy.com/demos/fruitJuice.png',
   'https://clomosy.com/demos/meat.png',
   'https://clomosy.com/demos/cake.png'];
   Form1 = TclStyleForm.Create(Self);
   Form1.SetFormColor('#ffffff','', clGNone);
   Form1.clSetCaption('Menu List');
   
   vScroll = Form1.AddNewVertScrollBox(Form1,'ScrollBoxY');
   vScroll.Align = alMostTop;
   vScroll.Height = Form1.clheight-70;
   
   for (i = 0 to 4)
   {
     btnS = Form1.AddNewProButton(vScroll,BtnNameArr[i],BtnCaptionArr[i]);
     btnS.Align = AlTop;
     btnS.Height = 150;
     btnS.Margins.Bottom = 5;
     btnS.clProSettings.IsFill = True;
     btnS.clProSettings.FontSize = 14;
     btnS.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
     btnS.clProSettings.TextSettings.Font.Style = [fsBold,fsItalic];
     btnS.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#4287f5');
     btnS.clProSettings.FontVertAlign = palLeading;
     btnS.clProSettings.FontHorzAlign = palcenter;
     btnS.clProSettings.PictureSource =btnImgArr[i];
     btnS.clProSettings.PictureAutoFit = True;
     btnS.SetclProSettings(btnS.clProSettings);
     btnS.Hint = BtnNameArr[i];
     Form1.AddNewEvent(btnS,tbeOnClick,'BtnOnClick');
   }
   
   Form1.Run;
 }


Output:
MenuList.png

See Also