Delphi: React to minimizing a form, OnMinimize
Question by Chematik | 2012-09-10 at 19:22
I would like to perform an action in Delphi when the user minimizes the form. In the Object Inspector, although, I can find all kinds of events, such as OnClose and so on, but I can not find OnMinimize there, and that is, would I need.
How can I set this event? Is that possible, anyway?
Related Topics
Lazarus: React to minimization of the application window
Question | 1 Answer
Delphi: Event Order of a Form - From OnCreate to OnDestroy
Info | 1 Comment
Send HTML5 Canvas as Image to Server
Tutorial | 0 Comments
Delphi/Lazarus: Command Line Parameter Tutorial Part 2: Receiving
Tutorial | 0 Comments
jQuery: Assign Action to Keyboard Keys (Keyboard Event)
Tip | 0 Comments
Delphi: System-Wide HotKey
Tutorial | 1 Comment
How to resize Image before Upload in Browser
Tutorial | 13 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Just search for the component named TApplicationEvents. This component provides all kinds of events, your application provides, including your sought OnMinimize.
Simply drag the component on your form and write under OnMinimize the code, that should be executed.
2012-09-11 at 21:42
The solution suggested by Computer Expert certainly works quite well, but there are cases in which the solution is not practical, because TApplicationEvents always applies to the entire application. But if you want to capture only the events of a particular form (window), you should better use the following code:
With this procedure, you are able to catch all Windows messages that are sent to the window. When minimizing, the type of the Windows Message is "SC_MINIMIZE" and you can react to it and write down your corresponding code.
If you omit the "exit", after your code also the default action of the minimizing is triggered. With "exit", it will not be triggered.
2012-09-20 at 11:52