Multi column list box with sort

BlitzMax Forums/MaxGUI Module/Multi column list box with sort

Ghost Dancer(Posted 2008) [#1]
Yay, I have finally cracked this. I've modified Ziltches code to make it OO structured and also added my own sort functionality (clicking column heading will alternate between ascending and decending sort). I hope others find it useful :-)

EDIT: Moved code to Code archives section: http://www.blitzmax.com/codearcs/codearcs.php?code=2293


Chalky(Posted 2008) [#2]
This looks great. However I can't seem to move the window - any attempt to do so via the title bar renders the listboxes black and the window freezes til I click the desktop and then reclick a listbox. The same happens if I try via the system menu :(


Ghost Dancer(Posted 2008) [#3]
Not sure how I missed that (although I have just updated Blitz to 1.30, not sure if the same happened in 1.28). Will find a way to fix it :-)


Ghost Dancer(Posted 2008) [#4]
OK fixed it for 1.30. Not sure why, but adding a canvas seemed to fix it! I also updated it to extend TProxyGadget, made it unicode compliant, and also remembers the selected item after a sort.


Chalky(Posted 2008) [#5]
Thanks for the update - this is seriously neat!

Still a teeny problem though: remembering the selected item after a sort is very flaky - clicking on a row and then on random column headers often removes the selection. Good opportunity for me to stretch the old brain cell and see if I can work out why... ;-)


jsp(Posted 2008) [#6]
Very nice. A good and useful addition! Something i could may add to Logic Gui?

While playing with it i found two minor things though you might want to look at.

When moving the separators between the titles and then clicking on one of them to do a sort, the first separator jumps back to it's initial size.

I made the window resizable to see how that works:
Local window:TGadget =CreateWindow("Multi-Column List Example",100,100,320,280,Null,WINDOW_TITLEBAR|WINDOW_CLIENTCOORDS|WINDOW_RESIZABLE)
Again the separator of the first column moves, this time to the smallest position, when you resize the window (or minimize/maximize).


Ghost Dancer(Posted 2008) [#7]
Hmm, see what you mean about the selection. Can't see anything obvious so feel free to have a crack at it.

jsp - I was hoping you would ask that :-) Feel free to use it in LogicGui, although you may want to wait until the bugs have been ironed out.

I was already aware of the first column width resizing, although on mine (Win XP) the size remains when sorting. It reset to minimum width if I edge aligned the gadget, and also if I resize the window. It's on my list of things to fix!


Difference(Posted 2008) [#8]
That resizing problem rang a bell:
http://blitzmax.com/Community/posts.php?topic=53343#609330

There are a lot of LVM_SETCOLUMNWIDTHs sent in win32listbox.cpp so if that code is called, it could be the source of the resizing as it was for me 2 years ago ! :)


Ghost Dancer(Posted 2008) [#9]
Thanks for the link (it needs a www. to work btw). I've got a few things I need to work on so will try and have a look at this tomorrow.


Ziltch(Posted 2008) [#10]
Good work Ghost Dancer!

What Peter said is true.
If we could only get maxgui code to check first if there is only one column before autosizing.

this line appears 3 times in win32listbox.cpp
SendMessage(_gadget.hwnd(),LVM_SETCOLUMNWIDTH,0,-2);


Ghost Dancer(Posted 2008) [#11]
Thanks Ziltch - couldn't have done it without your original code.

Would be great if maxgui could be updated as you suggested, I prefer not to change the module code if at all possible. I think for now I will write an update method that can be called on a resize event, but would be nice if it could be self contained.

EDIT: Just uploaded latest version to code archives (link in first post)