Windows forms and static

Posted by jmls on 07-Sep-2008 11:49

Is there any magic command in the Application:run to only run one instance of any particular form ?

If not, could I declare a static property that holds the form object and set that property the first time the form is initialized ?

 * jmls buggers off to find out for himself.

All Replies

Posted by Admin on 07-Sep-2008 13:01

Is there any magic command in the Application:run to

only run one instance of any particular form ?

No.

If not, could I declare a static property that holds

the form object and set that property the first time

the form is initialized ?

That's how I do that. The constructor set's the property to itself (THIS-OBJECT) and the static property throws an exception (sorry an error class that inherits from AppError) when the property already has a value. The routine level error handling than prevents the creation of the second form instance.

Posted by Admin on 07-Sep-2008 13:04

This logic in that property and in that constuctor can be defined in a sub-class (SingletonForm). And a Form inherriting SingletonForm can still be designed in the Visual Designer.

This thread is closed