Archive: [Listbox] Change color of listitem & sort items alphabetically


[Listbox] Change color of listitem & sort items alphabetically
Hi,

I am using a list box in my custom page. If a checkbox is selected the selected item in the listbox should change its color. How I able to do this?

Still another question:
Is it possible to sort the items in the listbox alphabetically?

Thank you in anticipation


Really nobody who can help?


Unless you want to write a plugin there is no way to change the colours for an individual list box item.
To sort the items it'd be easiest to use the NSIS Array plugin. You can add the items to an array with WriteListC, use Sort to sort the array and finally write back to the INI file with Concat. http://nsis.sf.net/File:NSISArray.zip

-Stu


You could also set the LBS_SORT style for the list by calling SetWindowLong using the System plug-in. If that doesn't work, you'd have to change the style on advance when creating it. For that you'd have to change the source code of InstallOptions.


Any chance you could give us the magic line to use "LBS_SORT" to sort list boxes. I can't find an example of that.
Thanks,


!define GWL_STYLE -16
!define LBS_SORT 0x0002L
System::Call `user32::GetWindowLong(i R0, i ${GWL_STYLE}) i.R1`
IntOp $R1 $R1 | ${LBS_SORT}
System::Call `user32::SetWindowLong(i R0, i ${GWL_STYLE}, i R1)`

Assuming $R0 contains the handle to your list box before you call it. Read it from the INI file HWND key or by using GetDlgItem.

Stu