Page 1 of 1

ExplorerTreeGadget Refresh Listing Question

Posted: Tue Nov 21, 2006 8:28 am
by tss
Hi,

Is there a way to force the ExplorerTreeGadget to refresh to display an updated file listing?

I've got a program which allows the user to select a file, then it creates a backup of the file in the same directory. Can the explorertreegadget be forced to refresh so that the new file can be seen?

Thanks in advance.
Paul

Posted: Tue Nov 21, 2006 9:07 am
by Shardik
Simply do a SetGadgetText(GadgetID, GetGadgetText(GadgetID) + "*.*") to refresh the ExplorerTreeGadget as in the example below:

Code: Select all

OpenWindow(1, 0, 0, 290, 370, "ExplorerTreeGadget Refresh", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) 

CreateGadgetList(WindowID(1)) 
ExplorerTreeGadget(1, 10, 10, 270, 300, "C:\") 
ButtonGadget(2, 45, 320, 200, 40, "Create backup of Boot.ini and refresh ExplorerTree", #PB_Button_MultiLine | #PB_Button_Default) 

Repeat 
  WindowEventID = WaitWindowEvent() 

  If WindowEventID = #PB_Event_Gadget And EventGadget() = 2 
    If CopyFile("C:\Boot.Ini", "C:\Boot.Bak") = #False
      MessageRequester("Error", "File copy of Boot.Ini to Boot.Bak failed!")
      End
    EndIf

    SetGadgetText(1, GetGadgetText(1) + "*.*") 
    DisableGadget(2, #True) 
  EndIf 
Until WindowEventID = #PB_Event_CloseWindow

Posted: Wed Nov 22, 2006 2:46 am
by tss
Thanks. That forces a refresh, although it is limiting the files to be only those that match the SetText+"*.*" criteria.

But changing it to do a SetGadgetText(#GadgetID, "*.*"), it is refreshing the listing, although it is changing back to the original directory location.

But it is a workable solution.

Thanks.