You can call a method (for example “DrawSomething”) from the paint event of the canvas by passing the graphics object to the method like this:
DrawSomething(g)
Of course the method “DrawSomething” needs to have a parameter “g as Graphics”.
Then in the method “DrawSomething” you can do your drawing onto g (the graphics object of the canvas), for example like this:
g.DrawRect(...)
g.DrawPicture(ToonFoto, ...)
Everytime you call Canvas.Invalidate (for example from a timers “Action” event) the canvas will do the (re)drawing.
Also in this case, all drawing is done via the paint event, like Dave already said.
Strange thing is that I was able to run my RS2012 code in Xojo just about a year ago without too much changes. I was considering the switch then also, but the party I develop this project for was not ready for an investment yet. So this must have been removed in a recent Xojo update?
BUT: I was able to make a start in solving this…
I am now doing all my “old” stuff in a picture instead and draw that picture onto the canvas. This way I have my old code up and running in Xojo in a couple of days without having to do massive rewrites. I can see what I can improve from there on.
[quote=462435:@Dave S]You don’t. period.
All actions on a canvas must be done via that canvas PAINT event
this was changed sometime after 2012[/quote]
Now with 19r2, this is a “Have To” way to do it.
I feel the same as back then with threads updating GUI elements, but for me, these changes are fine.
Needs to updating a lot of code, but I’m not angry about.
Hint for programmers that want change graphics displayed in a Canvas:
Set a global variable, then call Canvas.invalidate now, instead of manipulating from within code.
There’s a lot deprecated, but most of it is still working in the newest Xojo. The only thing that I needed to fix right away was this canvas stuff, because that was not working anymore. But that is solved now! I used a local picture instead and was able to make it work with minor changes.
My project is running again and in the next few weeks I am going to replace old code with new.
Ah oke, thanks. English is not my first language and I was under the assumption it meant “removed”. But Google Translate explains that it means that it is still working, but is discouraged to use