[Lazarus] autosize issue

Andrea Mauri andrea.mauri.75 at gmail.com
Fri Sep 10 15:48:48 CEST 2010


Zitat von "Juha Manninen (gmail)" <juha.manninen62 at gmail.com>:

> On Friday 10 September 2010 12:25:57 Lukasz Sokol wrote:
>> Isn't +10 the GroupBox's label/caption height in pixels ?
>
> Yes but it depends on widgetset and theme. There is no absolute  
> correct value,
> or the absolute value should be inspected at run-time somehow.
>
>> and the +2, something to do with the bezel or the line-around-groupbox
>> width ?
>
> Yes, there is a border and the coordinates are relative to ClientWidth and
> ClientHeight. In Delphi they are relative to the total Width and Height.
> All TWinControl descendants have this problem I am told.

Yes, all Delphi controls I tested use client coordinates relative to  
the left, top. That means a label put inside the frame of a TGroupBox  
with a frame width horizontal of 4 and a title height of 20 needs a  
Left=4 and Top=20.
When the frame width changes the label must be moved. To move it  
correctly you need the the frame width at designtime. But the VCL does  
not store this information in the dfm. This is not a big problem for  
Delphi apps, because they run only one target platform.

The LCL is meant for cross platform development and the frame width  
vary greatly, especially under gtk and qt. That's why the LCL uses  
coords relative to the inner frame. A label put at 0,0 stays at 0,0  
under MS Windows, Linux, OS X, ... This allows to edit+run a form  
under various platforms without storing theme information to the lfm.


> If you have some good default values, please let me know.

As this problem only rises when opening a dfm produced by Delphi, the  
offset depends solely on the theme used by Delphi. AFAIK there are not  
many combinations and only a few controls have child controls and a  
notable frame. I guess one offset per class will be sufficient for 99%  
of all Delphi apps.


Mattias







More information about the Lazarus mailing list