ZOrder Method

See AlsoKW6L4T              Example18EX6T7>Low

Places a specified form or control at the front or back of the z-order within its graphical level.

Syntax

[object.]ZOrder [position]

Remarks

The ZOrder method has these parts:

Part               Description

 

object            Form, MDI form, or control to be positioned. For controls, object can be any control except a menu or timer.

position          Integer indicating the position of the control relative to other controls.  If position is 0 or omitted, the control is positioned at the front of the z-order.  If position is 1, the control appears at the back of the z-order.

 

The z-order of controls can be set at design time using Bring To Front and Send To Back choices on the Edit menu.

Within MDI forms, the ZOrder method sends MDI child forms to either the front or the back of the MDI client area, depending on the value of position.  For forms and MDI forms, ZOrder sends the form to either the front or the back of the screen, depending on the value of position.  As a result, forms may appear in front of or behind other running applications.

 

Note   There are three graphical layers associated with forms and containers.  The back layer is the drawing space, where the results of the graphics methods appear. Next is the middle layer where graphical controls and labels appear.  The front layer is where all non-graphical controls like command buttons, check boxes, and file controls appear.  Anything in one layer covers anything in the layer behind.  The ZOrder method arranges controls only within the layer where the control appears.

 


See Also

Arrange Method22JZIP


ZOrder Method Example

The example uses the ZOrder method to position command buttons on a form.  Choosing each button brings it to the front of the z-order.  To try this example, paste the code into the Declarations section of a form that contains a single command button named Command1 whose Index property is set to 0, indicating a control array.  Then press F5 to start.

 

Sub Form_Load ()

   Dim I                                 ' Declare variable.

   For I = 1 To 5

      Load Command1(I)                   ' Load new command button.

      Command1(I).Left = Command1(I - 1).Left + 250  ' Change position.

      Command1(I).Top = Command1(I - 1).Top + 250

      Command1(I).Caption = "Command" & I + 1  ' Change caption.

      Command1(I).Visible = True         ' Make visible.

   Next I

End Sub

 

Sub Command1_Click (Index As Integer)

   Command1(Index).ZOrder 0              ' Position button to front.

End Sub