CListCtrl Fixed headers and Column Widths

I have a dialog based application which contains two list controls setup in report view that are used to monitor status events.  I would like to fix the column widths and their headers so that they can not be changed or clicked.  

I have set the controls up through the ClassWizard with an associated variable of CListCtrl type.  I access the entries of the controls through the LV_ITEM structure and the columns through the LV_COLUMN structure.

I'm using version 5 of MSVC/C++ on NT 4/SP3.
beardencAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:
Hi,

Derive Ur own class from CListCtrl and map OnNotify() function and write the code as follows. Here Column 2 to 8 have been fixed. User can't resize them.


BOOL CDontResize::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{

HD_NOTIFY *pHDN = (HD_NOTIFY*)lParam;
{
if((pHDN->hdr.code == HDN_BEGINTRACKW || pHDN->hdr.code == HDN_BEGINTRACKA)
&& (pHDN->iItem == 2) || (pHDN->iItem == 3) || (pHDN->iItem == 4) || (pHDN->iItem == 5) || (pHDN->iItem == 6) || (pHDN->iItem == 7) || (pHDN->iItem == 8))
{
      *pResult = TRUE;
      return TRUE;
}
}      
return CListCtrl::OnNotify(wParam, lParam, pResult);
}

Hope it helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vinayak KumbarSr Program ManagerCommented:
Hi,

I forgot to say!!!

U have the variable for list control. declare it as of Ur class's object instead of CListCtrl. That means subclass that control to Ur class(say CDontResize).

Try it out.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.