How to add events and event processors for Delphi programs

xiaoxiao2021-03-06  19

Delphi is a very functional visualization program development tool. In the process of using Delphi to develop Windows applications, although Delphi provides a lot of properties and events for each visual component, you may encounter some special events you need in practical applications, these Special event Delphi is not available, then we need to add these special events to the app. When these events occur, the process of processing these events immediately immediately immediately. This article uses an example to explain how to add events and process processes for applications. In Delphi, the event is actually a specialized attribute, which is a process (Procedure) pointer. To add an event, you should first describe a pointer to point to the event procedure in the defined class, which is the process of processing the event by this pointer once the event is performed. Finally, the event attribute that is defined by the specified Published published and the event processing pointer associated with it. In this example, ftoobig is the event processing process pointer defined, and ONTOOBIG is the event attribute name. Event Process Pointer FTOOBIG The process TOOBIG1 is directed through the initialization of the program. Place three edit boxes on Delphi's form (Form1), which are Edit1, Edit2, and Edit3, and put a button button1. A private integer variable VAL1, VAL2, and RES are served in the program, and the variable RES is used to record the product of VAL1 and VAL2 and display it with EDIT3. When the data entered via EDIT1 and EDIT2 has a greater than 100, an event is triggered, and the event processing process TOOBIG1 is called to display a dialog, indicating that this event has occurred and has been processed. The source program code is as follows, which is debugged in Delphi 3.

转载请注明原文地址:https://www.9cbs.com/read-42695.html

New Post(0)