Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   How to prevent resizing of column in CListCtrl (http://www.go4expert.com/forums/prevent-resizing-column-clistctrl-t27751/)

luskyshah 8Feb2012 14:39

How to prevent resizing of column in CListCtrl
 
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.


All times are GMT +5.5. The time now is 00:23.