From Clomosy Docs
Base class for controls that represent a scroll area (scroll box). One use of a scroll box is to group multiple graphical controls (such as buttons, list boxes, edit boxes, radio buttons, and so on) under the same scrollable parent (the scroll box itself). In this way, a smaller form can contain a lot of graphical objects organized in a scrollable manner in order to occupy less space on a graphical user interface.
AddNewHorzScrollBox(TComponent, xName): TclHorzScrollBox
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 horzscrollbox should be written.
Let's create a horzscrollbox.
1. Create a new project.
2. You need to define TclHorzScrollBox 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 TclHorzScrollBox.
var testHertScrollBox: TclHorzScrollBox;
3. Add the TclHorzScrollBox 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.AddNewHorzScrollBox, we actually add to the form we have defined. Here, you need to add your form definition as whatever you wrote it.
testHorzScrollBox := MyForm.TclHorzScrollBox(MyForm,'Test');
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.
testLayout := MyForm.AddNewLayout(MyForm,'testLayout'); testHorzScrollBox := MyForm.TclHorzScrollBox(testLayout,'testHorzScrollBox');
5. While defining the component, you can define it manually by typing. Another method is to write its shortcut. If you type "TclHorzScrollBox" while the shortcut is in the code block, a pop-up menu will appear.
As soon as you click, the following block will come automatically.
AddNewHorzScrollBox(xOwner:TComponent; xName:String);
6. We gave the variable name while defining the TclHorzScrollBox 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.
7. Now let's design our TclHorzScrollBox component. Let's set the width and height first. For this, you must make the following definitions.
testHorzScrollBox.Height := 50; testHorzScrollBox.Width := 150;
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 page to learn about these features. We're going to call it the top part here. So we have to write "AlTop".
testHorzScrollBox.Align := alTop;
9. With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.
testHorzScrollBox.Margins.Left:= 50; testHorzScrollBox.Margins.Right:= 10; testHorzScrollBox.Margins.Top:= 50; testHorzScrollBox.Margins.Bottom:= 10;
10. Nothing appears on the screen unless data is entered into our scrollable component.
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:
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:
- Base Syntax
var
MyForm:TclForm;
testButton : TclButton;
horzScrollBox : TClHorzScrollBox;
lytContainer : TClLayout;
testImg : TClProImage;
isCreated : Boolean;
procedure SetupImageComponent;
var
i : Integer;
begin
if isCreated then exit;
lytContainer.Width := 0;
for i:= 1 to 7 do
begin
testImg := MyForm.AddNewProImage(lytContainer,'testImg'+IntToStr(i));
testImg.Align := alLeft;
testImg.Margins.Left := 10;
testImg.Width := 100;
MyForm.SetImage(testImg,'https://media1.cucuvi.com/Dic19/BD220BD4-7AEA-43FA-AF97-E62D073AFD1B.jpg');
lytContainer.Width := lytContainer.Width + testImg.Width + testImg.Margins.Left;
end;
isCreated := True;
end;
procedure ButtonClicked;
begin
SetupImageComponent;
end;
begin
isCreated := False;
MyForm := TclForm.Create(Self);
testButton:= MyForm.AddNewButton(MyForm,'testButton','Load Images Horizontally');
testButton.TextSettings.Font.Size:=50;
testButton.Align := alCenter;
testButton.Height := 50;
testButton.Width := 200;
horzScrollBox := MyForm.AddNewHorzScrollBox(MyForm,'horzScrollBox');
horzScrollBox.Align := alTop;
horzScrollBox.Height := 100;
horzScrollBox.Margins.Left := 10;
horzScrollBox.Margins.Right := 10;
horzScrollBox.Margins.Top := 10;
horzScrollBox.ShowScrollBars := True;
lytContainer := MyForm.AddNewLayout(horzScrollBox,'lytContainer');
lytContainer.Align := alLeft;
lytContainer.Width := 200;
MyForm.AddNewEvent(testButton,tbeOnClick,'ButtonClicked');
MyForm.Run;
end;
- TRObject Syntax
var
MyForm:TclForm;
testButton : TclButton;
horzScrollBox : TClHorzScrollBox;
lytContainer : TClLayout;
testImg : TClProImage;
isCreated : Boolean;
void SetupImageComponent;
var
i : Integer;
{
if (isCreated) exit;
lytContainer.Width = 0;
for (i = 1 to 7)
{
testImg = MyForm.AddNewProImage(lytContainer,'testImg'+IntToStr(i));
testImg.Align = alLeft;
testImg.Margins.Left = 10;
testImg.Width = 100;
MyForm.SetImage(testImg,'https://media1.cucuvi.com/Dic19/BD220BD4-7AEA-43FA-AF97-E62D073AFD1B.jpg');
lytContainer.Width = lytContainer.Width + testImg.Width + testImg.Margins.Left;
}
isCreated = True;
}
void ButtonClicked;
{
SetupImageComponent;
}
{
isCreated = False;
MyForm = TclForm.Create(Self);
testButton= MyForm.AddNewButton(MyForm,'testButton','Load Images Horizontally');
testButton.TextSettings.Font.Size=50;
testButton.Align = alCenter;
testButton.Height = 50;
testButton.Width = 200;
horzScrollBox = MyForm.AddNewHorzScrollBox(MyForm,'horzScrollBox');
horzScrollBox.Align = alTop;
horzScrollBox.Height = 100;
horzScrollBox.Margins.Left = 10;
horzScrollBox.Margins.Right = 10;
horzScrollBox.Margins.Top = 10;
horzScrollBox.ShowScrollBars = True;
lytContainer = MyForm.AddNewLayout(horzScrollBox,'lytContainer');
lytContainer.Align = alLeft;
lytContainer.Width = 200;
MyForm.AddNewEvent(testButton,tbeOnClick,'ButtonClicked');
MyForm.Run;
}