Embedding container into canvas

@Michel Bujardet in your example code mVerticalScrollBarLast is not updated. Is this maybe the reason why my Canvas does not scroll anymore? Or is it not needed in your code?

Yes, this would be a nice addition to have!
Please file a feature request and post the link here, so that everyone can subscribe it.

Created a feature request: <https://xojo.com/issue/39168>

After a few days and help from @Michel Bujardet, i finally found a good solution for a scrolling area with controls in it.

The goal was the following: simply show a vertical scrollbar and let the user scroll vertical until the last control is displayed at the bottom of the area where you want to display your controls. If there is nothing to scroll, because the window.height is large enough, there should be no scrolling or scrollbar. I started first with a container on a canvas, but i don’t need the container at the moment.

Lets see whats in the project:

1 Window (WndMain 300w x 370h)
1 Canvas (Canvas1 285w x 370h)
3 TextFields (placed WndMain.Top + 20, + 174, + 328)
1 VerticalScrollBar (VScrollBar 15 x 370h)

3 Integer Properties:

ControlWidth which takes the width of the controls you want to place in the scrolling area, default 260
VSpaceDemand which takes the vertical space needed to display all controls without scrolling, default 350
VScrollBarPosition which takes the vertical position of the ScrollBarIndicator.

Canvas1 MouseWheel Event:

  if WndMain.Height < VSpaceDemand then
    VScrollBar.Value = VScrollBar.Value + deltaY
    Return True
  end if

VScrollBar MouseWheel Event (same code as Canvas1 MouseWheel Event):

  if WndMain.Height < VSpaceDemand then
    VScrollBar.Value = VScrollBar.Value + deltaY
    Return True
  end if 

VScrollBar ValueChanged Event:

  Dim delta As Integer
  delta = VScrollBarPosition - Me.Value
  Canvas1.Scroll(0, delta)
  VScrollBarPosition = Me.Value

WndMain Close Event:

Quit

WndMain Open Event:

  if WndMain.Height > VSpaceDemand then
    VScrollBar.Visible = False
    if TextField1.Width = ControlWidth - VScrollBar.Width then
      TextField1.Width = ControlWidth
      TextField2.Width = ControlWidth
      TextField3.Width = ControlWidth
      Canvas1.Refresh
    end if
  else
    VScrollBar.Visible = True
    if TextField1.width = ControlWidth then
      TextField1.Width = ControlWidth - VScrollBar.Width
      TextField2.Width = ControlWidth - VScrollBar.Width
      TextField3.Width = ControlWidth - VScrollBar.Width
      Canvas1.Refresh
    end if
  end if
  
  VScrollBar.Maximum = Canvas1.Height

WndMain Resized Event:

  if WndMain.Height > VSpaceDemand then
    VScrollBar.Visible = False
    if TextField1.Width = ControlWidth - VScrollBar.Width then
      TextField1.Width = ControlWidth
      TextField2.Width = ControlWidth
      TextField3.Width = ControlWidth
      Canvas1.Refresh
    end if
  else
    VScrollBar.Visible = True
    if TextField1.width = ControlWidth then
      TextField1.Width = ControlWidth - VScrollBar.Width
      TextField2.Width = ControlWidth - VScrollBar.Width
      TextField3.Width = ControlWidth - VScrollBar.Width
      Canvas1.Refresh
    end if
  end if
  
  if WndMain.Height < VSpaceDemand then
    VScrollBar.Maximum = Canvas1.Height - WndMain.Height
  else
    VScrollBar.Value = 0
    VScrollBar.Maximum = Canvas1.Height
  end if

I made a small Screencast to show the result. You can watch it on Vimeo.