Forum > LCL

problem with label alignment in pagecontrol

(1/6) > >>

Hi everyone i have spotted this problem long ago and i think i've reported here also
It's been happening since a several versions before last (2.2.4).
tested on lazarus fixes (2.2.5) on windows 11 but it happens with previous stable versions also in windows 10 (i recall). WIll try on linux after
Test like this:

new application
drop pagecontrol
create two tabs
create 3 labels on each tab
set alignment to the first (in the two tabs) to left
set alignment to the sencond (ijn the two tabs) to center
set alignment to the third  (in the two tabs) to right.
on formshow write a number (or any text) on each label and this happens:
when i compile and run (f9) and focusing on the first tab when application runs the labels on the first tab are well aligned but in the sencond all are left aligned.
close and return to lazarus
focus on second tab and run again (f9) and labels on second tab are well aligned but in the first all appear left aligned.
it puzzles me so the only solution i found is use string functions to align labels and fixed font size for numbers appear well aligned.
Hope i was clear with the procedure.
Thanks to all!

Something is missing here: Are the labels autosized? And where are they? When AutoSize=true, how can you tell whether the text is left-aligned/centered/right-aligned?

When I place three labels on each tab, set their Align to alTop so that they extend over the full width of the tab and set the Alignment to taLeftJustify, taCenter and taRightJustify everything is fine. The same observation when I turn AutoSize off and grow the width of the labels so that they extend over the tab width.

all other options are default ones.
they are put in the ttab one behind the other
its easy to know if they are rigth aligned, when i load numbers with 2 decimals if the align is right its easy to notice. (ej 12.23 and 4832.33)
Change the align to right only and you will see it
im not usign align only aligment

Please post a project for clarification.

Well, there is something indeed - when the code for setting captions of labels is put in FormCreate event (as I/we usually do) all seems OK but when it is written inside  FormShow the strange behaviour (described by TS) occurs. Tested on Lazarus 2.2.0 (rev lazarus_2_2_0) FPC 3.2.2 x86_64-win64-win32/win64, IDE set as docked. See below:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormShow(Sender: TObject);begin  label1.caption:='111.11';  label2.caption:='222.22';  label3.caption:='333.33';  //label2.left:=label1.Left; //needed to keep position unchanged  //label3.left:=label1.Left; //needed to keep position unchanged   label4.caption:='444.44';  label5.caption:='555.55';  label6.caption:='666.66'; end;  


[0] Message Index

[#] Next page

Go to full version