Page 1 of 1

ListIcon - Adding/deleting items and redrawing.

Posted: Mon Jun 10, 2013 10:19 pm
by jassing
I have a listicon that gets some log info; but I discard anything over 8 hours old. Along with the deletes, I add new items to the end.

So the pseudo code is:

while GetGadgetItem(#lstLog,0,0) < Current-Cut-Off-Date
RemoveGadgetItem(#lstLog,0)
wend
AddGadgetItem(#lstLog,-1,"New item")

My problem is that the list icon flashes during both adds and deletes.

Currently the log shows the "last item" (auto-scrolling to end) - but when deleting items, the gadget flashes. Especially the grid appears and disappears.

Similarly, if the list isn't in "auto scroll" mode ("looking at the middle" the gadgets items appear to scroll while deleting items from the top -- I would like the user to be able to remain looking at what they are, even when items are being deleted (that are not in view).

So:
1) Is there a way to keep a currently selected gadget item "in view" so it doesn't scroll due to deleting items from the head of the list?
2) Is there a way to stop the gadget from being redrawn? I had hte code below, but it doesn't seem to be helping me any...

Code: Select all

Procedure DisableGadgetRedraw(nGadget, bDisabled.b)
	If IsGadget(nGadget)
		If bDisabled
			SendMessage_(GadgetID(nGadget),#WM_SETREDRAW,#False,0)
		Else
			SendMessage_(GadgetID(nGadget),#WM_SETREDRAW,#True,0)
			RedrawWindow_(GadgetID(nGadget),#Null,#Null,#RDW_INVALIDATE)
		EndIf 
	EndIf
EndProcedure

Re: ListIcon - Adding/deleting items and redrawing.

Posted: Tue Jun 11, 2013 11:10 am
by RASHAD
It may help you

Code: Select all

  LoadFont(0,"Arial",12)
  If OpenWindow(0, 0, 0, 640, 340, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
      ListIconGadget(0,  10,  10, 620, 280, "Column 0", 120,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
      SetGadgetFont(0,FontID(0))
        For x = 1 To 6      
          AddGadgetColumn(0, x, "Column " + Str(x), 120)
        Next
        For x = 0 To 20
            AddGadgetItem(0, -1, "Row : "+Str(x)+Chr(10)+"Item 1"+Chr(10)+"Item 2"+Chr(10)+"Item 3"+Chr(10)+"Item 4"+Chr(10)+"Item 5")
        Next
        
        ButtonGadget(1,10,300,60,24,"Scroll")
        
    EndIf
Repeat
  Select WaitWindowEvent()
  
        Case #PB_Event_CloseWindow
              Quit = 1
               
        Case #PB_Event_Gadget
          Select EventGadget()
           Case 1
                  Result = GetGadgetState(0)
                  EnableScrollBar_(GadgetID(0),#SB_BOTH	,#ESB_DISABLE_BOTH)
                  For x = 21 To 500
                      AddGadgetItem(0, -1, "Row : "+Str(x)+Chr(10)+"Item 1"+Chr(10)+"Item 2"+Chr(10)+"Item 3"+Chr(10)+"Item 4"+Chr(10)+"Item 5")
                  Next 
                  EnableScrollBar_(GadgetID(0),#SB_BOTH	,#ESB_ENABLE_BOTH	)
                  SetGadgetState(0,Result) 
                  SetActiveGadget(0)             
         
          EndSelect 

  EndSelect 
Until Quit = 1


Re: ListIcon - Adding/deleting items and redrawing.

Posted: Tue Jun 11, 2013 3:25 pm
by jassing
Thank you Rashad -- I will try that this afternoon & let you know
Cheers
-j