TreeView Editing

Everything else that doesn't fall into one of the other PB categories.
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

TreeView Editing

Post by localmotion34 »

ok i have messed with this long enough without asking for help. ive looked at the two examples on how to make a Treeview editable, and setup the callback exactly as the authors did. when i click the button to start editing the treeview, the edit box appears but when i type in the edit, i am only allowed to type opne character:

Code: Select all



#WindowWidth  = 390
#WindowHeight = 350

Procedure Callback(Window.l, Message.l, wParam.l, lParam.l)
  result = #PB_ProcessPureBasicEvents 
  
  If Message = #WM_Notify 
    *lp.NMHDR = lParam
    
    
    Select *lp\code
      Case #TVN_BEGINLABELEDIT
        
      Case #TVN_ENDLABELEDIT
        *pvdi.NMTVDISPINFO = lParam
        If *pvdi\item\psztext <> #Null
          Text.s = PeekS(*pvdi\item\psztext)
          
          If Text = ""
            result = #False
          Else
            result = #True
          EndIf
          
        EndIf 
    EndSelect
  EndIf
  ProcedureReturn result
  
EndProcedure


If OpenWindow(0, 100, 200, #WindowWidth, #WindowHeight, #PB_Window_MinimizeGadget, "Edit Treeview")
  
  If CreateGadgetList(WindowID())
    TreeGadget(0,20,20,100,300)
    AddGadgetItem(0,-1,"Tree")
    SetWindowLong_(GadgetID(0),#GWL_STYLE,GetWindowLong_(GadgetID(0),#GWL_STYLE) | #TVS_EDITLABELS)
    ButtonGadget(1,200,100,50,20,"Edit Tree")
  EndIf
  SetWindowCallback(@Callback())
  
  
  
  Repeat
    EventID = WaitWindowEvent()
    
    If EventID = #PB_EventGadget
      
      Select EventGadgetID()
        Case 0
          
          
        Case 1
          currentitem=GadgetItemID(0, 0) 
          SendMessage_(GadgetID(0),#TVM_EDITLABEL,0,currentitem)
          
      EndSelect
      
    EndIf
    
  Until EventID = #PB_EventCloseWindow
  
EndIf

End 
can anyone help me out?

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

My best guess is that the EventGadgetID() is returning the ID of 1 everytime you press a key in the StringGadget used for editing. Changing the ButtonGadget to ID #2 seems to work fine.

Code: Select all

#WindowWidth  = 390 
#WindowHeight = 350 

Procedure Callback(Window.l, Message.l, wParam.l, lParam.l) 
  result = #PB_ProcessPureBasicEvents 
  
  If Message = #WM_Notify 
    *lp.NMHDR = lParam 
    
    
    Select *lp\code 
      Case #TVN_BEGINLABELEDIT 
        
      Case #TVN_ENDLABELEDIT 
        *pvdi.NMTVDISPINFO = lParam 
        If *pvdi\item\psztext <> #Null 
          Text.s = PeekS(*pvdi\item\psztext) 
          
          If Text = "" 
            result = #False 
          Else 
            result = #True 
          EndIf 
          
        EndIf 
    EndSelect 
  EndIf 
  ProcedureReturn result 
  
EndProcedure 


If OpenWindow(0, 100, 200, #WindowWidth, #WindowHeight, #PB_Window_MinimizeGadget, "Edit Treeview") 
  
  If CreateGadgetList(WindowID()) 
    TreeGadget(0,20,20,100,300) 
    AddGadgetItem(0,-1,"Tree") 
    SetWindowLong_(GadgetID(0),#GWL_STYLE,GetWindowLong_(GadgetID(0),#GWL_STYLE) | #TVS_EDITLABELS) 
    ButtonGadget(2,200,100,50,20,"Edit Tree") 
  EndIf 
  SetWindowCallback(@Callback()) 
  
  
  
  Repeat 
    EventID = WaitWindowEvent() 
    
    If EventID = #PB_EventGadget 
      
      Select EventGadgetID() 
        Case 0 
          
          
        Case 2 
          currentitem=GadgetItemID(0, 0) 
          SendMessage_(GadgetID(0),#TVM_EDITLABEL,0,currentitem) 
          
      EndSelect 
      
    EndIf 
    
  Until EventID = #PB_EventCloseWindow 
  
EndIf 

End 
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post by localmotion34 »

hmmm, that does work. maybe this is a possible bug in PB. Freak, Fred, can you guys check this out? i will fool around with different gadget numbers and see if the same problem occurs. my editable treegadget will have many many items, of which item numbers will overlap with gadget numbers 1,2,3,....50.

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

localmotion34 wrote:hmmm, that does work. maybe this is a possible bug in PB. Freak, Fred, can you guys check this out? i will fool around with different gadget numbers and see if the same problem occurs. my editable treegadget will have many many items, of which item numbers will overlap with gadget numbers 1,2,3,....50.
@localmotion
The right way of doing it is to start your first gadget # with 100.

If you look at win32 example programs on the internet (c/c++, vb, or whatever) they all start at 100.
The reason for that is that some win32 messages use low numbers (like the message that tells you over which menu title your mouse cursor is, for example...)

So if you want a working gui system just start with 100 and you are fine for years to come :wink:
Post Reply