So, no bugs?RASHAD wrote:Your last post need to be recoded again (lot of bugs)…
Habibi, the tree gadget in your updated API example now has two editing routines; the one that is enabled when you set the TVS_EDITLABELS style to it, and your own.RASHAD wrote:API again edit in place…
When the gadget is double-clicked, your routine is activated, which manually sends the TVM_EDITLABEL message, starts recording the keystrokes into a string, then sets the tree item with that string once the ENTER key is pressed. It appears to work, although it does not filter out non alpha-numeric input like backspaces and control characters.
When the gadget is slow clicked twice (not double-clicked), or is right clicked then left clicked, the system editing routine is activated instead. However, since there's no procedure to process the input, it is simply discarded.
If the tree gadget has the TVS_EDITLABELS style set, all the editing work will be handled by the system, but requires validation before it updates the tree item:
Code: Select all
Procedure tgProc(hWnd, uMsg, wParam, lParam)
  Shared sysProc
  If uMsg = #WM_NOTIFY
    *lParam.NMHDR = lParam
    If *lParam\code = #TVN_ENDLABELEDIT
      ProcedureReturn #True
    EndIf
  EndIf
  ProcedureReturn CallWindowProc_(sysProc, hWnd, uMsg, wParam, lParam)
EndProcedure
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
window = OpenWindow(#PB_Any, 0, 0, 220, 220, "TreeGadget", wFlags)
tree = TreeGadget(#PB_Any, 10, 10, 200, 200)
SetWindowLongPtr_(GadgetID(tree), #GWL_STYLE, 
                  GetWindowLong_(GadgetID(tree), #GWL_STYLE) | #TVS_EDITLABELS)
sysProc = SetWindowLong_(WindowID(window), #GWL_WNDPROC, @tgProc())
For populate = 0 To 10
  AddGadgetItem (tree, -1, "main node " + Str(populate))
  AddGadgetItem (tree, -1, "first sub-level "  + Str(populate), 0, 1)
  AddGadgetItem (tree, -1, "second sub-level "  + Str(populate), 0, 2)
Next
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
