From Clomosy Docs
AddNewProButton(TComponent, xName, xCaption): TClProButton
Unlike the standard button component, it has the feature of adding an image on the button. Apart from that, when you use the standard button, there is no clicking effect on the button when you run the application. You will see this feature when you use the ProButton. The logic is the same as the standard button. Let's create our button with a few changes on the code.
Below are the json parameters. With these parameters, you can add new features to your button along with the standard features.
- caption
- Width
- Height
- PositionX
- PositionY
- Align
- TextColor
- BackgroundColor
- TextSize
- TextVerticalAlign
- TextHorizontalAlign
- TextBold
- MarginTop
- MarginBottom
- MarginRight
- MarginLeft
- RoundHeight
- RoundWidth
- BorderColor
- BorderWidth
- ImgFit
- ImgStretch
- ImgUrl
Let's define the proButton at the beginning.
Var
testBtn : TClProButton;
Let's add ProButton to MyForm. Then let's give properties to our button with json structure.
testBtn := MyForm.AddNewProButton(MyForm,'testBtn','');
clComponent.SetupComponent(testBtn,'{"caption":"Click Hero","Align" : "Center","MarginBottom":135,"Width" :200, "Height":70,"RoundHeight":2, "RoundWidth":2,"BorderColor":"#7A3E65","BorderWidth":2}');
We use the "SetImage" function to add an image to the button.
MyForm.SetImage(testBtn,'https://www.pngitem.com/pimgs/m/7-73713_play-game-button-png-lilac-transparent-png.png');
Finally, it gives a message when the button is clicked. A procedure has been established for this.
procedure BtnOnClick;
begin
ShowMessage('Hello..');
end;
begin
MyForm.AddNewEvent(testBtn,tbeOnClick,'BtnOnClick');
end;
Code:
Var MyForm:TclForm; testBtn : TClProButton;
procedure BtnOnClick; begin ShowMessage('Hello..'); end;
begin MyForm := TclForm.Create(Self);
testBtn := MyForm.AddNewProButton(MyForm,'testBtn',''); clComponent.SetupComponent(testBtn,'{"caption":"Click Hero","Align" : "Center","MarginBottom":135,"Width" :200, "Height":70,"RoundHeight":2, "RoundWidth":2,"BorderColor":"#7A3E65","BorderWidth":2}'); MyForm.SetImage(testBtn,'https://www.pngitem.com/pimgs/m/7-73713_play-game-button-png-lilac-transparent-png.png'); MyForm.AddNewEvent(testBtn,tbeOnClick,'BtnOnClick'); MyForm.Run;
end;
Output: