v2.0-a112 saw the removal of
GuiCreate() and the introduction of
Gui, exposed as a class of its own. This opens up the possibility to inherit from it, which in some (arguably most) cases can prove a tad cumbersome, requiring additional (undesirable) boilerplate and paying extra attention to the order and way in which fields are to be initialized. The following snippet demonstrates one such case:
Code: Select all
class SpecializedGui extends Gui
{
InstanceVar := []
}
SG := SpecializedGui.New() ; The Gui is destroyed.
The initializers run prior to the Gui having been created, thereby tripping the
HWND check in
GuiType::Invoke(IObject_Invoke_PARAMS_DECL), resulting in the aforementioned technically correct, albeit misleading, exception.
This can be worked around with by providing a constructor implementation, ensuring the Gui has been instantiated prior to any pending assignments:
Code: Select all
class SpecializedGui extends Gui
{
__New(Options := '', Title := '', EventObj := unset)
{
super.__New(Options, Title, IsSet(EventObj) ? EventObj : this)
this.InstanceVar := []
}
}
SG := SpecializedGui.New()