Problem with erased background when moving a desktop canvas

I am programming a Poker Squares card game.
The player can move a card from a pile to the destination place, while the card (desktop canvas) follows the mouse.
My problem is, that the controls behind the moving card are always erased.
I found a solution with drag drop picture, but my index finger is getting tired too soon…
Then i found a solution with a timer which refreshes the window while moving the card, but there are still short artefacts of the erased background which irritates the eyes.
Maybe someone can help me?
Thanks a lot, Rolf.

Your cards and pile should all be graphics drawn on the canvas.
if you use controls, you can never get rid of the flicker.

eg dont move a desktop canvas, draw the card every time the canvas repaints.


sub class a canvas, span this over your window as play field.
draw all cards as you need. make a method DrawCard(g as Graphics) and call this from paint event.
if you call .Refresh it invalidate the canvas so the Paint Event in called.
Rect have methods like Contains or Intersects, you could use this for painted buttons,
to know if mouse is inside.

Well, i think i really have to learn more about the desktop canvas. Until now, i only used it to display an image…
Thank you very much for your helpful replies!
Yours, Rolf.

Well, i was programming a few small games in vb6, but i didnt had this problem there as far as i can remember.
Xojo is similar to vb6, but not exactly the same…:slightly_smiling_face:

Have a look at the example program supplied with Xojo in the graphics section:
Canvas DrawDrag

1 Like

Thank you very much for your advice, dear Jeff and Markus :slightly_smiling_face:
I will try both and i really hope to get deeper into Xojo with time :slightly_smiling_face:
Yours, Rolf.