Condividi tramite


CHeaderCtrl::GetItem

Retrieves information about a header control item.

BOOL GetItem(
   int nPos,
   HDITEM* pHeaderItem 
) const;

Parameters

  • nPos
    Specifies the zero-based index of the item to retrieve.

  • pHeaderItem
    Pointer to an HDITEM structure that receives the new item. This structure is used with the InsertItem and SetItem member functions. Any flags set in the mask element ensure that values in the corresponding elements are properly filled in upon return. If the mask element is set to zero, values in the other structure elements are meaningless.

Return Value

Nonzero if successful; otherwise 0.

Example

LPCTSTR lpszmyString = _T("column 2");
LPCTSTR lpszmyString2 = _T("vertical 2");

// Find the item whose text matches lpszmyString, and 
// replace it with lpszmyString2.
int    i, nCount = m_myHeaderCtrl.GetItemCount();
HDITEM hdi;
enum   { sizeOfBuffer = 256 };
TCHAR  lpBuffer[sizeOfBuffer];
bool   fFound = false;

hdi.mask = HDI_TEXT;
hdi.pszText = lpBuffer;
hdi.cchTextMax = sizeOfBuffer;

for (i=0; !fFound && (i < nCount); i++)
{
   m_myHeaderCtrl.GetItem(i, &hdi);

   if (_tcsncmp(hdi.pszText, lpszmyString, sizeOfBuffer) == 0)
   {
      _tcscpy_s(hdi.pszText, sizeOfBuffer, lpszmyString2);
      m_myHeaderCtrl.SetItem(i, &hdi);
      fFound = true;
   }
}

Requirements

Header: afxcmn.h

See Also

Reference

CHeaderCtrl Class

Hierarchy Chart

CHeaderCtrl::SetItem

Other Resources

CHeaderCtrl Members