LVS_NOSORTHEADER style for a CListCtrl
anatoly.katzman@octel.com Sunday, February 23, 1997 Environment: NT 4.0, VC++ 4.1 My list control CListCtrl lstctrl; is created as sortable, so that clicking on a column header makes the header be pressed down like a pushbutton, and the list is resorted by that column contents. On some conditions I need to disable this feature (on already created and living list control). I thought I could do this by modifying the list control style: BOOL bSuccess = lstctrl.ModifyStyle ( 0L, // no styles to delete LVS_NOSORTHEADER, // style to add 0L); // flags or DWORD dwStyle = ::GetWindowLong( lstctrl.m_hWnd, GWL_STYLE); dwStyle |= LVS_NOSORTHEADER; ::SetWindowLong( lstctrl.m_hWnd, GWL_STYLE, dwStyle); For other styles (LVS_REPORT/LVS_LIST/LVS_ICON) the both methods worked fine, but with LVS_NOSORTHEADER neither of them succeeds. Anyone having an idea what I am missing here, please help. Thanks, Anatoly Katzman
petter.hesselberg -- petter.hesselberg@ac.com Tuesday, February 25, 1997 [Mini-digest: 2 responses] Fair warning: I haven't tried this, so I don't know if it will help you. But it's where I'd start if I had your problem: The header is not actually part of the list view, it is a control in its own right. One of the styles that apply to header controls is HDS_BUTTON. A listview created with styles LVS_NOSORTHEADER and LVS_REPORT gets a header that's missing the HDS_BUTTON style. The docs indicate that you should be able to change the style of a header control dynamically. (This is not possible for all controls; you can't change the alignment for a multi-line edit control, for example.) In other words - get a handle to the header control and remove the HDS_BUTTON style. Regards Petter Hesselberg (petter.hesselberg@ac.com) PS: The header control is a child of the listview. The one and only, under normal circumstances. _________________________________________________________________ To: mfc-l @ netcom.com @ internet cc: (bcc: Petter Hesselberg) From: anatoly.katzman @ octel.com @ internet Date: 24-02-97 00:54 Subject: LVS_NOSORTHEADER style for a CListCtrl _________________________________________________________________ Environment: NT 4.0, VC++ 4.1 My list control CListCtrl lstctrl; is created as sortable, so that clicking on a column header makes the header be pressed down like a pushbutton, and the list is resorted by that column contents. On some conditions I need to disable this feature (on already created and living list control). I thought I could do this by modifying the list control style: BOOL bSuccess = lstctrl.ModifyStyle ( 0L, // no styles to delete LVS_NOSORTHEADER, // style to add 0L); // flags or DWORD dwStyle = ::GetWindowLong( lstctrl.m_hWnd, GWL_STYLE); dwStyle |= LVS_NOSORTHEADER; ::SetWindowLong( lstctrl.m_hWnd, GWL_STYLE, dwStyle); For other styles (LVS_REPORT/LVS_LIST/LVS_ICON) the both methods worked fine, but with LVS_NOSORTHEADER neither of them succeeds. Anyone having an idea what I am missing here, please help. Thanks, Anatoly Katzman -----From: ktm@ormec.com On mfc-l, anatoly.katzman@octel.com wrote: > Environment: NT 4.0, VC++ 4.1 > > My list control, CListCtrl lstctrl, is created as sortable, so > that clicking on a column header makes the header be pressed > down like a pushbutton, and the list is resorted by that > column contents. > > On some conditions I need to disable this feature (on already > created and living list control). You need to get at the header part of the list control, and modify its styles directly, e.g. // must be in report mode ASSERT(GetWindowLong(m_list.m_hWnd, GWL_STYLE) & LVS_REPORT); CHeaderCtrl* pHead = (CHeaderCtrl*) lstctrl.GetDlgItem(0); ASSERT(pHead != 0); pHead->ModifyStyle(HDS_BUTTONS, 0); Note that when a list control is in report mode, the associated header control always has ID 0. See books online under "About Header Control Styles" for more information about the header styles. Katy -- Katy Mulvey <mailto:ktm@ormec.com> Software Development Engineer ORMEC Systems
Become an MFC-L member | Вернуться в корень Архива |