|
-
September 16th, 1999, 12:36 PM
#1
CListCtrl sorting a column
My CListCtrl in my CFormView is working fine, sorting the items (far left col). I want to be able to click on the 2nd column (1st subitem) heading & sort the list based on the data in that column. Can't find much help in doc. Appreciate any s****. Thanks in advance to anyone.
-
September 16th, 1999, 01:31 PM
#2
Re: CListCtrl sorting a column
Just handle the LVN_COLUMNCLICK notify message. In the handler, dedermine which column is clicked and that's the column you are going to sort. Then call the SortItems() member function, which requires a pointer to a custom written static function which returns the result of compareing two items.
I hate fat programs as much as I hate being fat myself. I am lean and mean and so is my program.
-
September 16th, 1999, 02:14 PM
#3
Re: CListCtrl sorting a column
Thanks for your quick answer. Does the custom written static function have to be global . . or can it be just a member function of the view class? Thanks very much for all your help.
-
September 16th, 1999, 03:07 PM
#4
Re: CListCtrl sorting a column
You need to look at the help for SortItems() member function for CListCtrl.
SortItems is defined as:
BOOL SortItems( PFNLVCOMPARE pfnCompare, DWORD dwData );
The best thing you can do, is write a global function as pfnCompare, and pass this, i.e., pointer to the CListCtrl class itself, as the dwData. This pointer will be passed to your compare function, as well as lParam's of the two items to be compared. You know what to do with them.
The compare function is declared as:
int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
I hate fat programs as much as I hate being fat myself. I am lean and mean and so is my program.
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
|