Events for forms in Delphi
Form forms can respond to a variety of times, listing a whole bunch of things in the events page of object inspector, such as:
Here are some common events that you will list.
1, OnActivate
The OnActivate event occurs when the form is initially activated, and when the form is initially created or when the user switches from one form to another, the form may be activated, and the Application object has a OnActivate event. This event occurs when a user switches from one application to another.
2, OnClose and Onclosequery
When an application is closed, the OnClose event is emitted, and the OnClose event calls the Onclosequery event to see if the form is actually closed, and if the Onclosequery event returns false, the form does not close.
3, OnCreate
When the form is initialized, the OnCreate event occurs, and the OnCreate event occurs only once for any instance of a particular form, and the OnCreate handler is only used to perform any startup tasks that are required for the form.
4, OnDestroy
The OnDestroy event is a oncreate anti-event that clears all memory that is dynamically allocated by the form, or other cleanup transactions.
5, Ondragdrop
The Ondragdrop event occurs when an object is dragged onto a form, and if the form supports drag-and-drop, it responds to the event.
6, Onmousedown,onmousemove and onmouseup
is to respond to mouse clicks and mouse runs on the form.
7, OnPaint
The OnPaint event occurs whenever a form needs to be redrawn, and there are many reasons for this event to occur. In response to this event, it can be used as any drawing required by the application and can be displayed at any time. In most cases, the specialized components will draw themselves, but in some cases we need to do the drawing ourselves.
8, OnResize
Whenever you rescale a form, the OnResize event occurs, in response to which you can adjust the components on the form or repaint the form.
9, OnShow
The OnShow event occurs before the form becomes visible. Before the form is displayed, you can use this event to complete any of the things that the diagram Antis needs to handle.
Note
When a form is created, it produces a lot of events, and similarly, when a form disappears, it also generates a lot of events. But in what order did these events occur? When the form is established, the order in which the events occur is entered:
When a form disappears, the event occurs in the following order:
In most cases, it is not important to keep this order directly, but in some cases it becomes crucial. It is good to understand the order of invocation of event handlers, constructors, and destructors, at least when you really need to know this order to avoid unnecessary attempts.
Category: IDE
Events for forms in Delphi