I can't seem to get the text for a header in CListView. I can get the index of the item and I can set the text and center it but when I call GetItem( )with HeaderItem.mask = HDI_TEXT it fails. If someone can help me out that would be great because I'm going to go insane.
Here's what I have to first set the header then try and read the header:
HDITEM HeaderItem;
CListCtrl& ListCtrl = GetListCtrl();
CHeaderCtrl* pHdrCtrl = ListCtrl.GetHeaderCtrl();
// get header strings
HeaderItem.mask = HDI_TEXT | HDI_FORMAT ;
HeaderItem.fmt = HDF_CENTER | HDF_STRING;
HeaderItem.pszText = "NEW";
HeaderItem.iOrder = 0;
// this works fine
pHdrCtrl->SetItem(0, &HeaderItem);
// this always fails
if(pHdrCtrl->GetItem(0, &HeaderItem) == 0){
AfxMessageBox("Could Not Get Item"
return;
}