Consider this form, with a label 'Observer here' and a button 'Click':
On button click I am setting the label's Left
to 10 (Label1.Left :=10;
)
I am getting correctly as in the second image:
Then, I scroll the form to the right:
Now, after clicking the button I get a problem, which is shown in 4th image:
The label's Left
is not 10 anymore. It's more than 10, but I need it to be 10. How can I do that?
Label1.Left := 10 ; Means 10 left from the current border(form1.left).
so Label1.Left := 10 ; will not produce the same result always ,It depends on Form1.HorzScrollBar.Position ;
You have to code like
Label1.Left := 10 - Form1.HorzScrollBar.Position ;
You can see this pattern on design time by select a component in your form1 and adjust the scroll bar ,you can notice that in the object Inspector left value of the selected component will also change when moving the scrollbar
You can understand it like this
If you have HorzScrollBar then if you add components and set their left value very high, the form1 will not increase its width but its virtual width handled by scrollbar will get increased, all the coordination values will give the value relative to form1 not related to the virtual space
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With