The code I posted previously and put in app.open is nearly identical to the code the IDE would generate to construct a window you design with very minor differences. But stylistically it is identical. That is very much what the IDE generates. So if that code won’t work then the code the IDE generates won’t work either for the exact same reasons.
Secondly, the code in the constructor is in the CLASS - not the INSTANCE. Every instance would run the exact same constructor. So if we put code in the constructor it would be the same for every instance and so every instance would have the same values.
“Ah” you say “but what if you called a constructor with ‘the right parameters’ so the control is set up once with those unique values for that instance?”
Exactly how would the IDE know which constructor to call if there are several?
They could all be similar, or worse have optional params so we’d have to somehow determine which of several possibilities is “right”.
How then does the IDE know what code to write for calling this constructor?
And it has to know this perfectly for every possible set up?
“Introspection!” you say
Except that when the IDE is running introspection doesn’t work on “data”. That’s really what the IDE has - data about what you want it to eventually compile - not runtime instances so that won’t work. We could only introspect the IDE itself - not the controls & classes you’ve created. They’re not running.
“Ah” you say “since the IDE knows the signature of the constructors you could know by parsing the constructor signature”
Not really
If you can tell me which property value matches which parameter when a person writes a constructor like:
Class MakeAMess
Inherits Listbox
Constructor( foo as integer, bar as integer, baz as integer)
End Constructor
property i as integer
property j as integer
property k as integer
and you expose i,j,k in the inspector
whats the right call to the constructor?
new MakeAMess(i,j,k) ?
new MakeAMess(j,i,k) ?
new MakeAMess(i,k,j) ?
There isn’t a way to do what you’re suggesting. Not accurately every time for any control a user or plugin author might write.