Automatically Starting a Picture

This section describes how to create a run-time environment that contains a virtual toolbar and several pictures of the same size.

NOTE: This section only applies to pictures created with Enhanced Coordinates.  This section does not support the legacy Logical Coordinates System.

The figure below shows a sample picture design, consisting of three untitled pictures: a main picture, a navigational banner, and an alarm banner.

Typical Picture Design

Since the main picture has to be a certain size and position in the run-time environment, you may want to create a toolbar button to create pictures of the same size to fill the main process picture area. To do so, you must first create a picture area, navigation (or toolbar) area, and other run-time areas that are reserved as "special pictures." After creating these pictures, write down the following coordinates of the pictures so it will be easier to enter them into the script:

  • Window top
  • Window left
  • Document height
  • Document width

These coordinates can be found in the Properties window for the picture. See the Creating Pictures manual for more information on picture coordinates.

When opening iFIX pictures through scripts, you may want to remove any unwanted scroll bars by executing the FitWindowToDocument method, which is also illustrated in this code sample.

Let's take a look at the toolbar script. Wherever possible, comments are provided to help you understand that particular part of the script. These bold-faced comments will appear by default as green text when pasted into the VBA code window. Comment colors are configured in the VBA Option dialog.

Example: Creating a Toolbar

Dim iNewDoc As Object

Dim iPage As Object

 

'Create a new picture.

Set iNewDoc = Application.Documents.Add("FIX.PICTURE")

Set iPage = iNewDoc.Page

With iPage

 

     'Set the height of the document.

     .DocumentHeight = 51.3

 

     'Set the width of the document.

     .DocumentWidth = 100.44

 

     'Call the FitWindowToDocument method to expand the

     'window size so it matches the size of the document.

     'This action removes all scrollbars.

     .FitWindowToDocument

     .windowtoppercentage = 7.03

     .windowleftpercentage = 0#

     .titlebar = False

 

End With

Set iNewDoc = Nothing

Set iPage = Nothing