Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
I have 3 fields
m_list.InsertColumn(0, _T("File Name"), LVCFMT_LEFT, 640);
m_list.InsertColumn(1, _T("Size"), LVCFMT_RIGHT, 120);
m_list.InsertColumn(2, _T("Item"), LVCFMT_RIGHT, 80);
When the fields are filled the File Name is on the left. When sorted it jumps the the right. How can I fix it?
Posted 21-Jan-13 0:23am
Roger6513.9K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I found the answer, what I had, copied the justifymask from the column clicked. This version copies each column separately.
// Display or hide sort icon on column to be sorted
void CFindWhatDlg::SetSortIcon()
{
	ASSERT(m_list);
	CHeaderCtrl* pHeaderCtrl = m_list.GetHeaderCtrl();
	ASSERT(pHeaderCtrl);
	
	HDITEM hdrItem;
	for (int nCol = 0; nCol < pHeaderCtrl->GetItemCount(); nCol++)
    {
		hdrItem.mask = HDI_FORMAT | HDI_IMAGE;
		pHeaderCtrl->GetItem(nCol, &hdrItem);
		if(bAscending)
		{
			hdrItem.iImage = m_nUpArrow;
			hdrItem.fmt    = hdrItem.fmt & HDF_JUSTIFYMASK |
				HDF_IMAGE | HDF_STRING| HDF_BITMAP_ON_RIGHT;
		}
		else
		{
			hdrItem.iImage = m_nDownArrow;
			hdrItem.fmt    = hdrItem.fmt & HDF_JUSTIFYMASK |
				HDF_IMAGE | HDF_STRING| HDF_BITMAP_ON_RIGHT;
		}
		pHeaderCtrl->SetItem(nCol, &hdrItem);
    }
}
  Permalink  
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 480
1 mhegazy94 460
2 Ravi Bhavnani 190
3 Kornfeld Eliyahu Peter 185
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 7,135
1 OriginalGriff 6,801
2 CPallini 5,350
3 George Jonsson 3,619
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web01 | 2.8.140922.1 | Last Updated 24 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100