Layering Controls

How to:

By default, all the controls on a form are placed on the same layer (the Default layer). If you are designing complicated forms with many controls, you can take advantage of the layering ability of the Form Editor.

At design time, you can create multiple layers and then assign different controls on the form to different layers. You can then hide a layer, which hides all the controls on that layer until you make it visible again. You can also lock a layer, which ensures that all controls on the layer cannot be changed. For run time, layers can be dynamically displayed or hidden using the SetLayer command.

Layers Sheet dialog box


Top of page

x
Procedure: How to Create a Layer
  1. In the Form menu, click Edit layers, or click the Edit layers button Edit Layers button on the Layout toolbar to open the Layers Sheet dialog box.
  2. Click Add.
  3. If you wish, rename your layer by typing over the name in the Name box.
  4. Click OK.

The new layer is added on top of the existing layers.


Top of page

x
Procedure: How to Make a Layer Active

To make a layer active so that all new controls will be placed on this layer:

  1. In the Form menu, click Edit layers, or click the Edit layers button Edit Layers button on the Layout toolbar to open the Layers Sheet dialog box.
  2. Select the layer you want to make active.
  3. Click Select.
  4. Click OK.

Top of page

x
Procedure: How to Hide or Unhide a Layer
  1. In the Form menu, click Edit layers, or click the Edit layers button Edit Layers button on the Layout toolbar to open the Layers Sheet dialog box.
  2. Select the layer you want to hide or unhide.
  3. Select or clear the Hide box.
  4. Click OK.

Top of page

x
Procedure: How to Lock or Unlock a Layer
  1. In the Form menu, click Edit layers, or click the Edit layers button Edit Layers button on the Layout toolbar to open the Layers Sheet dialog box.
  2. Select the layer you want to lock or unlock.
  3. Select or clear the Lock box.
  4. Click OK.

Top of page

x
Procedure: How to Change the Order of the Layers
  1. In the Form menu, click Edit layers, or click the Edit layers button Edit Layers button on the Layout toolbar to open the Layers Sheet dialog box.
  2. Select the layer you want to move.
  3. Click the Up or Down button.
  4. Click OK.

Top of page

x
Procedure: How to Move an Existing Control to Another Layer
  1. Select the control.
  2. In the property sheet, select the Layers property.
  3. Select the name of the layer you want the control to be on.

Top of page

x
Procedure: How to Rename a Layer
  1. In the Form menu, click Edit layers, or click the Edit layers button Edit Layers button on the Layout toolbar to open the Layers Sheet dialog box.
  2. Select the layer you want to rename.
  3. Type a new name in the Name box.
  4. Click OK.

Top of page

x
Procedure: How to Delete a Layer
  1. In the Form menu, click Edit layers, or click the Edit layers button Edit Layers button on the Layout toolbar to open the Layers Sheet dialog box.
  2. Select the layer you want to delete.
  3. Click Delete.
  4. Click OK.

Top of page

x
Syntax: How to Control Layers at Run Time Using the SetLayer Command

The SetLayer command allows layers to be set as visible or invisible at run time. The command can be used in a Maintain or JavaScript event. The syntax is

Maintain

Formname.SetLayer.("layername",n);

JavaScript

setLayer.formname.("layername",n);

where:

"layername"

Is the name of the layer, enclosed in double quotation marks (“).

n

Possible values are:

  • 0 sets the layer to invisible (off).
  • 1 sets the layer to be visible (on).

To preset a layer before the form is run, you can use the SetLayer command with the Winform Show_inactive command:

Winform Show_inactive Form1;
Form1.SetLayer("Layer1”,1);
Form1.SetLayer("Layer2”,0);
Winform Show Form1;

This sets Layer1 as visible and Layer2 as invisible.


WebFOCUS