; --------------------------------------------------------------------- ; How to make ListIconGadget Items Editable by the User ; by Timo Harter ; --------------------------------------------------------------------- ; ; You should read my 'TreeGadgetEdit' Tutorial first, as this one only ; shows changes to be made from the first one. ; ; --------------------------------------------------------------------- #List = 1 ; just to make the Code more readable. ; This Structure is a little different that the one for TreeGadget ; (it is LV_ITEM instead of TV_ITEM, and the Name is different :) ) Structure NMLVDISPINFO hdr.NMHDR item.LV_ITEM EndStructure Declare Callback(Window.l, Message.l, wParam.l, lParam.l) OpenWindow(0, 0, 0, 200, 400, #PB_Window_SystemMenu | #PB_Window_Screencentered, "ListIconGadget Example") CreateGadgetList(WindowID()) ListIconGadget(#List, 5, 5, 190, 390, "Edit Items:", 150) ; change the Styles: here, we add #LVS_EDITLABELS Styles.l = GetWindowLong_(GadgetID(#List), #GWL_STYLE) Styles = Styles | #LVS_EDITLABELS SetWindowLong_(GadgetID(#List), #GWL_STYLE, Styles) AddGadgetItem(1, 0, "Item0") AddGadgetItem(1, 0, "Item0") AddGadgetItem(1, 0, "Item0") AddGadgetItem(1, 0, "Item0") SetWindowCallback(@Callback()) While WaitWindowEvent() <> #PB_EventCloseWindow: Wend End ; ------------------------------------------------------------------------------------ Procedure Callback(Window.l, Message.l, wParam.l, lParam.l) result = #PB_ProcessPureBasicEvents If Message = #WM_NOTIFY *lp.NMHDR = lParam ; check, if it was really this Gadget, who sent the Message: ; this can also be done for TreeGadgets (i forgot that) If *lp\hwndFrom = GadgetID(#List) ; get real Message: Select *lp\code Case #LVN_BEGINLABELEDIT ; this is just the same as for TreeGadget, only the Message Constant is different. ; return #True, to forbit editing, #False to allow it. If GetGadgetState(1) = 1 result = #True EndIf ; ------------------------------------------ Case #LVN_ENDLABELEDIT ; This is also the same, just the Structure Name and the Constant has changed. *pvdi.NMLVDISPINFO = lParam ; Even the Members of the Structure are the same: If *pvdi\item\pszText <> #NULL Text.s = PeekS(*pvdi\item\pszText) ; If you want to accept the Text, set 'result' to #True, if not, set it to ; #False. If Text = "" result = #False Else result = #True EndIf EndIf ; ------------------------------------------ EndSelect EndIf EndIf ProcedureReturn result EndProcedure