My Delphi 11 FMX project has multiple document windows.
How can I detect in code whether or not the window is in the background? (Windows and Macintosh)
CodePudding user response:
The Active: Boolean
property indicates whether the form has focus.
Note, however:
In procedure
TCommonCustomForm.Activate;
theActive
property is setTrue
beforeOnActivate
is called.In procedure
TCommonCustomForm.Deactivate;
theActive
property is setFalse
afterOnDeactivate
is called.
Therefore, referring to the Active
property in these events (OnActivate
and OnDeactivate
) might be error prone. OTOH, the events already tell what the state will be after exit.
Outside of these events the Active
property correctly indicate the actual state.