How to prevent resizing of column in CListCtrl

Discussion in 'MFC' started by luskyshah, Feb 8, 2012.

  1. luskyshah

    luskyshah New Member

    Joined:
    Feb 8, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Bangalore
    I am working on a CDHTMLDialog based application where I ahve added a CListCtrl as shown below.

    The list control has only one column.

    IDD_TEST_DIALOG DIALOGEX 0, 0, 419, 286
    STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
    EXSTYLE WS_EX_APPWINDOW
    FONT 8, "MS Shell Dlg", 0, 0, 0x1
    BEGIN
    CONTROL "",IDC_LIST_TEXT,"SysListView32",LVS_REPORT | LVS_OWNERDATA | LVS_NOSORTHEADER | NOT WS_VISIBLE | WS_BORDER | WS_TABSTOP,20,143,397,136
    END

    The problem is that I can drag the colum header to extreme left and the column goes hidden. To bring it back I will have to again drag the column header to the right.

    I want to prevent resizing of this column so that the user cannot drag this completely to the left and make it hidden.

    I did try the following code but it is not working.

    void CMyTestDlg::OnHDNEndtrackListLog(NMHDR *pNMHDR, LRESULT *pResult)
    {
    LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
    // TODO: Add your control notification handler code here
    if(m_ListCtrl.GetColumnWidth(0) < 100)
    {
    m_ListCtrl.SetColumnWidth(0, 500);
    }

    *pResult = 0;
    }
    Since I have very less time to implement this, I request you kindly give me some examples from MFC Dialog based applications.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice