Get item in multicolumn listbox?

BlitzMax Forums/MaxGUI Module/Get item in multicolumn listbox?

Raph(Posted 2007) [#1]
I am using the multicolumn listbox code that Ziltch did, and am trying to make it possible to select an individual item as opposed to a whole row. SelectedGadgetItem() returns the row, and I cannot figure out how to get the specific selected item.

The end goal is making it so that you can edit this item. I found plenty of references on the Net to LVS_EDITLABEL, but can't see how to get it working either. I tried this function, but it didn't seem to do anything:

Zapped old and bad code


If I can get the selected item, I can let you edit it in a different textfield. If I can edit it directly in the grid, even better. Any ideas?


Raph(Posted 2007) [#2]
I have managed to get an edit box to pop up for the first column in the listbox, using Ziltch's code and much trial and error:

http://www.blitzbasic.com/Community/posts.php?topic=62706#700557

But I haven't figured out how to get it to pop up for any column but the first one. Is there a style that I need to be setting on added columns or on the listbox as a whole to allow any of the labels to be edited?


SebHoll(Posted 2007) [#3]
Don't really know a lot about this, but I do know that the full-row select parameter is set internally by MaxGUI when the list box is created. In win32listbox.cpp:

SendMessage( hwnd,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT,LVS_EX_FULLROWSELECT);
You'll probably need to unset this LVS_EX_FULLROWSELECT parameter, but other than that, I don't really know.


Raph(Posted 2007) [#4]
I have tried toggling that parameter but it doesn't seem to do anything. My function seems to work, though, because I can use it to toggle other extended style things, like the grid.


Ziltch(Posted 2007) [#5]
The example code is in post

http://www.blitzbasic.com/Community/posts.php?topic=62706#700557

the important bits of code are;



the constants and structures needed are in the code in post
http://www.blitzbasic.com/Community/posts.php?topic=62706#700557

It is a lot trickier than it should be!!


Raph(Posted 2007) [#6]
Yep, that looks like the code I extracted from your other post. Slightly different though -- I'd have to compare them closely to see the differences, but this one calls ModifyGadgetItem() instead of SetListBoxItem()?

So the other version seemed to only edit the first column. Based on what I was reading today on MSDN, iSubItem is in the LVITEM returned as iItem in the DispInfo. I don't see where this queries that?

I also notice that this line:


oldWinProc =SetWindowLongA(QueryGadget(ExplorerPanel,QUERY_HWND), GWL_WNDPROC,Int(Byte Ptr(NewWinProc)))


references the parent window of the grid, but the LVEditHandle references the grid itself. My grid is not in a panel -- would that matter? Should I just reference the window itself?

I'll mess with this and see how far I get. :)


Raph(Posted 2007) [#7]
OK, I tried this out. And I get almost the same behavior. I am able to edit the first column -- regardless of what I click on, I always get the edit box in the first column.

I changed

If NewText > "" Then ModifyGadgetItem(Explorer,DispInfo.iItem,NewText,Explorer.items[DispInfo.iItem].flags,Explorer.items[DispInfo.iItem].icon,Explorer.items[DispInfo.iItem].tip)


to
If NewText > "" Then SetListBoxItem(explorer,NewText,DispInfo.iItem,column)


Then I manually set 'column' to various other values, and was able to change the text in other columns. But the edit box still appears on the first column.

I added a function to toggle LVS_EX_FULLROWSELECT. When it's turned off, you can't even click on columns other than the first one.

iSubItem is a field in tagNMLVDISPINFO, but it always seems to be 0. If it was returned, then it seems like I'd be able to tell which column to change...

I also notice that when I edit that first column, it blows away the rest of the columns in that row -- but that's easy enough to work around since they are sourced from data elsewhere.

Here's where I stand right now. A double-click in the grid area will toggle the full-row select on and off (you can change LVS_EX_FULLROWSELECT to LVS_EX_GRIDLINES to toggle the grid on and off).




Raph(Posted 2007) [#8]
I have most of a solution. It doesn't work perfectly because the currently SelectedGadgetItem isn't always the row you just clicked on. But that seems like it shoudl be a fairly easy fix.

In short, instead of listening for WM_NOTIFY on the ExplorerPanel, listen for WM_LBUTTONDBLCLK on the listbox. Then I get the widths of each column, and calculate which column the doubleclick happened in.

Here's a semi-working version. Sorry for the messiness, it's not at all clean code. I don't know why freeing the textfield isn't making it go away, but since I source my data elsewhere, I'll be rebuilding the listbox anyhow.



Anyone know why activateGadget() won't set the textfield to be active?