You are here: Using External Control Systems with HAL > Integrating Stardraw Control Systems > Exploring the Stardraw Example Application > Initializing the Form on Application Start

Initializing the Form on Application Start

When the Stardraw example application starts, it is important to initialize all of the form controls to the current values of the external controls running in the HAL system. This will bring the Stardraw form to the same state as Halogen/HAL. To do this, the Stardraw application responds to a Load event from the Form1 control. Form1 is the name of the top level form of the example application and the Load event occurs right after the application begins running and connects to the Halogen/HAL Control Server.

The Stardraw application associates an action with the Load event, which calls the HAL1 driver’s RequestAllControlValues method. In the HAL1 driver, this method sends a ‘get’ message to the Halogen/HAL Control Server for each of the external controls in the example HAL1 configuration.

The Halogen/HAL Control Server responds with ‘set’ messages for each of the controls, which make their way through the Stardraw HAL1 driver, raising corresponding ‘On…Changed’ events, one for each control. After the Stardraw application performs the actions associated with these events, the form controls and the Halogen/HAL controls match.

To see how the application configures this event, bring up the Actions dialog for the Stardraw Form1 by double clicking on the window title bar of the form. This is the light blue area across the top of the form that includes the Stardraw application icon in the top left of the form. The Actions dialog for Form1 shows the Form1.Load event in the upper left and the associated action: