Function Dibujo(guibank) canvas=PeekInt(guibank,4) draw=PeekInt(guibank,12) Select EventID() Case $203 If ButtonState(draw) SetBuffer CanvasBuffer(canvas) Plot EventX(),EventY() FlipCanvas canvas EndIf End Select End Function
As you see, I wiped half the function contents. Also, I replaced MouseX and MouseY with EventX and EventY. And I narrowed down the opened canvasbuffer to strictly the area where it's needed.
I wouldn't base a designtool on this structure tho. Correct way is to draw into an image buffer and draw this imagebuffer onto a canvas.
Additionally, you want to use the events $201 and $202 for mousedown and mouseup rather than a draw checkbox.