Contents
Non-Visual Component Sample Help

Sample Description: Non-Visual Component

Points of Interest

Adding Forms to a Group

Managing the Display of Forms in a Group

Control

Form

Group

For Help on Help, Press F1


Non-Visual Component

The purpose of the Non-Visual sample is to highlight the fact that non-visual components may be developed to help support the visual aspects of an application.

Envelop is made of many non-visual objects, such as timers, groups, etc. These objects can be used to create key functionality in an application and can be developed in a reusable way.

This particular sample focuses on the Group object and how it may be used to coordinate the display of several different forms. As the sample is loaded, the group named FormGroup is cleared and then populated with seven form objects. The group object can be used to manage a group of objects in a similar manner that a ListBox can be used to manage a list of text information.

The purpose of the sample is to display one of the seven forms that are contained inside the FormGroup object. Clicking the Next and Prev buttons will cycle through the display of the various forms.


Adding Forms to a Group

The Append method is used to populate the group object. As form objects are appended to the FormGroup object, they are added in a particular order. The Load method of Form11 is used to initialize the application by first clearing the FormGroup group object, then appending seven different forms to the group.


Managing the Display of Forms in a Group

Two methods, ShowNext and ShowPrev, are defined as methods on the FormGroup group object. These methods are called from the Next and Prev buttons on each of the seven forms stored in the group. The ShowNext method displayed below is used to determine which form object is currently displayed in the For loop, then determine the name of the next form in the group. The variable "next_form" is set to be the next object within the group.

Sub ShowNext(current_form as Form)

  Dim i,j as Integer

  Dim next_form as Form

  For i = 0 To Count - 1

    If ObjectAt(i) = current_form Then

      If i = Count - 1 Then

        j = 0

      Else

        j = i + 1

      End If

      next_form = ObjectAt(j)

      Exit For

    End If

  Next i

  If next_form Then

    Dim form_top, form_left As Integer

    form_top = current_form.Top

    form_left = current_form.Left

    next_form.Caption = "Group Number: " & j

    If (next_form.Left <> form_left) || (next_form.Top <> form_top) Then

      next_form.Move form_left, form_top, next_form.Width, next_form.Height

    End If

    next_form.DisplayForm(j + 1, Count)

    current_form.Hide

  End If

If there is a next_form object, it is moved and sized to a position that matches the currently displayed form. Once the currently displayed form is covered by the next form, it is hidden. This is why it appears as though only the contents of the same form are changing when you click the Next or Prev button several times in a row.