Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are there advantages to using Static Text instead of Label in Delphi?

From the docwiki for labels:

You place a label on a form when you need to identify or annotate another component such as an edit box or when you want to include text on a form. The standard label component, TLabel, is a non-windowed control, so it cannot receive focus; when you need a label with a window handle, use TStaticText instead.

What does the statement "when you need a label with a window handle, use TStaticText instead" mean?

like image 756
Michael Riley - AKA Gunny Avatar asked Aug 16 '14 23:08

Michael Riley - AKA Gunny


3 Answers

Also, if you're creating forms that need to work with screen readers for visually impaired users, TLabels can't be seen by the software, but TStaticText labels can.

like image 176
David Schwartz Avatar answered Nov 17 '22 15:11

David Schwartz


At work, we use a TStaticText when we want our UI automation testing tool to 'read' the text of a "label". Most of the interaction is done by Windows API messaging, so a TStaticText will respond to GetWindowText, while a TLabel will not. This is a simplistic overview on how we use TStaticText and a TLabel.

like image 37
Nicholas Ring Avatar answered Nov 17 '22 15:11

Nicholas Ring


Cut and pasted from Embarcadero

The TStaticText component functions like TLabel, except that it descends from TWinControl and therefore has a window handle. Use TStaticText instead of TLabel when the component's accelerator key must belong to a windowed control—for example, on an ActiveX property page.

like image 2
Lars Avatar answered Nov 17 '22 17:11

Lars