How to prevent resizing of column in CListCtrl - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to prevent resizing of column in CListCtrl

luckyshahluckyshah Posts: 1Member
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(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.
Sign In or Register to comment.