Recent

Author Topic: [SOLVED] Scrollbox horizontal scrollbars now showing up  (Read 3130 times)

spassigl

  • New Member
  • *
  • Posts: 21
[SOLVED] Scrollbox horizontal scrollbars now showing up
« on: March 08, 2021, 06:37:54 pm »
Hi, I've been trying and searching everything but there's something I'm missing I'm afraid.

On a form, I have a tabbed interface, and inside one of the tabs, I have a TScrollbox.
At run-time, I create my own control to be hosted in the scrollbox. The control is a TWinControl descendant.
Hierarchy is like this:
- TPageControl
  - TTabSheet
     - TScrollbox
        - TGraphicEditor (my component, descendant of TWinControl)

All components except for TGraphicEditor are aligned as alClient.
TGraphicEditor is aligned as alCustom.

I create my component this way:

Code: Pascal  [Select][+][-]
  1. procedure TMainForm.SetupGraphicsEditor;
  2. begin
  3.    GraphicEditor := TGraphicEditor.Create(Self);
  4.    with GraphicEditor do
  5.    begin
  6.       Parent := GraphicalScrollBox;
  7.      Align := alCustom;
  8.      Anchors := [akTop, akLeft, akRight, akBottom];
  9.      Visible := true;
  10.       Width := GraphicalScrollBox.Width;
  11.       Height := GraphicalScrollBox.Height;
  12.       Constraints.MinWidth := GraphicalScrollBox.Constraints.MinWidth;
  13.       Constraints.MinHeight := GraphicalScrollBox.Constraints.MinHeight;
  14.       Resize;
  15.    end;
  16. end;
  17.  

So far so good.

But - there are circumstances when the GraphicEditor becomes bigger than the scrollbox. I'm expecting the scrollbox to show the scrollbars but it does not.
See attached picture.

Anything I'm clearly missing here?

« Last Edit: March 09, 2021, 06:59:26 pm by spassigl »

jamie

  • Hero Member
  • *****
  • Posts: 4569
Re: Scrollbox horizontal scrollbars now showing up
« Reply #1 on: March 09, 2021, 02:10:32 am »
for the scrollbars to show first you need to ensure "AutoScroll" is checked for the TScrollbox…

second, if you are setting the constraints of the child control to the constraints of the scrollbox then I would say you will never see the scrollbars.

 Not sure what your intended use is for the scroll box but its designed to simulate a larger client area than what is being shown so this means child controls that map off the current client size of the scrollbox should make the scrollbars appear and allow you to scroll over and view your child controls..

 if you are looking for something like a ruler then you are using the wrong controls
The only true wisdom is knowing you know nothing

spassigl

  • New Member
  • *
  • Posts: 21
Re: Scrollbox horizontal scrollbars now showing up
« Reply #2 on: March 09, 2021, 10:16:14 am »
Thanks, yes I just want to simulate a larger client area than what is being shown.

Yes Autoscroll is set to True;
I removed the constraints code (even if they were on the min size) but still scrollbars don't appear.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1474
  • Former Delphi 1-7, 10.2 user
Re: Scrollbox horizontal scrollbars now showing up
« Reply #3 on: March 09, 2021, 11:34:31 am »
Operating system? Widgetset? Lazarus version?
Lazarus 2.1 r65061 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r65182 FPC 3.3.1 r49223 macOS 11.4 aarch64 Xcode 12.4
Lazarus 2.1 r61574 FPC 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

spassigl

  • New Member
  • *
  • Posts: 21
Re: Scrollbox horizontal scrollbars now showing up
« Reply #4 on: March 09, 2021, 12:18:41 pm »
Fedora 32 - Linux 5.10.16
GTK2
Lazarus 2.0.10 - FPC 3.2.0

jamie

  • Hero Member
  • *****
  • Posts: 4569
Re: Scrollbox horizontal scrollbars now showing up
« Reply #5 on: March 09, 2021, 05:22:06 pm »
Did u enable / visible property of the scrollbars to true?
You have two and they need to be visible.
The only true wisdom is knowing you know nothing

spassigl

  • New Member
  • *
  • Posts: 21
Re: Scrollbox horizontal scrollbars now showing up
« Reply #6 on: March 09, 2021, 05:44:33 pm »
Yes, obviously. They are Visible by default and I have not touched them.
Literally, I only dropped the Scrollbox on the form and did not touch anything, apart from setting its alignment to alClient.
I have added some debug info in the OnResize event of my control.  See below.
I have added a button that increases the size of my control of 10px on every click.
Parent is the Scrollbox, Self is my control. As you can see, my control width becomes bigger while the Scrollbox width stays the same. I assume this should show the scrollbars but it's not happening.

Parent size - (t,l,w,h): (0,0,1155,776)
Self size - (t,l,w,h): (0,0,1163,774)
Parent size - (t,l,w,h): (0,0,1155,776)
Self size - (t,l,w,h): (0,0,1173,774)
Parent size - (t,l,w,h): (0,0,1155,776)
Self size - (t,l,w,h): (0,0,1183,774)
Parent size - (t,l,w,h): (0,0,1155,776)
Self size - (t,l,w,h): (0,0,1193,774)
Parent size - (t,l,w,h): (0,0,1155,776)
Self size - (t,l,w,h): (0,0,1203,774)
Parent size - (t,l,w,h): (0,0,1155,776)
Self size - (t,l,w,h): (0,0,1213,774)
Parent size - (t,l,w,h): (0,0,1155,776)
Self size - (t,l,w,h): (0,0,1223,774)

korba812

  • Full Member
  • ***
  • Posts: 172
Re: Scrollbox horizontal scrollbars now showing up
« Reply #7 on: March 09, 2021, 06:03:03 pm »
Looking at your code, I can say that there is nothing to scroll because your GraphicsEditor always fits into the scrollbox.

To see what the problem is, try this code:
Code: Pascal  [Select][+][-]
  1. procedure TMainForm.SetupGraphicsEditor;
  2. begin
  3.    GraphicEditor := TGraphicEditor.Create(Self);
  4.    with GraphicEditor do
  5.    begin
  6.       Parent := GraphicalScrollBox;
  7.      Align := alCustom;
  8.      Anchors := [akTop, akLeft];
  9.      Top := 0;
  10.      Left := 0;
  11.      Visible := true;
  12.       Width := 4000;
  13.       Height := 4000;
  14.    end;
  15. end;

spassigl

  • New Member
  • *
  • Posts: 21
Re: Scrollbox horizontal scrollbars now showing up
« Reply #8 on: March 09, 2021, 06:34:52 pm »
Well I had tried that as the first thing a couple of days ago, just to see if forcing a wider size would show the scrollbars.
No luck.

I'm starting to believe the problem is because the scrollbox is in a tabsheet?

korba812

  • Full Member
  • ***
  • Posts: 172
Re: Scrollbox horizontal scrollbars now showing up
« Reply #9 on: March 09, 2021, 06:44:41 pm »
Did you notice "Anchors" in my example?
Code: Pascal  [Select][+][-]
  1. Anchors := [akTop, akLeft];

spassigl

  • New Member
  • *
  • Posts: 21
Re: Scrollbox horizontal scrollbars now showing up
« Reply #10 on: March 09, 2021, 06:53:40 pm »
Shoot - that was the issue! Never thought about the anchors as an issue.

Thanks a bunch!

 

TinyPortal © 2005-2018