Accessing property of casted object returning unexpected results on Android


I have a snippet of code that casts a TFmxObject to a TForm and accesses it’s Height and Width properties that works fine. AControl is a standard TControl, and the Parent property is a TfmxObject. edited: I am first checking with the IS keyword that the parent is in fact a TForm.

LPar.Height:=(AControl.Parent As TForm).Height;
LPar.Width:=(AControl.Parent As TForm).Width;

On Windows, this code returns the values of Height and Width that I would expect and assigns it to LPar.Height and LPar.Width (Also a standard TControl), but as soon as I change the target platform to Android and debug using usb debugging on the device, the assignment is not an actual value but something like 6.2645644…+036 (Both Height and Width have the same invalid value).

I don’t know if the problem lies with casting the TFmxObject as a TForm or.. really where to start with troubleshooting further. I’ve tried assigning AControl.Parent to a local TFmxObject and then performing the cast on the local variable (same results) and I have also tried casting using this syntax as well


with no luck. Any help would be greatly appreciated.

Comments are closed.