Canvas Backdrop Not Updating?

I’m using a picture array to store pictures that my program has scanned into it from a folder. I’m setting the initial canvas backdrop image from the 0 index of the picture array on window open, not in canvas paint as per the LR.

I’m then trying to use a timer to walk through the picture array and change the canvas backdrop every 15 seconds. I have verified the picture array is populated correctly. I have verified the timer is firing. But my canvas backdrop never updates???

What do I need to do to get the canvas backdrop to update correctly from the timer? Thanks!

My timer code:

intPicCount is the Ubound value from my picture array.

intNextPic is a property of my window.

[code] if intPicCount <= intNextPic then

cnvMain.Backdrop = pSlideShow(intNextPic)
intPicCount = pSlideShow.Ubound

intNextPic = intNextPic + 1

cnvMain.Refresh

else

intNextPic = 0

end[/code]

try this instead

timer code

 if intPicCount <= intNextPic then
    intPicCount = pSlideShow.Ubound
    intNextPic = intNextPic + 1
  else
    intNextPic = 0
  end
  cnvMain.Invalidate

cnvMain PAINT event

  g.drawpicture pSlideShow(intNextPic),0,0

I would have expected that you were missing an invalidate or refresh, but I see you have one.

I think the most likely issue here is that intNextPic is always 0

Where is it defined?
If it is done in the timer as

dim intNextPic as integer

there every time the timer fires, it will be 0, then one

If so, change

dim intNextPic as integer

to read

static  intNextPic as integer

or make intNextPic a property pf the window

Thanks Dave!

I thought about trying that but I was hoping I could just update the backdrop. Maybe it’s not possible to change the backdrop on the fly?

Thanks Jeff!

intNextPic is a global propery of my window. That’s exactly what I thought at first too! So I added a label to my canvas and intNextPic is incrementing as I expected it to.

Thanks to you both.

Should it not be :

if intNextPic <=  intPicCount then

As it stands, your code probably does not execute at all, since intPicCount is always > intNextPic

OK…
You can change the backdrop on the fly,
Try refreshing the window, as well as/ instead of the canvas?

I dont use backdrops myself.
I would just refresh the canvas, and have the paint event of the canvas draw ‘whatever the current picture is’

Basically what Dave said

Timer code:

intNextPic = intNextPic + 1 intNextPic = intNextPic mod pSlideShow.Ubound cnvMain.Invalidate

canvas code:

 g.drawpicture pSlideShow(intNextPic),0,0

edit: which covers Michel’s point too… no point comparing the value as you currently do

Thanks for the replies. There may very well be some kind of oversight I missed in the comparison logic. I’ll take another look thank you guys!

Yeah that was it. I just didn’t have the if statement correct. Thanks a lot. Not having a great week anyways. :confused:

[quote=295894:@Michel Bujardet]Should it not be :

if intNextPic <=  intPicCount then

As it stands, your code probably does not execute at all, since intPicCount is always > intNextPic[/quote]