Jump to content


Photo

Help centering image in scrollbox

TW3Image image TW3Scrollbox Scrollbox resize

  • Please log in to reply
3 replies to this topic

#1 ielite

ielite
  • Members
  • 704 posts

Posted 21 October 2016 - 04:40 AM

I have a TW3Scrollbox on my layout. On the scrollbox I have a TW3Image, which I am trying to place below a label (fDates) and center it in the Scrollbox. The images is 150 X 150.

 

I can't seem to get the image to display in the correct position using setbounds. Its always off to the right.  

when I use showmessages to display the image width and height, those are off too.

 

How do I get the image to be sized 150 X 150 and center in the scrollbox?

 

procedure TfrmNavigation.ResizeContent;
begin


 fImage.SetBounds((fScrollBox.Content.clientWidth div 2)-75,
                   fDates.Top + fDates.Height,
                  (fScrollBox.Content.clientWidth div 2)+75,
                   fDates.Top + fDates.Height + 150);


end;


procedure TfrmNavigation.Resize;
begin
  inherited;
  if assigned(FLayout) then
  begin
    FLayout.Resize(self);
    ResizeContent;
  end;
end;



  • two_dog_knight and Natthercress like this

#2 ielite

ielite
  • Members
  • 704 posts

Posted 21 October 2016 - 05:23 PM

here is  the code and some test links

 

 

code
 
browser test
 
Mobile Test

  • two_dog_knight likes this

#3 DavidRM

DavidRM
  • Members
  • 56 posts
  • LocationTulsa, OK

Posted 21 October 2016 - 06:59 PM

SetBounds is (Left, Top, Width, Height), isn't it? So you wouldn't want to change the width and height of the image. Just use the values 150, 150 (or the image Width/Height properties).

 

Something like:

fImage.SetBounds((fScrollBox.Content.clientWidth - 150) div 2,
                   fDates.Top + fDates.Height,
                  150, 150);

  • ielite and two_dog_knight like this

#4 ielite

ielite
  • Members
  • 704 posts

Posted 21 October 2016 - 07:41 PM

darn, how did i not see that?

 

thanks for the bump


  • two_dog_knight likes this





Also tagged with one or more of these keywords: TW3Image, image, TW3Scrollbox, Scrollbox, resize

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users