Help ListIconGadget

Just starting out? Need help? Post your questions and find answers here.
Rascal
User
User
Posts: 30
Joined: Mon Sep 17, 2007 11:06 pm

Help ListIconGadget

Post by Rascal »

Can't check to "System" Column



Should how to do


Code: Select all


Enumeration 
  #Window_0 
  #Button_0
  #ListIcon_0 
EndEnumeration 

Structure LVFINDINFO
  Flags.l
  Psz.s
  Lparam.l
  Ptx.l
  Pty.l
  VkDirection.l
EndStructure

Procedure.l GetIndex(Gadget.l,Caption.s)
pItem.LVFINDINFO
ZeroMemory_(@pItem,SizeOf(LVFINDINFO))
hWnd.l = GadgetID(Gadget)
If hWnd = #Null
   ProcedureReturn -1
EndIf
pItem\psz=Caption
ProcedureReturn SendMessage_(hWnd,#LVM_FINDITEMA,-1,@pItem\Flags)
EndProcedure 

If OpenWindow(#Window_0,274,163,540,260,"List",#PB_Window_SystemMenu) 
  If CreateGadgetList(WindowID(#Window_0)) 
     ButtonGadget(#Button_0,005,233,100,025,"Del",#PB_Button_Default)
     ListIconGadget(#ListIcon_0,000,000,540,230,"Address",258,#PB_ListIcon_CheckBoxes|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
     AddGadgetColumn(#ListIcon_0,001,"System",258)
  EndIf
  
  Index.l = 500000 ; Fix
  
  For i = 1 To Index
     Buf$ + "255.255.255.255" + Chr(10)
     Buf$ + "Windows 2003"    + Chr(10)
     AddGadgetItem(#ListIcon_0,-1,Buf$)
  Next i 
  
  Buf$ = #NULL$
  Buf$ + "127.000.000.001" + Chr(10)
  Buf$ + "Windows Xp"    + Chr(10)
  AddGadgetItem(#ListIcon_0,Random(Index),Buf$)
  
  Repeat 
    EventID  = WaitWindowEvent() 
      Select EventID 
         Case #PB_Event_Gadget 
            Select EventGadget() 
               Case #Button_0 
                 Debug GetIndex(#ListIcon_0,"127.000.000.001")
                 Debug GetIndex(#ListIcon_0,"Windows Xp") ;Can't check to "System" Column
            EndSelect 
      EndSelect 
  Until EventID = #PB_Event_CloseWindow 
EndIf 

srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I think you'll have to do that manually -which is straight forward enough. :)
I may look like a mule, but I'm not a complete ass.
User avatar
Demivec
Addict
Addict
Posts: 4280
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

Checkboxes can only be in the first column.

You will need to move "System" to the first column.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I don't think that's what he meant - though admitedly he worded it badly! :)

He's on about using the LVM_FINDITEM message to search on the second column -which I do not think is possible.
I may look like a mule, but I'm not a complete ass.
Rascal
User
User
Posts: 30
Joined: Mon Sep 17, 2007 11:06 pm

Post by Rascal »


to search on the second column -which I do not think is possible. ?????

Can not search the second column ????? :?: :?: :?: :shock: :shock:
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

No.

Just search yourself with a simple loop.
I may look like a mule, but I'm not a complete ass.
Rascal
User
User
Posts: 30
Joined: Mon Sep 17, 2007 11:06 pm

Post by Rascal »

500,000 loop cycles, too slow
User avatar
Demivec
Addict
Addict
Posts: 4280
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

Rascal wrote:500,000 loop cycles, too slow

make your list smaller, much faster
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

@Rascal: Stop posting in big red text, please. You don't need too.
Rascal
User
User
Posts: 30
Joined: Mon Sep 17, 2007 11:06 pm

Post by Rascal »

Code: Select all



Enumeration 
  #Window_0 
  #Button_0
  #Button_1
  #ListIcon_0 
EndEnumeration 

Structure LVFINDINFO
  Flags.l
  Psz.s
  Lparam.l
  Pt.POINT
  VkDirection.l
EndStructure

Procedure.l GetIndex(Gadget.l,Caption.s)
pItem.LVFINDINFO
ZeroMemory_(@pItem,SizeOf(LVFINDINFO))
hWnd.l = GadgetID(Gadget)
If hWnd = #Null
   ProcedureReturn -1
EndIf
pItem\psz=Caption
ProcedureReturn SendMessage_(hWnd,#LVM_FINDITEM,-1,@pItem\Flags)
EndProcedure 

If OpenWindow(#Window_0,274,163,540,260,"List",#PB_Window_SystemMenu) 
  If CreateGadgetList(WindowID(#Window_0)) 
     ButtonGadget(#Button_0,005,233,100,025,"API",#PB_Button_Default)
     ButtonGadget(#Button_1,110,233,100,025,"Del",#PB_Button_Default)
     ListIconGadget(#ListIcon_0,000,000,540,230,"Address",258,#PB_ListIcon_CheckBoxes|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
     AddGadgetColumn(#ListIcon_0,001,"System",258)
  EndIf
  
  Index.l = 50000 ; The code is to test the speed, 50 million necessary
  
  For i = 1 To Index
     Buf$ + "255.255.255.255" + Chr(10)
     Buf$ + "Windows 2003"    + Chr(10)
     AddGadgetItem(#ListIcon_0,-1,Buf$)
  Next i 
  
  Buf$ = #NULL$
  Buf$ + "127.000.000.001" + Chr(10)
  Buf$ + "Windows Xp"      + Chr(10)
  AddGadgetItem(#ListIcon_0,Random(Index),Buf$)
  
  Repeat 
    EventID  = WaitWindowEvent() 
      Select EventID 
         Case #PB_Event_Gadget 
            Select EventGadget() 
               Case #Button_0 
                 Debug GetIndex(#ListIcon_0,"127.000.000.001")
               Case #Button_1
                 
                 ;Speed optimization
                 For i = 0 To CountGadgetItems(#ListIcon_0)
                  If GetGadgetItemText(#ListIcon_0,i,1) = "Windows Xp"
                     n.l = i
                     Break
                  EndIf
                 Next i
                 Debug n
                 
                 
            EndSelect 
      EndSelect 
  Until EventID = #PB_Event_CloseWindow 
EndIf 


User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

As long as he's using big, red letter and doesn't at least try to formulate a proper question I'd say screw this little prick.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Demivec
Addict
Addict
Posts: 4280
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

You are constructing the list entries incorrectly.

Code: Select all

  For i = 1 To Index
    Buf$ + "255.255.255.255" + Chr(10) ; <== fix, this goes outside the loop 
    Buf$ + "Windows 2003"    + Chr(10) ; <== fix, this goes outside the loop
    AddGadgetItem(#ListIcon_0,-1,Buf$)
  Next i
Rascal
User
User
Posts: 30
Joined: Mon Sep 17, 2007 11:06 pm

Post by Rascal »

Code: Select all


Enumeration 
  #Window_0 
  #Button_0
  #Button_1
  #ListIcon_0 
EndEnumeration 

Structure LVFINDINFO
  Flags.l
  Psz.s
  Lparam.l
  Pt.POINT
  VkDirection.l
EndStructure

Procedure.l GetIndex(Gadget.l,Caption.s)
pItem.LVFINDINFO
ZeroMemory_(@pItem,SizeOf(LVFINDINFO))
hWnd.l = GadgetID(Gadget)
If hWnd = #Null
   ProcedureReturn -1
EndIf
pItem\psz=Caption
ProcedureReturn SendMessage_(hWnd,#LVM_FINDITEM,-1,@pItem\Flags)
EndProcedure 

If OpenWindow(#Window_0,274,163,540,260,"List",#PB_Window_SystemMenu) 
  If CreateGadgetList(WindowID(#Window_0)) 
     ButtonGadget(#Button_0,005,233,100,025,"API",#PB_Button_Default)
     ButtonGadget(#Button_1,110,233,100,025,"Del",#PB_Button_Default)
     ListIconGadget(#ListIcon_0,000,000,540,230,"Address",258,#PB_ListIcon_CheckBoxes|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
     AddGadgetColumn(#ListIcon_0,001,"System",258)
  EndIf
  
  Index.l = 50 ;The code is to test the speed, 50 million necessary 
  
  For i = 1 To Index
     Buf$ = #NULL$
     Buf$ + "255.255.255.255" + Chr(10)
     Buf$ + "Windows 2003"    + Chr(10)
     AddGadgetItem(#ListIcon_0,-1,Buf$)
  Next i 
  
  Buf$ = #NULL$
  Buf$ + "127.000.000.001" + Chr(10)
  Buf$ + "Windows Xp"      + Chr(10)
  AddGadgetItem(#ListIcon_0,Random(Index),Buf$)
  
  Repeat 
    EventID  = WaitWindowEvent() 
      Select EventID 
         Case #PB_Event_Gadget 
            Select EventGadget() 
               Case #Button_0 
                 Debug GetIndex(#ListIcon_0,"127.000.000.001")

               Case #Button_1
                 
                 ;Speed optimization 
                 For i = 0 To CountGadgetItems(#ListIcon_0)
                  If GetGadgetItemText(#ListIcon_0,i,1) = "Windows Xp"
                     n.l = i
                     Break
                  EndIf
                 Next i
                 
                 Debug n
                 
                 
            EndSelect 
      EndSelect 
  Until EventID = #PB_Event_CloseWindow 
EndIf 
User avatar
Demivec
Addict
Addict
Posts: 4280
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

Code: Select all

Index.l = 50000 ; The code is to test the speed, 50 million necessary 
Why do you need 50 million? Is it related to this quote?
It is safe to estimate that as many as 50 million people use the Internet on a regular basis.
User avatar
Demivec
Addict
Addict
Posts: 4280
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

[This space intentionally left blank]
Post Reply