Skip to content

Class: cDbScrollingContainer

Properties | Events | Methods | Index of Classes

Container for cDbScrollingClientArea

Hierarchy

cObject > cUIObject > DfBaseObject > DfBaseWindow > DfBaseUIWindow > DfBaseContainer > DfBaseDialog > Container3d > dbContainer3d_ > dbContainer3d > cDbScrollingContainer

Show full hierarchy and direct subclasses

Library: Windows Application Class Library

Package: cDbScrollingContainer.pkg

Mixins: cScrollingContainerMixin

Description

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

This dropped object will consist of a cDbScrollingContainer and a single required cDbScrollingClientArea child object.

  • There must be one cDbScrollingClientArea object and no other type of object inside of a cDbScrollingContainer.
  • You should not place any other code inside of the cDbScrollingContainer object.

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

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

Object oView is a dbView

    Object Customer_DD is a cCustomerDataDictionary
    End_Object

    Object oCustomer_Number is a dbForm
        Entry_Item Customer.Customer_Number
        Set Size to 13 51
        Set Location to 5 51
    End_Object

    Object oCustomer_Number is a dbForm
        Entry_Item Customer.Name
        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 cDbScrollingContainer / cDbScrollingClientArea object as follows.

Object oView is a dbView

    // DataDictionary Objects (DDOs) should be placed inside the view
    // NOT inside the cScrollingContainer or cScrollingClientArea
    Object Customer_DD is a cCustomerDataDictionary
    End_Object

    Object oScrollingContainer1 is a cDbScrollingContainer
        Object oScrollingClientArea1 is a cDbScrollingClientArea

            Object oCustomer_Number is a dbForm
                Entry_Item Customer.Customer_Number
                Set Size to 13 51
                Set Location to 5 51
            End_Object

            Object oCustomer_Number is a dbForm
                Entry_Item Customer.Name
                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 cDbScrollingContainer and cDbScrollingClientArea classes can be thought of as a unit. The cDbScrollingContainer 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 cDbScrollingClientArea. 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 enable 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 cDbScrollingClientArea object.

The Visual Designer

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

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 cDbScrollingContainer
        Object oScrollingClientArea1 is a cDbScrollingClientArea
        End_Object
    End_Object
End_Object

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

Notes

A cDbScrollingContainer object must contain one and only one object, a cDbScrollingClientArea object. You discouraged from adding any other code inside of this object (doing so can cause issues with scrolling and anchor logic). An object of class cDbScrollingClientArea can only be used inside of cDbScrollingContainer object. A non-data-aware version of this class pair is cScrollingContainer / cScrollingClientArea. Size, Location and peAnchors should not be set for either of these classes, as they will be inherited from their parent containers. The cDbScrollingContainer and cDbScrollingClientArea objects always use the full size of their container's client area.