canvas exists ?

BlitzPlus Forums/BlitzPlus Programming/canvas exists ?

Timjo(Posted 2007) [#1]
Is there a way to determine whether or not a previously created canvas is still present. I have an application with several canvases open at once. Depending on the actions of the user, some may be freed at any time. I know I can check for various gadget events to keep track of windows/gadgets, but is there a way to see if a canvas is still in memory before I use a command like 'mousex(canvas)' - which will generate an error if that canvas no longer exists. Thanks.


Dabz(Posted 2007) [#2]
Well, if you create a canvas, then free it, you should make sure the handle is null (or 0), then you can do something like:-

hCanvas = CreateCanvas(blah blah)

FreeGadget hCanvas
hCanvas = 0

If hCanvas <> 0
DoSomething() ;The canvas is alive and well
Else
MaybeDoSomethingElse() ;Bugger, its gone!
End If

That should do the trick! :)

Dabz