Defining Event Handler Code Blocks
Defining a code block involves defining the Visual PRO/5 code to be executed upon occurrence of the event.
There are two ways to select the code block to be edited:
-
Selection via drop down lists.
-
Selection by clicking on the form to which the event is to be attached.
List Method
-
Click the drop down arrow of the Object list to display the forms in the resource file. (The Object list also displays Initialization, End of Job, and user-defined Subroutines and Functions, but we are not interested in them at this point.) Select the form that contains the resource (form, window, or control) for which you want to define the code block.
-
If the resource is a child window, or is contained within a child window, click the drop down arrow of the Window list and select the child window. (The Window list initially shows the form selected in the Object list.) If there are no child windows on the selected form, the form itself will already be selected in the Window list, and it will be grayed out so it cannot be edited.
-
Click the drop down arrow of the Control list to display the list of controls contained in the form or window selected in the Window list.
-
To define a code block for the form or window selected in the Window list, select it again in the Control list. If the selected form or window contains no controls, it will already be selected in the Control list, and it will be grayed out so it cannot be edited.
-
To define a code block for a control contained in the form or window selected in the Window list, select that control from the list.
-
-
Click the drop down arrow of the Event list and select an event. If there is only one event available for the item selected in the Control list, it will already be selected in the Event list, and it will be grayed out so it cannot be edited. If you are creating a new event handler:
-
The code will be initialized with a comment block to identify the event; for some events, control variables will also be set to help you out.
-
If the event will not be visible in the event loop of the generated program, the Event Warning dialog is displayed. This is to warn you that you will need to edit the window attributes in the resource file to make this event visible within the event loop.
-
-
If you are using an external editor, click the Edit Code tool button to edit the block of code using your external editor.
-
Enter or edit the Visual PRO/5 code to be executed upon occurrence of the event.
Visual Method
-
Do one of the following:
-
On the Program menu, select SelectForm, then select the desired form from the sub-menu.
-
On the toolbar, click the SelectForm button, then select the desired form in the SelectForm dialog and click OK.
-
-
If GUIBuilder is configured to provide extra help at this point, the Selecting a Form dialog is displayed to provide instructions for working with the form. (To prevent this dialog from being displayed each time you select a form, click the Don't show me this screen again checkbox.) Click OK to dismiss the Selecting a Form dialog.
-
The selected form appears. Do one of the following:
-
To define an event handler for the form as a whole, double-click on the form background.
-
To define an event handler for a specific control, double-click on that control.
-
To define an event handler for a menu item, select that menu item.
-
To define an event handler for the close box, click the close box.
-
To exit from the form without defining an event handler, press the Delete key.
-
-
If you clicked on a part of the form where more than one control overlaps, the Select Control dialog appears. Select a control from the list and click OK.
-
To select an event:
-
If you selected a control that only supports one type of event, or if you are defining an event handler for a menu item or the close box, the correct event is selected automatically.
-
If you clicked on the form background or on a control that supports more than one type of event, the SelectEvent dialog appears. Select an event from the list and click OK.
-
-
Even when a control supports a certain type of event, that event might not be visible in the event loop of the generated program. This means that the event is optional, and has not been enabled for this window in ResBuilder. If such an event is selected, the Event Warning dialog appears. This dialog indicates that, while you can go ahead and create the event handler code, it will not be visible to the event loop unless you go back into ResBuilder and edit the window properties, enabling the event. (The following events are always visible: Close box operated; Menu selection made; Push button operated; Tool button operated; and any of the Notify events, code "N").
-
If you are creating a new event handler, the code block is initialized with a comment to identify the event. For some events, control variables are also set to help you out. After the initial comment block inserted by GUIBuilder, enter your own Visual PRO/5 code to be executed whenever this event occurs in the generated program. There is no need to explicitly save each block of code; when you move on to the next code block, or when you close the file or exit from the program, the block of code is automatically saved to your .gbf file.