Lazarus

Programming => LCL => Topic started by: Ten_Mile_Hike on June 11, 2021, 06:28:35 am

Title: Solved Tscrollbar has a caption property ???
Post by: Ten_Mile_Hike on June 11, 2021, 06:28:35 am
Using 2.0.12
How long has Tscrollbar have a caption property?
Tscrollbar isn't supposed to have a caption property is it? I'm confused.

Place a scrollbar 'SB1' on a form

Procedure test;
Begin
SB1.caption:= 'This works';
Form1.caption:=SB1.caption+', but why?' ;
End;
Title: Re: Tscrollbar has a caption property ???
Post by: Handoko on June 11, 2021, 06:40:04 am
As far as I know, all of the visual components have a caption property. They maybe not directly useful to you but it could be useful if you write a class inherited from them.

For example, the default TListBox has caption but it won't be visible to users. If I subclass it to TMyListBox, I may want to show a caption right above the position of the listbox. Something like: "Please select a category:".
Title: Re: Tscrollbar has a caption property ???
Post by: Ten_Mile_Hike on June 11, 2021, 06:46:53 am
Shouldn't "Caption"  be listed as a property in the documentation then???
I can find no mention of a "caption" property for Tscrollbar anywhere in the documentation.
Title: Re: Tscrollbar has a caption property ???
Post by: Handoko on June 11, 2021, 06:49:08 am
Yes, it is documented on its ancestor class:
https://lazarus-ccr.sourceforge.io/docs/lcl/controls/tcontrol.html (https://lazarus-ccr.sourceforge.io/docs/lcl/controls/tcontrol.html)

When you study a class by reading the documentation, it's usually useful to read the documentation of its parent class too.
Title: Re: Tscrollbar has a caption property ???
Post by: Ten_Mile_Hike on June 11, 2021, 07:41:39 am
Thank you for your answer.
I'm new here. I don't know how to mark this topic as "answered", but I've been up for 20 hours
so maybe that has something to do with it.
Title: Re: Tscrollbar has a caption property ???
Post by: trev on June 11, 2021, 08:09:40 am
Click "Modify" in your first post and prefix the original subject line with [SOLVED].
Title: Re: Tscrollbar has a caption property ???
Post by: MarkMLl on June 11, 2021, 09:38:39 am
Thank you for your answer.
I'm new here. I don't know how to mark this topic as "answered", but I've been up for 20 hours
so maybe that has something to do with it.

Don't worry, nobody's criticising you for it :-)

But as Handoko says, really you /do/ need to look back through ancestors since while they're very often marked "do not use directly" in many cases half of the functionality is only documented there.

I suggest keeping these as bookmarks somewhere:

https://www.freepascal.org/docs.html
https://lazarus-ccr.sourceforge.io/docs/

Those are for current FPC and Lazarus. Even though they appear to duplicate the RTL and FCL links, the versions might be different.

MarkMLl
TinyPortal © 2005-2018