Link to home
Start Free TrialLog in
Avatar of yakky
yakky

asked on

CListCtrl - How do I prevent a user resizing the columns & stop the blue hilighter appearing when an item is clicked on?

CListCtrl -
1. How do I prevent a user resizing the columns?

2. Stop the blue hilighter appearing when an item is clicked on?

I can do this if I invalidate the window, but the windows background becomes greyed. I want a white background.  Any ideas?

Thanks in Advance
Yakky
Avatar of Vinayak Kumbar
Vinayak Kumbar

Hi,

Not to allow user to resize.

Have Ur own List Control class say CDontResize and associate it with ur list control. Then map the following function

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

Here I am not allowing the columns 2 - 8 to resize!!!.

Try it out.

VinExpert
ASKER CERTIFIED SOLUTION
Avatar of Vinayak Kumbar
Vinayak Kumbar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

To prevent selection u can map the WM_LBUTTONDOWN message to that class and dont call the base class member. That also will work.

Try it out.

VinExpert
Avatar of yakky

ASKER

Thanks a lot
Yakky