Link to home
Start Free TrialLog in
Avatar of Michael Knight
Michael Knight

asked on

How to hide a column of text in a CListCtrl?

I have a CListCtrl in my dialog that displays user information. One of the columns displays the user password. Is there a way to either a) hide a column so someone cannot resize it and view it, or b) show this column's text as asterisks (password text).
ASKER CERTIFIED SOLUTION
Avatar of naveenkohli
naveenkohli

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
Avatar of naveenkohli
naveenkohli

The place to store your passowrd information would be lParam member of LVITEM structure of your item.
Hi,

If U want that information in ListCtrl only,  then subclass that control to ur class derived from CListCtrl and map the OnNotify() function and wrtie the following code

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

Note that I have done it foe col 2 to 8(no resizing)

Try it out.