The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: jefe on December 30, 2008, 01:24:14 PM

Title: Listbox sorted property
Post by: jefe on December 30, 2008, 01:24:14 PM
 Do someone know how to set the Listbox property sorted (true or false) .
Title: Re: Listbox sorted property
Post by: ragdog on December 30, 2008, 04:23:44 PM
Hi

Read Iczelion tutorials 31

Quote
Sorting items/subitems

You can specify the default sorting order of a listview control by specifying LVS_SORTASCENDING or LVS_SORTDESCENDING styles in CreateWindowEx. These two styles order the items using their labels only. If you want to sort the items in other ways, you need to send LVM_SORTITEMS message to the listview control.

    LVM_SORTITEMS
    wParam = lParamSort
    lParam = pCompareFunction

lParamSort is a user-defined value that will be passed to the compare function. You can use this value in any way you want.
pCompareFunction is the address of the user-defined function that will decide the outcome of the comparison of items in the listview control. The function has the following prototype:

CompareFunc proto lParam1:DWORD, lParam2:DWORD, lParamSort:DWORD

lParam1 and lParam2 are the values in lParam member of LV_ITEM that you specify when you insert the items into the listview control.
lParamSort is the value in wParam you sent with LVM_SORTITEMS

When the listview control receives LVM_SORTITEMS message, it calls the compare function specified in lParam of the message when it needs to ask us for the result of comparison between two items. In short, the comparison function will decide which of the two items sent to it will precede the other. The rule is simple: if the function returns a negative value, the first item (represented by lParam1) should precede the other. If the function returns a positive value, the second item (represented by lParam2) should precede the first one. If both items are equal, it must return zero.
...
..
.
Title: Re: Listbox sorted property
Post by: Tedd on December 30, 2008, 05:44:56 PM
Quote from: jefe on December 30, 2008, 01:24:14 PM
Do someone know how to set the Listbox property sorted (true or false) .

How many times do you want to ask the same question? -- http://www.masm32.com/board/index.php?topic=10575.0