Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

Can any on help me to change the color for the CListControl Header??

Thanks
sudhir
Posted

With other controls this can be done using the WM_CTLCOLOR notification. But as far as I know, this can't be used with CHeaderCtrl and CListCtrl.

Then you must use an owner drawn header control (see CHeaderCtrl::DrawItem() [^]) and use sub-classing.
 
Share this answer
 
Dear Arndt,

i have implemented the same thing but Header index covered on label when we click on the header it was allowing me to see the old header.

how to fill the color for the CListcontrol Header...?

Thanks
sudhir
 
Share this answer
 
Comments
Jochen Arndt 14-Mar-12 7:33am    
Please don't use solutions to ask questions. Use the 'Have a question or Comment' option like I have done here. If doing so, the author of the solution gets an email notification. Otherwise, he may not see you post.

What do you mean by 'implemented the same thing'? Without knowing what you have done, I can't help you.

However, there is one possible bug (at least with MFC 7.1 / VS 2003):
When using CListCtrl::SetItem(), the owner draw flag of the header item is removed. So it must be set again after calling SetItem().
cnvsudheerraju 14-Mar-12 8:50am    
ok, Actually i have created list control in a splitter. for that i have taken a dialog box(frame less),later added a class inherited from CView to the same dialog box.passed the class as runtime class. up to this i am good. now i need to change the color for the Header of the List control.for this i have created a class inherited from CHeaderCtrl. later in OnInitialUpdate(){ ocHdr = new GRDSCDHeadCtrl; ocHdr = lc.GetHeaderCtrl(); ocHdr->Create ( WS_CHILD | WS_VISIBLE | HDS_HORZ, CRect (0,0,ocSize.Width(),18), this, 1 ); } which is creating a lable on the header..? not able to fill color..!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900