Two instances of the same class, second one does not work

I have designed a class containing a couple canvas. The class has properties that trigger actions on the canvas through an internal timer.

When I drag the class over the window, and change the properties on the control instance of the class, it works fine.

If I add a second control instance on the window, that one does not work.

I must be missing something.

I could duplicate the class, but somehow I feel a class should support multiple instances. Am I wrong ?

You are obviously missing something. What, I do not know. Please provide more details.

I am using a variable inside the class timer to track the value of a property. So when that property is changed in the instance, I can do stuff accordingly.

I have created a small test project where a class property “status” sets the value of a checkbox.

When I drag one instance and change the value in a pushbutton Action, it changes the status of the checkbox fine.

When I add a second instance of the class to the window and do the same thing, it does not work. I suspect it has to do with the way I store the old value of status. Is there a way to discriminate according to the instance ?

Here is the test project

You’re using a static variable in the timer, use a property for it. Static variables like are shared propertys.

That was it. I have changed the static to a class property and now multiple instances work fine. Thank you Peter :slight_smile:

Noted : no static in classes.