check, if button exists

BlitzPlus Forums/BlitzPlus Programming/check, if button exists

I ant to check, if a created button is still there or was FreeGadget.
If the button does not exists, the programm should create a new one.

I do it so:

Code:

If button_Besteposition1<>0 Then FreeGadget button_Besteposition1:button_Besteposition1=0

button_Besteposition1=CreateButton("RV",10,5,50,15,panelbesteposition,3)



Sometimes, if the If..Then-Code is checked, the programm ends with the message "Invalid Gadget Handle".

Why is that so?

How can I check, if the button does still exists ?

Kind Regards,

Dirk Knoop