I have got Columns in listBoxes

BlitzMax Forums/BlitzMax Module Tweaks/I have got Columns in listBoxes

Ziltch(Posted 2005) [#1]
I have got Columns in listBoxes!

Here is what I have come up with.

It is windows only! If any one wants to have a go at Linix/Mac ?


The only problems is the auto resizing causes the 1st column to be the width of the textbox. So only non resized listbox work 100%. I hope to find a way around this.





Regular K(Posted 2005) [#2]
I had to do some modifications to get it to work here (v1.14)



But it works, and its nice. Thank you for this, even if it does act a bit weird when resizing.

(commented strict out because of conversion errors, changed Query to QueryObject)


Difference(Posted 2005) [#3]
I think I know how to do this I'll try get a working example up later.


Difference(Posted 2005) [#4]
I think this line in win32listbox.cpp is the trouble maker, but I'll have to test another day:

	case WM_SIZE:
		SendMessage( _gadget.hwnd(),LVM_SETCOLUMNWIDTH,0,LOWORD(lp) );
		break;


Another way to do this:




Ziltch(Posted 2005) [#5]
It would be nice if blitzmax had the option to let the programmer size gadgets.


Sky009(Posted 2005) [#6]
Hello!

Error, "Identifier QUERY_HWND not found"

Ralf


Difference(Posted 2005) [#7]
version 1.14 + Syncmods fixes that? If no use
Const QUERY_HWND = 1 'I think


Regular K(Posted 2005) [#8]
I would very much appreciate it if this was added into the MaxGUI module eventually :D


Jay Kyburz(Posted 2006) [#9]
Any chance we could make this official and get mac and Linux support?


skidracer(Posted 2006) [#10]
Yes.


Jay Kyburz(Posted 2006) [#11]
You rock skid.


Ziltch(Posted 2006) [#12]
It would make progs look/work better!
Thanks Skidracer in advance.


Grisu(Posted 2006) [#13]
Any update on this?
Did some optimised this?

And yes, any official help would be awesome!


Ziltch(Posted 2006) [#14]
Here is an example prog with the best workarounds a could get working.

:Updated


Grisu(Posted 2006) [#15]
It crashes on Bmx1.20 with and without debugmode "DebugLog:resize"


Ziltch(Posted 2006) [#16]
It works for me on 1.20
What line does it crash on?


Grisu(Posted 2006) [#17]
It shows up and a moment later it starts counting in the box at the bottom, then it crashes after 2 secs or so.

Memory access error or in debugmode the message above is given.


kenshin(Posted 2006) [#18]
Confirmed. Crashes on v1.20 with Unhandled Memory Exception. This line is the culprit:
AddTextAreaText(TextArea,"~n"+MilliSecs()+"  "+EvName)

Comment it out and it runs, but there's a box drawn at the bottom of the window which doesn't look like it should be there.



Ziltch(Posted 2006) [#19]
I have updated the code above. The error is strange , but not to do with the listbox columns.

The resizing looks bad, as it flashes before it fixes the column sizes. The problem is the blitz thinks only one column can exist and that it must be the full width of the listbox.


Grisu(Posted 2006) [#20]
There is a redrawing bug with all listboxes and comboboxes.
http://www.blitzbasic.com/Community/posts.php?topic=59315


Regular K(Posted 2006) [#21]


I rewrote it to work with SuperStrict. Doesn't include the tutorial though.

Hope that saves someone sometime.

(also digging article up!)


Ziltch(Posted 2006) [#22]
Here is a link to an example multi column file explorer.

http://www.blitzbasic.com/Community/posts.php?topic=61520

The main trick to remember is to only use multi column list boxes on windows that do not resize. Also that the 1st column auto resizes based off the largest text in the column.


Punksmurf(Posted 2006) [#23]
Thank you for this code. It works nice - but sadly enough only in debug mode.

I don't know if this is a bug in blitz, to me it seems like it.

Note that this does not go wrong when building a debug application.

Also, I do not remember seeing this error before, but I'm fairly sure I've had some final builts as well, so I think it might be some module that has been updated...

It goes wrong at this point in the example (I added three lines with a print statement).


The output is as follows:

Executing:test.exe
AddListBoxColumn Debug
1
148451344
Unhandled Memory Exception Error
Process complete

As you see, before calling AddListBoxColumn count is 1, after that, it's 148451334. I don't see how count could be affected, though, so that's where I think blitz is bugging, but I'd like to hear you before heading to the bug reports forum.

So, what are your thoughts on this?

UPDATE

I tried to add in another local variable, c:


I'd say that even if c (formerly count) would be affected, count wouldn't because I assigned the value of count to c, not a reference of it... But it acts the other way around:

Executing:test.exe
AddListBoxColumn
1
148451344, 148451344
Unhandled Memory Exception Error
Process complete

This looks seriously wrong to me...


Punksmurf(Posted 2006) [#24]
**bumpetybump**

none of you tech guys has an idea besides just releasing my application as a debug built?


Punksmurf(Posted 2006) [#25]
Hmmm, I've had some more trouble with this :(
It does not support more than 12 columns:
edit: read on, because the 12 columns is not the problem, as I found out somewhat later.



Removing the last line works fine.

I'll live with 12 columns, but... is there a solution?


Kev(Posted 2006) [#26]

The only problems is the auto resizing causes the 1st column to be the width of the textbox. So only non resized listbox work 100%. I hope to find a way around this.



this can be fixed by rem'ing all LVM_SETCOLUMNWIDTH found in your 'mod\brl.mod\win32maxgui.mod\win32gui\win32listbox.cpp look for SendMessage(_gadget.hwnd(),LVM_SETCOLUMNWIDTH,0,-2);

@Punksmurf, not sure whats going on, i have mingw installed and use c for adding columns and dont have this problem.

int AddListViewColumn(HWND listview,int index,char *title,int width){

       
        LV_COLUMN column;
        column.mask = LVCF_FMT | LVIF_IMAGE | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
        column.fmt = LVCFMT_LEFT;
        column.cx = width;
        column.pszText = (LPTSTR)title;
        column.iSubItem = index;
        
        return(int)SendMessage(listview,LVM_INSERTCOLUMN,(WPARAM) (int) index,(long)(LPARAM)&column);
}    


heres the function call i make, and below for example the way i modify the listbox.
Local listbox_local_files:TGadget = CreateListBox(0,GadgetHeight(combobox_local_drives)+5,GadgetWidth(panel3),GadgetHeight(panel3)-65,panel3)
SetGadgetLayout listbox_local_files,1,1,1,1
SetGadgetIconStrip listbox_local_files,tmp_iconstrip
SendMessageA(QueryGadget(listbox_local_files,QUERY_HWND),LVM_SETIMAGELIST,LVSIL_SMALL,iconlist)
Local LV_style:Long = GetWindowLongA(QueryGadget(listbox_local_files,QUERY_HWND),GWL_STYLE)
SetWindowLongA(QueryGadget(listbox_local_files,QUERY_HWND),GWL_STYLE,LV_style ~ LVS_NOCOLUMNHEADER )
SendMessageA(QueryGadget(listbox_local_files,QUERY_HWND),LVM_SETEXTENDEDLISTVIEWSTYLE,0, LVS_EX_SINGLEROW)
SendMessageA(QueryGadget(listbox_local_files,QUERY_HWND),LVM_DELETECOLUMN,0,0)

AddListViewColumn(QueryGadget(listbox_local_files,QUERY_HWND),0,"Name",160)
AddListViewColumn(QueryGadget(listbox_local_files,QUERY_HWND),1,"Size",60)
AddListViewColumn(QueryGadget(listbox_local_files,QUERY_HWND),2,"Type",120)
AddListViewColumn(QueryGadget(listbox_local_files,QUERY_HWND),3,"Modifyed",120)




Punksmurf(Posted 2006) [#27]
Kev,

Thank you for your reply. As IŽm on a deadline now and we can (for the moment) live with 12 columns, IŽll try your solution in the next year.

Edit;

I just made some stupid mistake with copy/paste stuff (I forgot to replace the names of the listboxes) and found out that I could add more columns, but some columns had equal values for ŽColumnŽ. However, now some columns of other listboxes have disappeared (Before you ask, I have fixed my mistake, so I refer to the correct listboxes now'.

( Function AddListBoxColumn(ListBox:TGadget,Column:Int,HeadingText:String,Width:Int,Style:Int) )

So, what causes the problem is not really clear, yet.

By the way, it would not give an error, it accepts the columns and all, I can fill them, too, but the headers of the columns are not displayed for some reason.


Punksmurf(Posted 2006) [#28]
Okay, so

this:


works fine.

And this:



Doesn't. I only deleted the last lines.


edit: blitz 1.24 is up, this solves my earlier bug.


Punksmurf(Posted 2007) [#29]
Update... the solution in this topic still won't work for me. However, I found a working solution on some German BlitzMax forum. Since I'm really, really bad at German and I understood it anyway, I won't bother with a translation and hand you the link.

It's over here: http://www.blitzforum.de/forum/viewtopic.php?t=20102

Works like a charm!


Raph(Posted 2007) [#30]
Excellent! Any chance that this can be ported to Mac and Linux? Seems like a relatively small set of external calls, and it'd be useful for everyone for it to be in MaxGUI.


Ziltch(Posted 2007) [#31]
That code on the german site is this code minus the header saying I wrote it. I think that is a little rude.

Raph - As this is all based on windows api calls, it is windows only.


Raph(Posted 2007) [#32]
I realize that -- but similar calls must exist in the other OSes, and it seems like a very limited set of calls. That's why I was asking -- seemed like a relatively easy port job for someone who knew the other OSes.


Punksmurf(Posted 2007) [#33]
(Posted 1 week ago)
That code on the german site is this code minus the header saying I wrote it. I think that is a little rude.

It is? I haven't looked at it that close. However, this works for me and your code doesn't... so there must be some very subtle and very important difference.
It works different anyway, I had to rewrite some of my code for it to work with it, so it's not exactly the same (but the inner workings might be, I don't know).

Anyway, I didn't mean to be rude - just helpful.