Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
How to add a border to a Label
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Lazarus 2.2.6 and anchord...
by
TRon
[
Today
at 12:46:08 pm]
list of IT assets
by
bobby100
[
Today
at 12:29:21 pm]
Why is a private type of ...
by
TRon
[
Today
at 12:27:31 pm]
Is changing name supposed...
by
Joanna
[
Today
at 12:14:03 pm]
is it possible to create ...
by
Seenkao
[
Today
at 11:17:33 am]
Feature announcement: Fun...
by
Peter H
[
Today
at 10:55:02 am]
Possible work-around for ...
by
Thaddy
[
Today
at 10:13:31 am]
How to download a file fr...
by
c4p
[
Today
at 09:44:13 am]
program locks up using se...
by
cdbc
[
Today
at 09:34:10 am]
.cvd ClamAV database comp...
by
Onur2x
[
Today
at 08:14:34 am]
Small DBMS project and Ho...
by
TRon
[
Today
at 07:44:06 am]
Check for updates and upd...
by
KodeZwerg
[
Today
at 07:43:19 am]
python for lazarus
by
Mongkey
[
Today
at 06:23:44 am]
Scope of cross-platform
by
TRon
[
Today
at 06:07:59 am]
Something wrong when i cl...
by
TRon
[
Today
at 05:57:57 am]
Connect Bluetooth Chess b...
by
tearsfornations
[
Today
at 05:48:10 am]
Lazarus for RISC OS
by
TRon
[
Today
at 05:36:04 am]
Are We Dead Yet?
by
dieselnutjob
[
Today
at 12:35:09 am]
How to POST a SOAPAction ...
by
rvk
[
Today
at 12:12:23 am]
What to change ModePortA,...
by
ccrause
[June 08, 2023, 10:17:09 pm]
Access violation with use...
by
Martin_fr
[June 08, 2023, 08:34:18 pm]
Suggestion on the lines o...
by
Skvoznjak
[June 08, 2023, 06:43:43 pm]
Best way to include lots ...
by
PascalDragon
[June 08, 2023, 06:14:51 pm]
DBEdit - display setting ...
by
rvk
[June 08, 2023, 05:44:34 pm]
[SOLVED] Help for downloa...
by
magleft
[June 08, 2023, 05:02:48 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to add a border to a Label (Read 713 times)
seany
Jr. Member
Posts: 99
How to add a border to a Label
«
on:
February 11, 2023, 11:23:39 am »
Hi all
I posted a lot about menu renders using Linux/QT5
I got sidetracked, and decided to make my own Menu Class. I posted my first steps here:
https://forum.lazarus.freepascal.org/index.php/topic,62257.0.html
I wonder, how can I add a border to labels programatically? If I create a tlabel on form designer, and look with object inspector, I can't find an item that seems to relate to a border. So, some advice will be appreciated. Tahnks.
Logged
KodeZwerg
Hero Member
Posts: 1405
Fifty shades of code.
Re: How to add a border to a Label
«
Reply #1 on:
February 11, 2023, 12:09:35 pm »
Use TStaticText and choose a BorderStyle.
Use a TPanel, put a TLabel in, remove TPanel caption, set TPanel AutoSize = True.
Does one of above fit your needs?
Logged
«
Last Edit:
Tomorrow
at 31:76:97 by
KodeZwerg
»
KodeZwerg
Hero Member
Posts: 1405
Fifty shades of code.
Re: How to add a border to a Label
«
Reply #2 on:
February 11, 2023, 12:22:27 pm »
And if it really just needs to be one single TLabel and your desire is that big to just draw a border around, you can override the Forms OnPaint with something like this:
Code: Pascal
[Select]
[+]
[-]
Label2
.
Canvas
.
Rectangle
(
0
,
0
,
Label2
.
Width
,
Label2
.
Height
)
;
In attachment you see all three variations on Windows with native widgetset.
Label1 is the Panel version
Label2 is the OnPaint version
and static is static
Logged
«
Last Edit:
Tomorrow
at 31:76:97 by
KodeZwerg
»
KodeZwerg
Hero Member
Posts: 1405
Fifty shades of code.
Re: How to add a border to a Label
«
Reply #3 on:
February 11, 2023, 12:42:08 pm »
TShape would also be a possibility.
Place one on form and set for it this OnPaint handler:
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
Shape1Paint
(
Sender
:
TObject
)
;
var
lbl
:
string
;
begin
lbl
:
=
'TShape'
;
Shape1
.
Canvas
.
Font
.
Color
:
=
clBlack
;
Shape1
.
Canvas
.
Pen
.
Color
:
=
clDefault
;
Shape1
.
Canvas
.
TextOut
(
3
,
1
,
lbl
)
;
Shape1
.
Width
:
=
Shape1
.
Canvas
.
TextWidth
(
lbl
)
+
6
;
Shape1
.
Height
:
=
Shape1
.
Canvas
.
TextHeight
(
lbl
)
+
3
;
end
;
Logged
«
Last Edit:
Tomorrow
at 31:76:97 by
KodeZwerg
»
lainz
Hero Member
Posts: 4151
Re: How to add a border to a Label
«
Reply #4 on:
February 11, 2023, 04:24:22 pm »
Hi, you can use BGRAControls TBCLabel.
It supports border, and also gradient background.
Logged
https://github.com/lainz
|
https://leandro-oscar-ezequiel-diaz.blogspot.com
|
https://lainz.github.io/
seany
Jr. Member
Posts: 99
Re: How to add a border to a Label
«
Reply #5 on:
February 12, 2023, 11:46:37 am »
Hi
That's a great option... I would like to find a tutorial on BGRA controls please, and can it support border radius? thank you
Logged
jamie
Hero Member
Posts: 5362
Re: How to add a border to a Label
«
Reply #6 on:
February 12, 2023, 03:30:42 pm »
just drop a TPanel on there and use that as the label, it has caption and boarder control.
Logged
The only true wisdom is knowing you know nothing
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
How to add a border to a Label
TinyPortal
© 2005-2018