This is the code I used to test:
Code: Select all
USING System
USING System.Collections.Generic
USING System.ComponentModel
USING System.Data
USING System.Drawing
USING System.Linq
USING System.Text
USING System.Threading.Tasks
USING System.Windows.Forms
BEGIN NAMESPACE WindowsFormsApplication1
PUBLIC PARTIAL CLASS Form1 ;
INHERIT System.Windows.Forms.Form
PUBLIC CONSTRUCTOR() STRICT//Form1
InitializeComponent()
RETURN
END CONSTRUCTOR
PRIVATE METHOD button1_Click(sender AS System.Object, e AS System.EventArgs) AS VOID STRICT
LOCAL oObjectChild AS DisplayInheritChild
oObjectChild := DisplayInheritChild{}
oObjectChild:Finished() // Just to prevent warning XS0219.
RETURN
END METHOD
END CLASS
CLASS DisplayInheritParent
CONSTRUCTOR() CLASS DisplayInheritParent
MessageBox.Show("DisplayInheritParent - Constructor()", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
SELF:PostInit()
RETURN
VIRTUAL METHOD PostInit() AS VOID CLASS DisplayInheritParent
MessageBox.Show("DisplayInheritParent - PostInit()", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
RETURN
END CLASS
CLASS DisplayInheritChild INHERIT DisplayInheritParent
CONSTRUCTOR() CLASS DisplayInheritChild
MessageBox.Show("DisplayInheritChild - Constructor()", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
SELF:PostInit()
RETURN
METHOD PostInit() AS VOID CLASS DisplayInheritChild
MessageBox.Show("DisplayInheritChild - PostInit()", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
RETURN
METHOD Finished() AS VOID CLASS DisplayInheritChild
RETURN
END CLASS
END NAMESPACE
The order in which the message boxes appear is:
DisplayInheritParent - Constructor()
DisplayInheritChild - PostInit()
DisplayInheritChild - Constructor()
DisplayInheritChild - PostInit()
But if you say "it should not work this way" then probably I am doing something wrong and I am curious to know what it is.
I have also attached the complete solution.