Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using CHeaderCtrl::GetItem( )

Status
Not open for further replies.

BrotherC

Programmer
Sep 29, 2002
25
CA

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;
}

 

Thanks, it worked. I don't need to set the cchTextMax to set an item in a list control but I need to set it to get an item. Doesn't make sense to me but ok.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top