Make picture of Canvas1.graphics.drawPicture

Hi everyone
I’m trying to make a full HR jpg of the window2
My window2 is build with either (canvas hardcoded Backdrop) and ( Canvas1.graphics.drawPicture choose by listbox rightClick selection from window1 control)
But when i’m rendering the whole window2 ( including all place image )
Only the Hardcoded Backdrop image appear on jpeg

This is how i place scale image on window2.canvas

window2.Canvas1.graphics.drawPicture pic, 0,0,window2.Canvas1.Width,window2.Canvas1.Height, 0,0,PicWidth,PicHeight

and this is how i rendering the final window2

dim p as new Picture (window2.Width, window2.Height, 32) p.Save(f, Picture.SaveAsJPEG, 100)
I’v notice too, if i move the window out of the screen… then comeback…all ( Canvas1.graphics.drawPicture ) are erase
what i understand is that ( Canvas1.graphics.drawPicture ) is virtual… do i have to set it all backdrop
Thanks
( R.S. 2011 4.3 on win 7 )

window2.Canvas1.graphics.drawPicture pic,

Oooo, ouch! This way of drawing to the graphics object has been deprecated for several releases of RS/Xojo. You should not be doing this. That’s also why your pic goes away when the Screen needs refreshing.
Begin by changing your drawing to the paint event of your canvas.
g.DrawPicture pic, etc…
You will find that your canvas graphics now get refreshed. Then you can tackle the drawing of the window content

oupps… newbie mistake
Thanks
But how can i place my code in paint event
actually my code is in ( click ) and ( contextualmenu action ) of a listbox for pic selection

if hitItem.Text = "Position 1" then CanPos1.graphics.drawPicture pic, 0,0,249,176, 0,0,PicWidth,PicHeight return true end If

The code in your CanPos1.paint event is…

g.drawPicture pic, 0,0,249,176, 0,0,PicWidth,PicHeight

The shown code is…

if hitItem.Text = "Position 1" then CanPos1.invalidate return true end If
the variable pic must be declared to a scope that is available to both the above piece of code and your CanPos1 paint event

It work !! … of course you knew :slight_smile:
But
In my window2 i’v overlay all canvas over bigwhite rectangle… over bigger blue rectangle
On screen everything look fine… but in the final jpg the rectangle hide the canvas
is it matter with rendering method

dim p as new Picture (window2.Width, window2.Height, 32)

again trigger by button… not control it self
Thanks Roger

Layering controls, particularly canvases, is advised against. It can cause flickering, particularly on Win32, and can cause refresh anomalies as you are seeing. Can you maybe place your canvas on a container control and get the effects you are after by drawing in the container control’s paint event?

Thank you very much for your advice Roger
This forum community is very helpfull