![]() |
CXTListCtrl With Sort Question |
Post Reply
|
| Author | |
hiaward
Newbie
Joined: 25 September 2007 Location: China Status: Offline Points: 1 |
Post Options
Thanks(0)
Quote Reply
Topic: CXTListCtrl With Sort QuestionPosted: 07 October 2007 at 3:58am |
|
hi!
I use CXTListCtrl in a dialogue,and subclass the CXTHeaderCtrl,but when i right click on the head ,then select any sort menu ,it can not work.btw,when i left click on the head,it can work very nice.
I dubuged the code,and found that when i right click ,it can not go to CTest_AllDlg::OnNotify message.why??
I use v9.60.thanks.
void CTest_AllDlg::InitList()
{ //m_CtlList.SetExtendedStyle(LVS_ALIGNLEFT |LVS_EX_HEADERDRAGDROP |LVS_EX_FULLROWSELECT |LVS_EX_TRACKSELECT |LVS_EX_CHECKBOXES); m_CtlList.BuildColumns(_countof(_Proc_nColWidth),_Proc_nColWidth,_Proc_nFieldName); this->LoadList(); HWND hWndHeader = m_CtlList.GetDlgItem(0)->GetSafeHwnd();
m_header.SubclassWindow(hWndHeader); m_header.EnableAutoSize(TRUE);
m_header.ResizeColumnsToFit(); SortColumn(m_nSortedCol, m_bAscending); m_CtlList.ModifyExtendedStyle(0, LVS_EX_FULLROWSELECT|LVS_EX_FULLROWSELECT);
m_CtlList.EnableUserSortColor(TRUE); m_header.SetTheme(new CXTHeaderThemeOffice2003());
CXTPPaintManager::SetTheme(xtpThemeOffice2003); CXTHeaderTheme* pTheme = m_header.GetTheme(); if(pTheme) { pTheme->SetDrawStyle(XTTHEME_SORTARROW|XTTHEME_HOTTRACKING,&m_header); EnableControls(); } } void CTest_AllDlg::LoadList()
{ m_CtlList.InsertItem(0,NULL,0); m_CtlList.SetItemText(0,0,"1"); m_CtlList.SetItemText(0,1,"a"); m_CtlList.InsertItem(1,NULL,0);
m_CtlList.SetItemText(1,0,"2"); m_CtlList.SetItemText(1,1,"b"); m_CtlList.InsertItem(2,NULL,0);
m_CtlList.SetItemText(2,0,"3"); m_CtlList.SetItemText(2,1,"c"); m_CtlList.InsertItem(3,NULL,0);
m_CtlList.SetItemText(3,0,"4"); m_CtlList.SetItemText(3,1,"d"); } BOOL CTest_AllDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{ HD_NOTIFY *pHDNotify = (HD_NOTIFY*)lParam; if(pHDNotify->hdr.code == HDN_ITEMCLICKA ||
pHDNotify->hdr.code == HDN_ITEMCLICKW) { if (pHDNotify->iItem == m_nSortedCol) SortColumn(pHDNotify->iItem, !m_bAscending); else SortColumn(pHDNotify->iItem, BoolType(m_header.GetAscending())); } return CXTResizeDialog::OnNotify(wParam, lParam, pResult);
} void CTest_AllDlg::SortColumn(int iCol,bool bAsc)
{ m_bAscending = bAsc; m_nSortedCol = iCol; // set sort image for header and sort column.
m_CtlList.SetSortImage(m_nSortedCol,m_bAscending); CXTSortClass csc(&m_CtlList,m_nSortedCol);
switch(m_nSortedCol) { case 0: csc.Sort(m_bAscending,xtSortInt); break; case 1: csc.Sort(m_bAscending,xtSortString); break; default: break; } } |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |