Sorting Strings In a ListBox win32
-
I am wondering, since u can pass a style LBS_SORT to the listbox when Initalized. But is there a flag that I can pass to SetDlgItemMessage(...) to sort the LB when I push a button ??? I dont want to have to write my own Sorting function to sort strings Alphabetically. Thanks
-
I am wondering, since u can pass a style LBS_SORT to the listbox when Initalized. But is there a flag that I can pass to SetDlgItemMessage(...) to sort the LB when I push a button ??? I dont want to have to write my own Sorting function to sort strings Alphabetically. Thanks
-
I am wondering, since u can pass a style LBS_SORT to the listbox when Initalized. But is there a flag that I can pass to SetDlgItemMessage(...) to sort the LB when I push a button ??? I dont want to have to write my own Sorting function to sort strings Alphabetically. Thanks
-
I think what you want is to change the sorting style of the listbox at runtime. Try SetWindowLong(..) in your button handler. Art
Exactly thats what I was trying to do at runtime sort the items in the LB.I will try SetWindowsLong(...)
-
I am wondering, since u can pass a style LBS_SORT to the listbox when Initalized. But is there a flag that I can pass to SetDlgItemMessage(...) to sort the LB when I push a button ??? I dont want to have to write my own Sorting function to sort strings Alphabetically. Thanks
You can not use SetWindowLong(...)for a list box, causes the program to freeze.
-
You can not use SetWindowLong(...)for a list box, causes the program to freeze.
Don't know why you are getting that. Here is my code: ---------------------------------- DWORD dwStyle = m_lb1.GetStyle(); dwStyle |= LBS_SORT; ::SetWindowLong(m_lb1.GetSafeHwnd(),GWL_STYLE,dwStyle); ----------------------------------- A check with spy++ clearly shows the listbox style has changed from no sort to sort. However the sorting operation doesn't occur. Don't know why. Sorry. It doesn't freeze the app though. Art
-
I am wondering, since u can pass a style LBS_SORT to the listbox when Initalized. But is there a flag that I can pass to SetDlgItemMessage(...) to sort the LB when I push a button ??? I dont want to have to write my own Sorting function to sort strings Alphabetically. Thanks
Read this: http://www.codeproject.com/combobox/recreatelistbox.asp Art
-
Read this: http://www.codeproject.com/combobox/recreatelistbox.asp Art
Mine does not work either this is my code ------------------------------------------------------- int x = SetWindowLong(dhwnd,GWL_STYLE,GetWindowLong(dhwnd,GWL_STYLE)|LBS_SORT); SendDlgItemMessage(dhwnd,IDC_LIST1,LB_RESETCONTENT,0,0); for(int i=0; i<6; ++i) SendDlgItemMessage(dhwnd,IDC_LIST1,LB_ADDSTRING,0,(LPARAM)table[i].list); SendDlgItemMessage(dhwnd,IDC_LIST1,LB_SETCURSEL,0,0); SetDlgItemText(dhwnd,IDC_EDIT1,table[0].list); ------------------------------------------------------------------------- I dont think I am getting the handle to the listbox
-
I am wondering, since u can pass a style LBS_SORT to the listbox when Initalized. But is there a flag that I can pass to SetDlgItemMessage(...) to sort the LB when I push a button ??? I dont want to have to write my own Sorting function to sort strings Alphabetically. Thanks
I have not explained this very. I created a listbox using the resource editor. The problem is I cant set the style to a LB because the resource editor set all the flags. But I assume u can change the style using SetWindowLong(...) but nothing happens. Is there a way I can get a handle to the listbox. This is win32 and not MFC.