Editable Treeview
Posted: Sat Mar 27, 2004 7:01 am
Code updated for 5.20+
This code works because I've added result=1
Why does this notification (#TVN_ENDLABELEDIT) need this result result ?
This code works because I've added result=1
Why does this notification (#TVN_ENDLABELEDIT) need this result result ?
Code: Select all
#Window = 0
#Gadget_TV = 0
Procedure CB(window, message, wParam, lParam)
result = #PB_ProcessPureBasicEvents
If window = WindowID(#Window)
If message = #WM_NOTIFY
; =======================
; Treeview Notifications
; =======================
*tvinfo.NMTVDISPINFO = lParam
If *tvinfo\hdr\hwndfrom = GadgetID(#Gadget_TV)
If *tvinfo\hdr\code = #TVN_BEGINLABELEDIT
; ==================================
; something to do before editing ...
; ==================================
EndIf
If *tvinfo\hdr\code = #TVN_ENDLABELEDIT And *tvinfo\item\pszText <> 0
; =======================
; get results...it works!
; =======================
Debug "Selected Item: " + Str(GetGadgetState(#Gadget_TV))
Debug "The new label is: " + PeekS(*tvinfo\item\pszText)
ProcedureReturn
EndIf
EndIf
EndIf
EndIf
ProcedureReturn result
EndProcedure
If OpenWindow(#Window, 0, 0, 300, 200, "Editable Treeview (edit on 2nd click)",
#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
tv = TreeGadget(#Gadget_TV, 10, 10, 280, 180)
AddGadgetItem(#Gadget_TV, -1, "item 1")
AddGadgetItem(#Gadget_TV, -1, "item 2")
AddGadgetItem(#Gadget_TV, -1, "sub item 2", 0, 1)
AddGadgetItem(#Gadget_TV, -1, "sub item 2", 0, 1)
;new editable style
SetWindowLong_(tv, #GWL_STYLE, GetWindowLong_(tv, #GWL_STYLE) | #TVS_EDITLABELS)
;new callback
SetWindowCallback(@CB())
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
EndIf