I am attempting to iterate through the forms I have open in my application. I have found the documentation for FMX.Forms.TScreen.Forms, which looks like it can be used to accomplish my goal. However, I am confused on how I am supposed to use it.
At first I tried this in a function within my form's CPP file:
ShowMessage( Forms::TScreen::FormCount );
This produced the error 'Member TScreen::FormCount cannot be used without an object'
I figured that to mean that I need to attempt to access this property from my form, or from the global Application
variable. I tried both
this->Forms...
Application->Forms...
and
this->TScreen...
Application->TScreen...
However, neither Forms
nor TScreen
exist within either of these objects.
How do I go about accessing Forms.TScreen.Forms
?
The error gives you a clue:
Member TScreen::FormCount cannot be used without an object
TScreen
is a class, not an object. FormCount
is not a static member of the class, so you need an object instance of the TScreen
class. And such an object is provided for you - the global Screen
object:
ShowMessage( Screen->FormCount );
This is stated in the documentation:
There is a global variable,
Screen
, of typeTScreen
, which is instantiated for use by any application with a GUI. UseScreen
to obtain information about the current state of the screen in an application.
extern DELPHI_PACKAGE TScreen* Screen;