DBase= New SQLiteDatabase
If DBase.Connect() Then
DBase.SQLExecute(“CREATE TABLE Drawing(ID INTEGER, Pic BLOB)”)
DBase.Commit
rec.IntegerColumn(“ID”)=1
rec.PictureColumn(“pic”) = pic
DBase.InsertRecord(“Drawing”, rec)
MyRec = DBase.SQLSelect(“SELECT * FROM Drawing WHERE ID=1”)
ID.Text = MyRec.Field(“id”)
Canvas2.Backdrop= MyRec.Field(“Pic”)
End If
DBase.Close[/code]
Drawing to Canvas.Graphics has been deprecated and is strongly discouraged. As a matter of fact, the Graphics property is not even part of the LR about Canvas at http://documentation.xojo.com/index.php/canvas ; it is recommended to use the Paint event instead.
That said, you can very well create a picture for the backdrop and use Canvas1.Backdrop.Graphics.
Add pic and pic2 as picture as properties of the window
In Canvas 1 :
Sub Open()
#If TargetWin32 then
App.UseGDIPlus = True
#Endif
pic = new picture(me.width,me.height)
me.backdrop = pic
Canvas1.Backdrop.Graphics.DrawLine(100,100,600,100)
Canvas1.Backdrop.Graphics.DrawOval(100,100,50,50)
End Sub
I used the explicit name Canvas1 for demonstration, but it would be better to use me.Backdrop.Graphics
In Canvas2 :
Sub Open()
#If TargetWin32 then
App.UseGDIPlus = True
#Endif
pic2 = new picture(me.width,me.height)
me.backdrop = pic2
End Sub
In a button :
Sub Action()
Canvas1.DrawInto(Canvas2.Backdrop.Graphics, 0,0)
Canvas2.Invalidate
End Sub
Canvas2.Invalidate is necessary to update its display.
I have try every think.
I have make a button with:
Sub Action Button Clear
pic = new picture(Canvas1.Width, Canvas1.Height)
Canvas1.Refresh
Canvas1.Invalidate
Canvas1.EraseBackground=False
Canvas2.Refresh
End Sub
But the results are nothing: the drawing is still in the cacans or in the Pic???
[quote=226156:@Hans Riemers]I have try every think.
I have make a button with:
Sub Action Button Clear
pic = new picture(Canvas1.Width, Canvas1.Height)
Canvas1.Refresh
Canvas1.Invalidate
Canvas1.EraseBackground=False
Canvas2.Refresh
End Sub
But the results are nothing: the drawing is still in the cacans or in the Pic???[/quote]
As Michel instructed, do all your drawing into a Picture which is a property of the window. In Canvas1.Paint and Canvas2.Paint, simply use DrawPicture to show the drawing in the canvas. To clear the canvas(es), create a blank picture and refresh/invalidate the canvas.