I am writing a program and I cannot figure out how to do this: it is necessary, when a window appears, to perform some kind of action. I have already done all the actions with the window, but I cannot catch it. I just don’t know how to add a condition: "if a window appears, then ...".
In Delphi, this can be done in at least two ways :
Describe the handler function signature ** of the system message in the main class (in the public section):
public procedure Catch(var msg:TMessage);message SW_SHOW; ...
And, accordingly, the implementation is already what you are implementing it. Suppose my example is this:
procedure TForm1.Catch(var msg: TMessage); begin showmessage('Caught!'); end;
This method can handle any system message for any form of application.
The second method already consists in processing the message by means of Delphi for each individual form. But, however, not every system message can be processed this way, so decide for yourself. Example of a handler procedure:
procedure TForm1.FormShow(Sender: TObject); begin showmessage('Caught!'); end;