Originally posted by: holy
As you see uplevel... where can i find ::OnNotify() function....
is ::OnNotify() List Control message ??
Originally posted by: shinoj
Sir,
The code which u have given to prevent resizing is fine.
But sir i need ur help.
I want to resize the header columns and when i close the window and reopen the same window , the resized column width should be saved.[Like the windows explorer works]
Is there any code for that.If there please send it to me.
Thanking you ,
yours faithfully,
shinoj.
To do this would require storing data. The
column sizes can be stored in the same place as
other settings. All that needs to be done is to
loop through the columns and retrieve their sizes
when the list control is destroyed:
void CMyList::OnDestroy () {
int ncols = GetHeaderCtrl()->GetItemCount();
CString t = _T("");
for (int i=0; i<ncols; i++) {
t.Format(_T("Column %d = %d"), i,
GetColumnWidth(i));
SaveSetting(t);
}
CListCtrl::OnDestroy();
}
Reply
Originally posted by: Robert Stalkin
I am a beginner with MFC. What do A and W stand for at the end of case labels. I tried to use one without W and A and it compiles but does not do anything.
It does work for MBCS with W and A but for UNICODE it does not work at all.
Hope somebody knows how to solve this problem.
Thanks
Originally posted by: Tom Hill
Solution:
This works great. One problem that is easily fixed
is the case where the user double clicks on the header
dividers. The original code does not eat those messages,
therefore the columns get "auto resized".
BOOL CMyListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
switch (((NMHDR*)lParam)->code)
{
case HDN_BEGINTRACKW:
case HDN_BEGINTRACKA:
case (HDN_DIVIDERDBLCLICKA):
case (HDN_DIVIDERDBLCLICKW):
{
*pResult = TRUE; // disable tracking
return TRUE; // Processed message
}
}
return CListCtrl::OnNotify(wParam, lParam, pResult);
}
this same logic can be applied to the second part of this
article on how to prevent certain columns from resizing.