Moving a picture with a scrollbar


I move a picture in a canvas with a scrollbar. It worked for years but it is not working anymore for a few months.
I don’t understand why, here are the code I am using.
in the paint event of the canvas:

if pp<>nil Then g.DrawPicture pp,0,0,pp.Width-ScrollBar2.Value,pp.Height-ScrollBar1.Value,ScrollBar2.Value,ScrollBar1.Value else g.DrawString "Nil",10,50 end if
in the open event of the scrollbar : p=new picture(1000*defE,250*defE,0) me.Maximum=p.width-Pcao.width
in the value changed event of the scrollbar : self.Refresh

I guess when changing from carbon to cocoa something has changed, maybe somebody can explain what?



shouldn’t it be

g.drawpicture pp,0,0,g.width,g.height ,   scrollbar2.value,scrollbar1.value, g.width,g.height

Hi Dave,

same result, as you can see on the picture below, the background is not erase and I get the 2 same pictures on top of each other.



Cant see your image, but
-is the canvas set to erasebackground = true
-are you ALSO setting a .backdrop property somewhere?

Hi Jeff,

Sorry for the picture
I don’t know how to show it :frowning:
The canvas is set to erasebackground = true
and yes for the second question.
I am drawing with an object2d which I append to my picture pp and then canvas.backdrop=pp, see code below
is it a problem?

[code] pp.objects.append d



I try again to post the image but it’s not working either, sorry for this

You cannot simply paste a picture into the editor. Put the picture on dropbox and post the public link.

Thanks Michel, I’ll know for next time. The image is not very important in this case.