1C:Enterprise 8.3. Practical Developer’s Guide. Lesson 5 (2:00). Theory. Event handler procedures in form modules

Event handler procedures in form modules

In addition to variable declarations and the main program, a form module can contain procedures that are handlers of the events related to the form. The events of opening and closing the form window are the most common events that can be handled in the form module (listing 5.18).

Listing 5.18. Form module

&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
    // Insert handler content
EndProcedure

&AtClient
Procedure OnOpen(Cancel)
    // Insert handler content
EndProcedure

It is important that the names of these procedures are not fixed, you can name them as you like. And it is not sufficient, for example, to define the OnCreateAtServer or OnOpen procedures in the module. You also have to link them to the respective form events in Designer (fig. 5.17).

Lesson 5 (2:00). Theory / Event handler procedures in form modules 

Fig. 5.17. Form events

Novice developers often forget about this aspect. To avoid such situations, we recommend that you use the opening buttons Lesson 5 (2:00). Theory / Event handler procedures in form modules in the property palette to generate the procedures (fig. 5.18).

Lesson 5 (2:00). Theory / Event handler procedures in form modules
Fig. 5.18. Form events

Alternatively, you can select them from the drop-down list that is available when you are in the form module (fig. 5.19).

Lesson 5 (2:00). Theory / Event handler procedures in form modules
Fig. 5.19. List of form events

In this case the procedure definitions are automatically generated and linked to the respective form properties.

Leave a Reply

Your email address will not be published. Required fields are marked *

1C:Enterprise Developer's Community