You state that this code:
for TempComponent in Application.MainForm do
if (TempComponent is TTextControl) then
ShowMessage('Text Assigned : ' + TempComponent.Name)
else
ShowMessage('No TTextControl Descendant : ' + TempComponent.Name);
results in an access violation. The only reasonable explanation for that is that either:
Application
isnil
, orApplication.MainForm
isnil
.
The former seems a little unlikely since you'd have to be running the code before the FMX.Forms
unit intialized (or after it finalized). So the likely explanation is that you are running the code before the main form has been created, or you are running the code in a program that does not have a main form.
When you encounter access violation errors, you can debug them yourself to understand. What you need to do is to set a breakpoint on the line that causes the exception. When it triggers, inspect the variables used by that line of code. Usually you will find that one of the variables is nil
.