I'm working with dynamically creating multiple different types of controls and storing them in a list in the background. Two of such controls are a TEdit and a TLabel. These controls are all sub-controls of a TPanel control.
Well I accidentally mixed up the TEdit with the TLabel when reading from TPanel.Controls (got them from the wrong indexes) when writing to the TEdit.Text and TLabel.Caption properties. Somehow, it didn't even raise any exception.
It does something like TLabel(SomeEditControl).Caption:= 'This is a label control';
and TEdit(SomeLabelControl).Text:= 'This is an edit control';
And it puts the TEdit.Text data in the TLabel.Caption property, and the TLabel.Caption data in the TEdit.Text property. I'm puzzled that this didn't raise an exception... The only thing I can guess is that the TEdit.Text and TLabel.Caption properties just so happen to use the same memory address between the control classes.
Why wouldn't this give an access violation?
TControl
which has aWindowText
property. ( Just guessing...) – Broadnax