Lazarus
Home
Forum
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
LCL
»
How i insert text in a TShape?
Downloads
Daily Snapshots
FAQ
Wiki
Bugtracker
IRC channel
Developer Blog
Follow us on Twitter
Mailing List
Free pascal
Other languages
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
About donations (wiki)
Bookstore
Lazarus, the complete guide
Search
Advanced search
« previous
next »
Print
Pages: [
1
]
Author
Topic: How i insert text in a TShape? (Read 495 times)
celso.lom
Newbie
Posts: 3
How i insert text in a TShape?
«
on:
February 02, 2012, 05:14:01 pm »
I created a TShape in runtime and i need to insert text in. How i do this?
Logged
felipemdc
Administrator
Hero Member
Posts: 3162
Re: How i insert text in a TShape?
«
Reply #1 on:
February 02, 2012, 05:32:37 pm »
Create a TCustomControl descendent and in its Paint method you can draw your shape using TCanvas routines and also draw the text:
http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Create_a_custom_control_which_draws_itself
See also:
http://lazarus-ccr.sourceforge.net/docs/lcl/graphics/tcanvas.html
Logged
typo
Hero Member
Posts: 1368
Re: How i insert text in a TShape?
«
Reply #2 on:
February 02, 2012, 05:42:23 pm »
Code:
[Select]
YourShape.Canvas.TextOut(0,0,'abc');
Logged
LazarusBrasil.Org
felipemdc
Administrator
Hero Member
Posts: 3162
Re: How i insert text in a TShape?
«
Reply #3 on:
February 02, 2012, 06:35:40 pm »
Quote from: typo on February 02, 2012, 05:42:23 pm
Code:
[Select]
YourShape.Canvas.TextOut(0,0,'abc');
Indeed that might work, but should only be used inside the OnPaint event of the shape.
Logged
celso.lom
Newbie
Posts: 3
Re: How i insert text in a TShape?
«
Reply #4 on:
February 02, 2012, 06:36:38 pm »
I tested the "TShape.Canvas.TextOut." By moving the TShape the text disappears. I create the TShape at runtime, and I would definitely put the text inside. Is there another way?
Translated from portuguese on Google Translator.
Logged
typo
Hero Member
Posts: 1368
Re: How i insert text in a TShape?
«
Reply #5 on:
February 02, 2012, 06:52:33 pm »
Test what Felipe said.
Logged
LazarusBrasil.Org
celso.lom
Newbie
Posts: 3
Re: How i insert text in a TShape?
«
Reply #6 on:
February 02, 2012, 07:08:00 pm »
I tested what Felipe said and it worked. As I am creating buttons dynamically, the procedures have to be dynamic. Added value to TShape.Caption and recovered within the procedure. Thanks!
Translated from portuguese on Google Translator.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
LCL
»
How i insert text in a TShape?
Recent
StringGrid.LoadFromCSVFil...
by
tedsmith
[
Today
at 11:17:52 pm]
TaChart ternary plot func...
by
ccrause
[
Today
at 10:53:15 pm]
Things went wrong install...
by
garlar27
[
Today
at 10:46:45 pm]
Installing Lazarus/FPC on...
by
Bruce Mayo
[
Today
at 10:21:17 pm]
"Tween" two images
by
TheBlackSheep
[
Today
at 09:38:04 pm]
another bug?
by
circular
[
Today
at 08:36:16 pm]
BGRABitmap 5.7.1 won't co...
by
circular
[
Today
at 08:24:59 pm]
Q about capabilities of t...
by
ludob
[
Today
at 07:39:16 pm]
Cross Compile
by
Leledumbo
[
Today
at 05:23:05 pm]
Stable database?
by
BigChimp
[
Today
at 03:27:28 pm]