Scrolling a canvas with controls on top

According to the documentation I should be able to scroll a canvas & controls that have that canvas as the parent will scroll with the canvas. I’m finding that the do indeed scroll until they are off the page (so to speak) but they don’t scroll back into the visible area again. Is this expected?

Wayne, this should work as you describe, and I do this in one of my applications. It works perfectly on the Mac, but Windows flickers horribly and the controls often get drawn incorrectly.

Make sure that you are positioning the scrolling canvas correctly in the window, and that other canvases aren’t above it in the z-order (old VB nomenclature) unless you want them to be. In the screenshot above, the scrolling canvas is “below” the header, toolbar and footer canvases and it’s .Top is positioned with the scrollbar.

Putting the following in the scrolling canvas’ MouseWheel event, and in the scrollbar’s ValueChanged event, will allow it to be scrolled by scrolling the mouse wheel (or two finger scrolling on the trackpad) while the cursor is over the canvas or with the scrollbar.

'Scrolling Canvas MouseWheel event
Function MouseWheel(index as Integer, X As Integer, Y As Integer, deltaX as Integer, deltaY as Integer) As Boolean
  scrSettings.Value = scrSettings.Value + deltaY
End Function

'Scrollbar ValueChanged event
Sub ValueChanged() 
  If Me.Enabled Then
    cvsSettings.Top = Me.Top - Me.Value 'Scrollbar min/max is set: 0 to (cvsSettings.Height - scrSettings.Height)
  End If
End Sub

Hi Bill

Thanks for your response. I’m not seeing the control - in my case a text area - reappear after it’s scrolled off the visible area. I am however using the canvas scroll method. I’ll try what you’re doing & see if that gives better results.

hi William Koperwhats
if I,m use Window OS .I try it but Nothing happens when I do MouseWheel event on canvas

I think the canvas has to have focus before the scroll wheel does anything on Windows

I’m click on canvas area befor MouseWheel event on canvas