The problem is that the label of the item in the first column is always empty. I assume this is because normally the edit control would be over that item (without repositioning it) and you won't recognize it. I already tried to change the text via SetGadgetItemText() but it doesn't have any effect. Actually this should be perfectly normal because as long as the edit control is on screen the program doesn't recieve any input.
Code: Select all
#LST_Items = 101
OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ListIconGadget(#LST_Items,5,5,310,230,"Firstname",100,#PB_ListIcon_FullRowSelect | #PB_ListIcon_GridLines | #LVS_EDITLABELS)
AddGadgetColumn(#LST_Items,1,"Lastname",100)
AddGadgetItem(#LST_Items,-1,"Steve" + Chr(10) + "Martin")
AddGadgetItem(#LST_Items,-1,"John" + Chr(10) + "Candy")
AddGadgetItem(#LST_Items,-1,"Chavey" + Chr(10) + "Chase")
AddGadgetItem(#LST_Items,-1,"Eddie" + Chr(10) + "Murphy")
Global lpPrevFunc
Procedure EditLabelProc(hWnd,uMsg,wParam,lParam)
Select uMsg
Case #WM_WINDOWPOSCHANGING
Protected *lpwp.WINDOWPOS = lParam
*lpwp\x = GetGadgetItemAttribute(#LST_Items,0,#PB_ListIcon_ColumnWidth) + 4
ProcedureReturn 0
EndSelect
ProcedureReturn CallWindowProc_(lpPrevFunc,hWnd,uMsg,wParam,lParam)
EndProcedure
Procedure WindowCallback(hWnd,uMsg,wParam,lParam)
Select uMsg
Case #WM_NOTIFY
*nmh.NMHDR = lParam
If *nmh\hwndFrom = GadgetID(#LST_Items)
Select *nmh\code
Case #LVN_BEGINLABELEDIT
Protected hwndLVEdit = SendMessage_(*nmh\hwndFrom,#LVM_GETEDITCONTROL,0,0)
Protected Result$ = GetGadgetItemText(#LST_Items,GetGadgetState(#LST_Items),1)
SendMessage_(hwndLVEdit,#WM_SETTEXT,0,@Result$)
lpPrevFunc = SetWindowLong_(hwndLVEdit,#GWL_WNDPROC,@EditLabelProc())
ProcedureReturn 0
Case #LVN_ENDLABELEDIT
*nmpdi.NMLVDISPINFO = lParam
If *nmpdi\item\pszText
SetGadgetItemText(#LST_Items,GetGadgetState(#LST_Items),PeekS(*nmpdi\item\pszText),1)
EndIf
ProcedureReturn 0
EndSelect
EndIf
ProcedureReturn 0
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
SetWindowCallback(@WindowCallback())
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend

