Editable List View?

Archives Forums/Win32 Discussion/Editable List View?

Picklesworth(Posted 2005) [#1]
I am trying to create an editable Windows listview in WinBlitz 3d (like here: http://www.codeproject.com/listctrl/listeditor.asp ). I have the listview, but I don't know how to make it editable.

I think that the constant I want to pass to it as a style parameter is LVS_EDITLABELS. I did find the constant. The only place I could find the actual number (rather than just its name) after a 30 minute search all over the Internet was here: http://vbnet.mvps.org/index.html?code/comctl/lvmembers.htm
Now. VB has the constant written as Const LVS_EDITLABELS = &H200. Blitz does not understand the H part (already changed the & to $). How can I make it so that Blitz knows what it's doing?

Anyway, here's the main question so you don't forget in the midst of my ramblings: How do I turn a regular listview into an editable listview? I think that it is with the use of the LVS_EDITLABELS, but I can't find out the value for that flag that Blitz would use.


If Win32 just took strings... or normal numbers... none of this rubbish would happen.


Perturbatio(Posted 2005) [#2]
Blitz does not understand the H part (already changed the & to $). How can I make it so that Blitz knows what it's doing?


try using decimal 512 instead.

what about LVM_EDITLABEL?

The LVM_EDITLABEL message begins in-place editing of the specified list view item's text. The message implicitly selects and focuses the specified item. You can send this message explicitly or by using the ListView_EditLabel macro.

LVM_EDITLABEL
wParam = (WPARAM) (int) iItem;
lParam = 0;


Parameters

iItem

Index of the list view item. To cancel editing, set iItem to -1.



Return Values

Returns the handle of the edit control that is used to edit the item text if successful or NULL otherwise.

Remarks

When the user completes or cancels editing, the edit control is destroyed and the handle is no longer valid. You can safely subclass the edit control, but you should not destroy it.
The control must have the focus before you send this message to the control. Focus can be set using the SetFocus function.

See Also

ListView_EditLabel, WM_CANCELMODE, SetFocus




Picklesworth(Posted 2005) [#3]
Fastest response ever in this section. Even after I spelled Perturbatio wrong :D
Thanks!
Trying now.


Perturbatio(Posted 2005) [#4]
can't guarantee another fast response for at least 9 hours, it's 5:37am here and I haven't slept yet (I am about to).


Picklesworth(Posted 2005) [#5]
What do you mean by "try using decimal 512 instead."? (I have tried $512, $0512, $.512, .512). I also tried $200, but it didn't seem to work either. (Note: I am probably missing something here)

LVM_EDITLABEL looks like it works, but causes me an MAV for some reason. Though, it appears to be a forced thing rather than just the user double clicking on a field and editing it.


Perturbatio(Posted 2005) [#6]
try just 512 instead of $512 (decimal instead of hexadecimal)
*EDIT*
ah, if you've done $200 then that is 512 as hex.


BlitzSupport(Posted 2005) [#7]
You want to replace &H with $ in C to Blitz conversions, ie. &H200 becomes $200, &H1AB becomes $1AB, etc -- it's a hexadecimal number.


Sweenie(Posted 2005) [#8]
What viewtype are you using?

LargeIcon, SmallIcon, Detail or list?

LabelEdit will make the main items editable, but not by doubleclicking on them.
You edit them by first singleclicking them and singleclick again within a few seconds(just like you rename files in the explorer)

However, if you are using the details-view, the subitems(the items in the columns next to the first) can't be edited.
However, you can detect a mouseclick and display a normal textbox covering the subitems bounding rectangle.
Search for Editable Listview on google for tutorials.


Picklesworth(Posted 2005) [#9]
Okay, got it all in but it won't work for one reason or another (and I think I know why), so I'll go with Sweenie's advice (which I thankfully know how to do).
Thanks a lot for all the help!


Picklesworth(Posted 2005) [#10]
I did the basic thing, but I have one problem:
It does not seem to be possible to delete my text boxes in order to put in new ones when the user clicks on the list in a different spot, unless the text boxes are already unfocussed. I tried to unfocus them using sendmessage and WM_KILLFOCUS. It caused an MAV.

If a textbox is in focus already, the event of the user clicking on the listview is not registered.

So... um... My problem entirely pivots around:
api_SendMessage VarsList_EditA,WM_KILLFOCUS,0,0

The constant WM_KILLFOCUS is defined. It equals $0008.

What am I doing wrong?



It looks like, for the more proper plan, I want to do this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsTreeViewClassLabelEditTopic.asp
How do I set that property to true? (or is it just LVS_EDITLABELS?)


Sarge(Posted 2005) [#11]
Where are you setting LVS_EDITLABELS, it should be placed like this ex:
CreateWindowEx(WS_EX_CLIENTEDGE, "SysTreeView32", Null, WS_VISIBLE|WS_CHILD| WS_CLIPSIBLINGS| LVS_EDITLABELS, x, y,
w, h, group, Null ,hInstance, Null)

this is not tested but you have to put it there, and i am pretty sure you cant do it this way Sendmessage( treeview, LVS_EDITLABELS, True, null ) because i think you have to do it when the treeview is created not after.


Picklesworth(Posted 2005) [#12]
Oh, yup, I had set that :(


Picklesworth(Posted 2005) [#13]
Oh wow!
I just had a hunch, and I was right.
I have wasted two days' worth of valuable programming time now (and it's running short because of the blasted sun!!), because of an error in my user32.decls file. The api_sendmessage command would cause an MAV no matter what.
I was just thinking "Hey, maybe I'll try the sendmessage that came with winblitz, since I'm out of ideas". So I removed the underscore, tested it, and BANG it worked!
So, this is probably the proper user32.decls api_sendmessage declaration:
api_SendMessage%(hWnd%,Msg%,wParam%,lParam%):"SendMessageA"