|
-
April 3rd, 2003, 03:54 PM
#1
MFC: ClistCtrl::GetSelectedColumn
Hi,
I'm currently using a CListCtrl for my application, thus i would like to sort items when the user click on an column header.
I manage to detect the click action, but i don't know how to retrieve the selected column...the msdn talk about a GetSelectedColumn method in the CListCtrl class, that's cool but when i type the call to this method and i compile i've an:
:\myprog\mator\DialogPlayer.cpp(225) : error C2039: 'GetSelectedColumn' : is not a member of 'CListCtrl'
c:\program files\microsoft visual studio\vc98\mfc\include\afxcmn.h(177) : see declaration of 'CListCtrl'
how can i do ?
Thanks for help !
-
April 3rd, 2003, 04:04 PM
#2
PHP Code:
ON_NOTIFY(LVN_COLUMNCLICK, IDC_MYLIST, OnLvnColumnclickMyList)
void MyView::OnLvnColumnclickMyList(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// pNMLV->iSubItem is the column index
_myList.SortItems(CompareFun, pNMLV->iSubItem);
*pResult = 0;
}
-
April 3rd, 2003, 04:12 PM
#3
-
April 3rd, 2003, 04:13 PM
#4
To detect a click on the column header, you can respond to a HDN_ITEMCLICK message. It is sent via ON_NOTIFY. For example,
ON_NOTIFY( HDN_ITEMCLICK, 0, OnClickListColumnHdr )
The handler appears like this:
void CMyDlg::OnClickListColumnHdr(NMHDR* pNotifyStruct, LRESULT* pResult)
pNotifyStruct contains a member called 'iItem' that indicates the column that was clicked.
Gort...Klaatu, Barada Nikto!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|