Page 1 of 2

Help ListIconGadget

Posted: Fri Jul 25, 2008 1:28 pm
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 


Posted: Fri Jul 25, 2008 2:14 pm
by srod
I think you'll have to do that manually -which is straight forward enough. :)

Posted: Fri Jul 25, 2008 2:48 pm
by Demivec
Checkboxes can only be in the first column.

You will need to move "System" to the first column.

Posted: Fri Jul 25, 2008 2:50 pm
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.

Posted: Fri Jul 25, 2008 3:13 pm
by Rascal

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

Can not search the second column ????? :?: :?: :?: :shock: :shock:

Posted: Fri Jul 25, 2008 3:34 pm
by srod
No.

Just search yourself with a simple loop.

Posted: Fri Jul 25, 2008 3:45 pm
by Rascal
500,000 loop cycles, too slow

Posted: Fri Jul 25, 2008 4:08 pm
by Demivec
Rascal wrote:500,000 loop cycles, too slow

make your list smaller, much faster

Posted: Fri Jul 25, 2008 4:18 pm
by PB
@Rascal: Stop posting in big red text, please. You don't need too.

Posted: Fri Jul 25, 2008 4:26 pm
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 



Posted: Fri Jul 25, 2008 4:39 pm
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.

Posted: Fri Jul 25, 2008 4:39 pm
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

Posted: Fri Jul 25, 2008 4:47 pm
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 

Posted: Fri Jul 25, 2008 4:56 pm
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.

Posted: Fri Jul 25, 2008 4:58 pm
by Demivec
[This space intentionally left blank]