다음을 통해 공유


CListBox::SetAnchorIndex

Sets the anchor in a multiple-selection list box to begin an extended selection.

void SetAnchorIndex(
   int nIndex 
);

Parameters

  • nIndex
    Specifies the zero-based index of the list-box item that will be the anchor.

Remarks

In a multiple-selection list box, the anchor item is the first or last item in a block of contiguous selected items.

Example

void CMyODListBox::OnLButtonDown(UINT nFlags, CPoint point)
{
   BOOL bOutside = TRUE;
   UINT uItem = ItemFromPoint(point, bOutside);

   if (!bOutside)
   {
      // Set the anchor to be the middle item.
      SetAnchorIndex(uItem);
      ASSERT((UINT)GetAnchorIndex() == uItem);
   }

   CListBox::OnLButtonDown(nFlags, point);
}

Requirements

Header: afxwin.h

See Also

Concepts

CListBox Class

CListBox Members

Hierarchy Chart

CListBox::GetAnchorIndex