Recent

Author Topic: Alignenment problem around a TImage component  (Read 2577 times)

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
Alignenment problem around a TImage component
« on: April 28, 2015, 05:49:20 pm »
I have a TImage component that is top, left and bottom anchored to a form.

The right side of the TImage should always remain at 450px from the right of my form.

The TImage should be able to display of any size and scale the content to fit within the TImage bounds.

To the right of the Image I have some text labels displaying info about the image.

I want the TImage to resize with the form, but leaving the 450px to the right for the labels, but I can't seem to get the correct set of anchors defined.

Can anyone give me a clue how to achieve this?

Everthying I try I end up with either the TImage filling the width of the form and/or the labels off the right hand side of the form.

-FM

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Alignenment problem around a TImage component
« Reply #1 on: April 28, 2015, 06:03:07 pm »
In code:
Code: [Select]
Image1.AnchorParallel(akRight, 450, Form1);
In Anchor Editor:
Right Anchoring must be enable, set 450 in spinedit, select Form in combo and click the speedbutton in the middle.

Then you can anchor labels to the right side of the image. (AnchorToNeighbour).

EDIT:
Code: [Select]
Label1.AnchorToNeighbour(akLeft, 10, Image1);
« Last Edit: April 28, 2015, 06:09:55 pm by Blaazen »
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
Re: Alignenment problem around a TImage component
« Reply #2 on: April 28, 2015, 06:16:00 pm »
The labels are Left anchored to the right edge of the TImage.

As soon as I set the TImage To Anchor right with a space of 450, the left side of the labels shoot off to the right by 450px...

-FM

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Alignenment problem around a TImage component
« Reply #3 on: April 28, 2015, 06:40:41 pm »
Ah, you are right, it set Image.BorderSpacing.Right to 450.

Solution: put there a GroupBox, TBevel or Panel with fixed width 450px and anchor the right side of the image to the left side of the GroupBox. Put labels to that groupbox (panel) or anchor them to TBevel (TBevel is not container).
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
Re: Alignenment problem around a TImage component
« Reply #4 on: April 29, 2015, 12:07:38 pm »
You know what.. I'd actually already tried various versions of that, but kept anchoring the wrong way around - too many attempts fuzzying my logic.

Your suggestion (and possibly a clear head this morning) put me in the right direction and it's all good now.

Thanks,

FM

 

TinyPortal © 2005-2018