# Moving a picture with a scrollbar

**URL:** <https://forum.xojo.com/t/moving-a-picture-with-a-scrollbar/32576>\
**Category:** macOS\
**Created:** [July 21, 2016, 1:57pm UTC](https://forum.xojo.com/t/moving-a-picture-with-a-scrollbar/32576 "2016-07-21T13:57:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christophe\_Blanc](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/ed8c4c/32.png) [@Christophe\_Blanc](https://forum.xojo.com/u/Christophe_Blanc)\
**Post date:** [July 21, 2016, 1:57pm UTC](https://forum.xojo.com/t/moving-a-picture-with-a-scrollbar/32576/1 "2016-07-21T13:57:05Z")

</div>

Hi,

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?

Thanks

Chris

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [July 21, 2016, 1:59pm UTC](https://forum.xojo.com/t/moving-a-picture-with-a-scrollbar/32576/2 "2016-07-21T13:59:58Z")

</div>

shouldn’t it be

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

---

<div class="post-metadata">

**Author:** ![Christophe\_Blanc](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/ed8c4c/32.png) [@Christophe\_Blanc](https://forum.xojo.com/u/Christophe_Blanc)\
**Post date:** [July 22, 2016, 4:41am UTC](https://forum.xojo.com/t/moving-a-picture-with-a-scrollbar/32576/3 "2016-07-22T04:41:27Z")

</div>

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.

![](http://Users/Chris/Desktop/Capture%20d%C2%92%C3%A9cran%202016-07-22%20%C3%A0%2006.39.50.png)

thanks

chris

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [July 22, 2016, 8:27am UTC](https://forum.xojo.com/t/moving-a-picture-with-a-scrollbar/32576/4 "2016-07-22T08:27:21Z")

</div>

> [@](#):
>
> 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?

---

<div class="post-metadata">

**Author:** ![Christophe\_Blanc](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/ed8c4c/32.png) [@Christophe\_Blanc](https://forum.xojo.com/u/Christophe_Blanc)\
**Post date:** [July 22, 2016, 8:57am UTC](https://forum.xojo.com/t/moving-a-picture-with-a-scrollbar/32576/5 "2016-07-22T08:57:46Z")

</div>

Hi Jeff,

Sorry for the picture  
I don’t know how to show it ☹  
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

```
pcao.backdrop=pp[/code]

```

thanks

![]()

---

<div class="post-metadata">

**Author:** ![Christophe\_Blanc](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/ed8c4c/32.png) [@Christophe\_Blanc](https://forum.xojo.com/u/Christophe_Blanc)\
**Post date:** [July 22, 2016, 8:58am UTC](https://forum.xojo.com/t/moving-a-picture-with-a-scrollbar/32576/6 "2016-07-22T08:58:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [July 22, 2016, 11:51am UTC](https://forum.xojo.com/t/moving-a-picture-with-a-scrollbar/32576/7 "2016-07-22T11:51:28Z")

</div>

> [@278429:@Christophe Blanc](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![Christophe\_Blanc](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/ed8c4c/32.png) [@Christophe\_Blanc](https://forum.xojo.com/u/Christophe_Blanc)\
**Post date:** [July 22, 2016, 12:05pm UTC](https://forum.xojo.com/t/moving-a-picture-with-a-scrollbar/32576/8 "2016-07-22T12:05:43Z")

</div>

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

Chris

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:24pm UTC](https://forum.xojo.com/t/moving-a-picture-with-a-scrollbar/32576/9 "2020-10-29T18:24:13Z")

</div>


