Class: cScrollingContainer

Properties  Events  Methods    Index of Classes

Container for cScrollingClientArea

Hierarchy

cObject
---cUIObject
------DfBaseObject
---------DfBaseWindow
------------DfBaseUIWindow
---------------DfBaseContainer
------------------DfBaseDialog
---------------------Container3d
------------------------cScrollingContainer

Library: Windows Application Class Library

Package: cScrollingContainer.pkg

Mixins: cScrollingContainerMixin

Description

cScrollingContainer objects are used to implement scrolling in containers. A cScrollingContainer object can be dropped into any container (typically a view) to add scrolling client area support.

This dropped object will consist of a cScrollingContainer and a single required cScrollingClientArea child object.

- There must be one cScrollingClientArea object and no other type of object inside of a cScrollingContainer.
- You should not place any other code inside of the cScrollingContainer object.

Additional objects are then placed inside of the cScrollingClientArea object. These are the objects that can be scrolled.

For example, a non-scrolling view might have the following structure:

Object oView is a View

    Object oForm1 is a Form
        Set Size to 13 51
        Set Location to 5 51
    End_Object

    Object oForm2 is a Form
        Set Size to 13 51
        Set Location to 25 51
    End_Object

End_Object


This can be changed into a scrolling view by inserting a cScrollingContainer / cScrollingClientArea object as follows.

Object oView is a View
    
    Set Main_DD to Customer_DD
    Set Server to Customer_DD

    Object oScrollingContainer1 is a cScrollingContainer
        Object oScrollingClientArea1 is a cScrollingClientArea

            Object oForm1 is a Form
                Set Size to 13 51
                Set Location to 5 51
            End_Object

            Object oForm2 is a Form
                Set Size to 13 51
                Set Location to 25 51
            End_Object

        End_Object
    End_Object

End_Object


Auto Scrolling

Scrollbars will only appear as needed. If a container is sized such that it cannot show all child objects, scrollbars will appear. The class will determine the size required for the client area by checking the size and location of its child objects during activation. If the objects do not fit, a scrollbar appears. As you resize the container, the object will determine if scrollbars are needed or not and adjust things as needed. This is called "Auto Scrolling" (pbAutoScroll).

Auto Focus Scrolling

As you change the focus within your scrolling view, the object will determine if the new focus object is visible. If it is not, it will scroll to make the object visible. This is called "Auto Focus Scrolling" (pbAutoScrollFocus). Auto focus scrolling is limited. It does not scroll within a focus object (e.g., it will not scroll within a rich edit control). This is also true of grids - the auto focus scroll does not consider the current cell location.

Auto Scrolling and Anchors

Normally, auto scrolling is used as an alternative to anchors (see peAnchors) and usually anchors will remove the need to auto scroll and vice versa. These techniques can be used together. For example, a form may anchor resize until it reaches a piMinSize, at which point it will no longer get smaller and auto scrolling may kick in. Mixing anchors and auto scrolling can get complicated and the developer must design his views carefully to make this work.

Scrolling containers may be added to any container, although it makes the most sense to add these to views. You may also wish to add scrolling containers to one or both sides of a splitter container (see cSplitterContainer and cSplitterContainerChild).

Customizing Scrolling

This cScrollingContainer and cScrollingClientArea classes can be thought of as a unit. The cScrollingContainer has no design time properties and you discouraged from adding any other code inside of this object (doing so can cause issues with scrolling and anchor logic).

All design time properties for these objects are maintained in the cScrollingClientArea. These objects are designed to scroll automatically with "Auto Scrolling" enabled, "Auto Focus Scrolling Enabled" and scrollbars that appear only as needed. This can be customized:

- If pbShowDisabledScrollBar is set to True, the scrollbars will always be visible. When they are not needed, they are disabled, but not hidden.

- piAutoScrollMarginX and piAutoScrollMarginY determine how much of a margin should be allowed in determining when scrolling is needed.

- When auto scroll (pbAutoScroll) is enabled, the container determines what the minimum size of a container must be before scrolling is required. It determines this be checking the size and location of the bottom-most and right-most object. This happens when the container is activated. If, for some reason, this minimum size is incorrect, you can set either the piAutoScrollMinX or piAutoScrollMinY values yourself. These values are zero by default, which instructs the object the determine the size automatically. You might need to do this if objects will be displayed or resized dynamically after the container is activated.

- If you create custom visual objects after the scrollbar container has been activated, you may need to send CalculateAutoScrollMinimums to force the container to adjust its scrollbars for the new objects.

- When pbAutoScroll is False, you must always set piAutoScrollMinX and piAutoScrollMinY yourself. If they are zero, scrolling is always disabled for that orientation. You might use this if you want to enabled scrolling in one direction and anchors in another.

- Auto Focus Scrolling can be disabled by setting pbAutoScrollFocus to False.

Note that all of these properties are set in the cScrollingClientArea object.

The Visual Designer


When a cScrollingContainer is dropped from the Studio's Class Palette onto a component, such as a view, an object of class cScrollingContainer is created and inside it, an object of class cScrollingClientArea.

Use with Tabbed Workspace Interface

A proper scrolling tab workspace view should surround the view's (dbView) visible controls with a scrolling container and a scrolling client area object. The cCJCommandBarSystem object's pbTabbedWorkspaces should be set to True.

Object oSomeView is a dbView
    Set Size to 146 277
    Set piMaxSize to 175 350
    :
    // insert these object before any visual controls are created in the view
    Object oScrollingContainer1 is a cScrollingContainer
        Object oScrollingClientArea1 is a cScrollingClientArea
        End_Object
    End_Object
End_Object

See Tabbed Workspace Interfaces for more information about implementing this interface.


Notes