Coordinates in a TScrollBox

I am writing a component that includes a TScrollBox. Into this ScrollBox I put several labels (TLabel). After inserting a Label I increase the position variables (CurrentX, CurrentY) to identify the position for the next label that may be inserted.
All this works fine if I do not scroll the client area of the ScrollBox.
If I scroll it e.g. downwards, the next label I insert will be placed incorrectly. CurrentX and CurrentY seem to be the absolute coordinates of the clientArea of the ScrollBox.
How can I convert them into logical coordinates to place the labels correctly, even if I scroll the field?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

How are you getting/setting the positions?
something along the lines of
label[i].top := label[ii].top-label[ii].height;
should work where ii is last label inserted,i is new label..we did something on a question here like this adding panels to the scrollbox.
remember also you can set the labels align property to alTop
as each label is added they will be added directly below the last label.
hi klusi,

what about this

  X : Integer = 10;
  Y : Integer = 10;

procedure TForm1.Button1Click(Sender: TObject);
var L : TLabel;
  L := TLabel.Create(Self);
  L.Top := Y - ScrollBox1.VertScrollBar.Position;
  L.Left := x;
  L.Caption := 'Label at '+inttostr(x)+':'+inttostr(y));
  L.Parent := ScrollBox1;
  Y := Y + l.Height + 2;  //prepare for next line


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
klusiAuthor Commented:
Thank you. I tried it out and it worked perfectly.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.