edit ListGadgetItem

Just starting out? Need help? Post your questions and find answers here.
User avatar
gurj
Enthusiast
Enthusiast
Posts: 640
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

edit ListGadgetItem

Post by gurj »

edit ListGadgetItem

Tree-View Styles
Tree-view styles govern aspects of a tree-view control's appearance. You set the initial styles when you create the tree-view control. You can retrieve and change the styles after creating the tree-view control by using the GetWindowLong and SetWindowLong functions.
The user can directly edit the labels of items in a tree-view control that has the TVS_EDITLABELS style. The user begins editing by clicking the label of the item that has the focus. An application begins editing by using the TVM_EDITLABEL message. The tree-view control notifies the parent window when editing begins and when it is canceled or completed. When editing is completed, the parent window is responsible for updating the item's label, if appropriate.

List View Window Styles
The following window styles are specific to list view controls.
LVS_EDITLABELS
Allows item text to be edited in place. The parent window must process the LVN_ENDLABELEDIT notification message.

MMC_RESULT_VIEW_STYLE
The MMC_RESULT_VIEW_STYLE enumeration defines the Win32® list view style (LVS_*) flags that can be used to set the view style in the MMC result view pane. They can be used in the add and remove parameters of the IResultData::ModifyViewStyle method.

typedef enum _MMC_RESULT_VIEW_STYLE
{
MMC_SINGLESEL = 0x0001,
MMC_SHOWSELALWAYS = 0x0002,
MMC_NOSORTHEADER = 0x0003,

} MMC_RESULT_VIEW_STYLE;

why #TVS_EDITLABEL succeeded and #LV/BS_EDITLABEL failed:

Code: Select all

If OpenWindow(0, 0, 0, 355, 180, "edit ListGadgetItem", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 g0=TreeGadget(0, 10, 10, 160, 160)
 AddGadgetItem (0, -1, "Normal Item "+Str(a), 0, 0)
 AddGadgetItem (0, -1, "Node "+Str(a), 0, 0)
 AddGadgetItem(0, -1, "Sub-Item 1", 0, 1)
 AddGadgetItem(0, -1, "Sub-Item 2", 0, 1)
 AddGadgetItem(0, -1, "Sub-Item 3", 0, 1)
 AddGadgetItem(0, -1, "Sub-Item 4", 0, 1)
 AddGadgetItem(0, -1, "File "+Str(a), 0, 0)
 g1=ListViewGadget(1, 180, 10, 160, 160)
 For a = 0 To 6
  AddGadgetItem(1, -1, ""+a)
 Next
 ;TODO,this ok:
 SetWindowLong_(g0, #GWL_STYLE,GetWindowLong_(g0, #GWL_STYLE) |#TVS_EDITLABELS)
 ;TODO,this no:
 SetWindowLong_(g1, #GWL_STYLE,GetWindowLong_(g1, #GWL_STYLE) |#LVS_EDITLABELS);LongPtr_(g1, #GWL_EXSTYLE
;TODO,other,what can this GadgetItem() do? :
;  Returns the OS handle For the given item in a gadget. This is especially useful For use With the OS API. 
;  This function is currently only supported by TreeGadget() on Windows. It returns zero in other cases. 
id=GadgetItemID(0,2)
 Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Last edited by gurj on Tue Feb 19, 2019 7:22 am, edited 1 time in total.
my pb for chinese:
http://ataorj.ys168.com
User avatar
Josh
Addict
Addict
Posts: 1184
Joined: Sat Feb 13, 2010 3:45 pm

Re: edit ListGadgetItem

Post by Josh »

Code: Select all

g0=TreeGadget(0, 10, 10, 160, 160)
...
g1=ListViewGadget(1, 180, 10, 160, 160)
What is g0/g1?
Look at the help!
sorry for my bad english
uweb
User
User
Posts: 98
Joined: Wed Mar 15, 2006 9:40 am
Location: Germany

Re: edit ListGadgetItem

Post by uweb »

In my case englisch is not the best common language - but PureBasic.
This should help to keep play on:

Code: Select all

If OpenWindow(0, 0, 0, 355, 180, "edit ListGadgetItem", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 g0=42 : g1=2019
 TreeGadget(g0, 10, 10, 160, 160)
 AddGadgetItem(g0, -1, "Normal Item "+Str(a), 0, 0)
 AddGadgetItem(g0, -1, "Node "+Str(a), 0, 0)
 AddGadgetItem(g0, -1, "Sub-Item 1", 0, 1)
 AddGadgetItem(g0, -1, "Sub-Item 2", 0, 1)
 AddGadgetItem(g0, -1, "Sub-Item 3", 0, 1)
 AddGadgetItem(g0, -1, "Sub-Item 4", 0, 1)
 AddGadgetItem(g0, -1, "File "+Str(a), 0, 0)
 ListViewGadget(g1, 180, 10, 160, 160)
 For a = 8 To 14
  AddGadgetItem(g1, -1, ""+Str(a))
 Next
 ;TODO,this ok:
 SetWindowLong_(g0, #GWL_STYLE,GetWindowLong_(g0, #GWL_STYLE) |#TVS_EDITLABELS)
 ;TODO,this no:
 SetWindowLong_(g1, #GWL_STYLE,GetWindowLong_(g1, #GWL_STYLE) |#LVS_EDITLABELS);LongPtr_(g1, #GWL_EXSTYLE
;TODO,other,what can this GadgetItem() do? :
;  Returns the OS handle For the given item in a gadget. This is especially useful For use With the OS API.
;  This function is currently only supported by TreeGadget() on Windows. It returns zero in other cases.
id=GadgetItemID(g0,2)
 Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Please pardon my English, my native tongue is German.
User avatar
Josh
Addict
Addict
Posts: 1184
Joined: Sat Feb 13, 2010 3:45 pm

Re: edit ListGadgetItem

Post by Josh »

Sorry uweb. That's exactly the same nonsense. You are using a gadget number as a Windows handle.
sorry for my bad english
User avatar
gurj
Enthusiast
Enthusiast
Posts: 640
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: edit ListGadgetItem

Post by gurj »

sorry, updata to:
id=GadgetItemID(0,2)
my pb for chinese:
http://ataorj.ys168.com
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4100
Joined: Sun Apr 12, 2009 6:27 am

Re: edit ListGadgetItem

Post by RASHAD »

PB ListViewGadget() = MSDN List Box Control
You are messing between ListView and ListIcon
Suit yourself

- Edit TreeGadget()

Code: Select all

Global EditFlag,Act

If OpenWindow(0, 0, 0, 400, 320, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  TreeGadget(0, 10, 10, 185, 300,#PB_Tree_CheckBoxes)
    For a = 0 To 10
      AddGadgetItem (0, -1, "Normal Item "+Str(a), 0, 0)
      AddGadgetItem (0, -1, "Node "+Str(a), 0, 0)
      AddGadgetItem(0, -1, "Sub-Item 1", 0, 1)
      AddGadgetItem(0, -1, "Sub-Item 2", 0, 1)
      AddGadgetItem(0, -1, "Sub-Item 3", 0, 1)
      AddGadgetItem(0, -1, "Sub-Item 4", 0, 1)
      AddGadgetItem (0, -1, "File "+Str(a), 0, 0)
    Next
   
    TreeGadget(1, 205, 10,185, 300,#PB_Tree_CheckBoxes)
    For a = 0 To 10
      AddGadgetItem (1, -1, "Normal Item "+Str(a), 0, 0)
      AddGadgetItem (1, -1, "Node "+Str(a), 0, 0)
      AddGadgetItem(1, -1, "Sub-Item 1", 0, 1)
      AddGadgetItem(1, -1, "Sub-Item 2", 0, 1)
      AddGadgetItem(1, -1, "Sub-Item 3", 0, 1)
      AddGadgetItem(1, -1, "Sub-Item 4", 0, 1)
      AddGadgetItem (1, -1, "File "+Str(a), 0, 0)
    Next
   
 SetWindowLongPtr_(GadgetID(0),#GWL_STYLE, GetWindowLongPtr_(GadgetID(0),#GWL_STYLE) | #TVS_EDITLABELS)
   
Repeat
  Select WaitWindowEvent()
     
    Case #PB_Event_CloseWindow
      Quit = 1
     
    Case #WM_KEYDOWN
            If EditFlag = 1 And EventwParam() = 13
                SetGadgetItemText(0,Act,Text$)
                EditFlag = 0
            EndIf   
     
    Case #WM_CHAR
            If EditFlag = 1
                 If EventwParam() > 32 And EventwParam() < 126
                     Text$ = Text$+ Chr(EventwParam())
                 EndIf
            EndIf
                       
          Case #PB_Event_Gadget
            Select EventGadget()
              Case 0
                  Select EventType()                                                     
                      Case #PB_EventType_LeftDoubleClick
                           Act = GetGadgetState(0)
                           EditFlag = 1
                           Text$ = ""
                           SendMessage_(GadgetID(0),#TVM_EDITLABEL,0, GadgetItemID(0, Act))
              EndSelect
      EndSelect
  EndSelect
Until Quit = 1
EndIf
- Edit ListView()

Code: Select all

LoadFont(0,"Georgia",12)
OpenWindow(0, 0, 0, 400, 300, "LBN_SELCHANGE", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

LV = ListViewGadget(0,10,10,300,200)

SetGadgetFont(0,FontID(0))

For i = 1 To 100
  AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview")
Next

StringGadget(100,0,0,0,0,"")

AddKeyboardShortcut(0,#PB_Shortcut_Return,10)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1
      
    Case #PB_Event_Menu
      Select EventMenu()
        Case 10
          If GetActiveGadget() = 100
            text$ = GetGadgetText(100)
            SetActiveGadget(0)
            ResizeGadget(100,0,0,0,0)
            SetGadgetText(100,"")
            SetGadgetItemText(0,item,text$)
            text$ = ""
          EndIf
      EndSelect
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Select EventType()
            Case #PB_EventType_LeftDoubleClick
              item = GetGadgetState(0)
              SendMessage_(LV,#LB_GETITEMRECT,item,r.RECT)
              ResizeGadget(100,r\left+GadgetX(0)+2,r\top+GadgetY(0)+2,r\right-r\left,r\bottom-r\top)
              SetActiveGadget(100)
          EndSelect
      EndSelect                   

  EndSelect
Until Quit = 1
Egypt my love
User avatar
gurj
Enthusiast
Enthusiast
Posts: 640
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: edit ListGadgetItem

Post by gurj »

Edit TreeGadget(), this ok:

Code: Select all

If OpenWindow(0, 0, 0, 355, 180, "edit ListGadgetItem", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 g0=TreeGadget(0, 10, 10, 160, 160)
 AddGadgetItem (0, -1, "Normal Item "+Str(a), 0, 0)
 AddGadgetItem (0, -1, "Node "+Str(a), 0, 0)
 AddGadgetItem(0, -1, "Sub-Item 1", 0, 1)
 AddGadgetItem(0, -1, "Sub-Item 2", 0, 1)
 AddGadgetItem(0, -1, "Sub-Item 3", 0, 1)
 AddGadgetItem(0, -1, "Sub-Item 4", 0, 1)
 AddGadgetItem(0, -1, "File "+Str(a), 0, 0)
 
 ;TODO,this ok:
 SetWindowLong_(g0, #GWL_STYLE,GetWindowLong_(g0, #GWL_STYLE) |#TVS_EDITLABELS)
 s.s=Space(1024)
 Repeat
  ev=WaitWindowEvent()
  re:
  Select ev
    ;#wm_systimer=280
   Case 280:gf=GetFocus_():gs=GetGadgetState(0)
    
    Repeat
     ev=WaitWindowEvent()
     If GetFocus_()=gf
      GetWindowText_(gf,@s,1024)
      ;SendMessage_(g0,#TVN_ENDLABELEDIT,0, 0)
     Else
      SetGadgetItemText(0,gs,s)
      
      Goto re
     EndIf
    ForEver
   Case #PB_Event_CloseWindow:Break
 EndSelect:ForEver
 End
EndIf
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 640
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: edit ListGadgetItem

Post by gurj »

updata previous post.
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 640
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: edit ListGadgetItem

Post by gurj »

Edit ListView(),this ok:

Code: Select all


;LoadFont(0,"Georgia",12)
OpenWindow(0, 0, 0, 400, 300, "LBN_SELCHANGE", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

LV = ListViewGadget(0,10,10,300,200)
; Class$ = Space(1024)
; GetClassName_(lv,@Class$,1024)
; Debug Class$
;SetGadgetFont(0,FontID(0))

For i = 1 To 50
 AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview")
Next

sg=StringGadget(100,0,0,0,0,"",#PB_String_BorderLess)
;SetGadgetColor(100,#PB_Gadget_BackColor,#Yellow)
SetParent_(sg,lv)
ScreenToClient_ (LV, @r.RECT)
Repeat
 Select WaitWindowEvent()
  Case #PB_Event_Gadget
   Select EventGadget()
    Case 0
     If EventType()=#PB_EventType_LeftDoubleClick
      item = GetGadgetState(0)
      SendMessage_(LV,#LB_GETITEMRECT,item,r)
      ResizeGadget(100,r\left,r\top,r\right-r\left,r\bottom-r\top)
      SetActiveGadget(100)
      SetGadgetText(100,GetGadgetItemText(0,item))
      SendMessage_(sg,#EM_SETSEL,0,-1)
     EndIf
    Case 100
     If EventType()=#PB_EventType_LostFocus
      SetGadgetItemText(0,item,GetGadgetText(100))
     EndIf
   EndSelect
  Case #PB_Event_CloseWindow:Break
EndSelect:ForEver
End
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 640
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: edit ListGadgetItem

Post by gurj »

updated previous post.
my pb for chinese:
http://ataorj.ys168.com
Post Reply