Sdílet prostřednictvím


CTreeCtrl::SetAutoscrollInfo

Sets the autoscroll rate of the current tree-view control.

BOOL SetAutoscrollInfo(
     UINT uPixelsPerSec, 
     UINT uUpdateTime
);

Parameters

Parameter

Description

[in] uPixelsPerSec

The number of pixels per second to scroll.

[in] uUpdateTime

The time interval between updates of the control.

Return Value

Always returns true.

Remarks

The autoscroll parameters are used to scroll into view an item that is currently not visible. The tree-view control must have the TVS_EX_AUTOHSCROLL extended style, which is described in Tree-View Control Extended Styles.

This method sends the TVM_SETAUTOSCROLLINFO message, which is described in the Windows SDK.

Requirements

Header: afxcmn.h

This method is supported in Windows XP and later.

Additional requirements for this method are described in Build Requirements for Windows Vista Common Controls.

Example

The following code example defines a variable, m_treeCtrl, that is used to access the current tree-view control. The code example also defines an unsigned integer and several HTREEITEM variables. These variables are used in the next example.

public:
    // Variable to access tree control.
    CTreeCtrl m_treeCtrl;
    // Variable to access splitbutton control.
    CSplitButton m_splitbutton;
    // Accessibility identifier
    UINT accIdUS;
    // HTREEITEMs
    HTREEITEM hCountry;
    HTREEITEM hPA;
    HTREEITEM hWA;

The following code example sets the autoscroll behavior of the current tree-view control. In an earlier section of the code example, which is not shown, we created a tree-view that consists of a root country node for the United States, subnodes for the states of Pennsylvania and Washington, and tree items for cities in those states. We intentionally made the tree-view control narrow so that it must automatically scroll to display the tree item that has the focus. The code example sets the tree-view control to automatically scroll 30 pixels per second every 5 seconds until the tree item is in view.

    // Scroll 30 pixels/sec and redraw every 5 seconds.
    m_treeCtrl.SetAutoscrollInfo( 30, 5 ); 

See Also

Reference

CTreeCtrl Class

Hierarchy Chart

TVM_SETAUTOSCROLLINFO

Tree-View Control Extended Styles

Other Resources

CTreeCtrl Members