Hidden Files in ExplorerListGadget
Hidden Files in ExplorerListGadget
Back in 2007 apparently ExplorerListGadget, or at least the Linux version, wouldn't display hidden files. Now it does and I can't find a way to turn that off. Is it possible?
Thanks,
Bill
Thanks,
Bill
PB 5.72 (32-bit) on Win 10.
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Hidden Files in ExplorerListGadget
I think that maybe an OS setting - If the OS is set to hide the files, Explorer will not display them. Seems logical that would be the case cross-platform, though perhaps Apple have a different way of thinking.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Hidden Files in ExplorerListGadget
IdeasVacuum,
Thanks, but I have file managers (ie. Total Commander) that can be switched either way. If it's an OS setting, mine must be set to show hidden files.
What I'm trying to do is NOT show hidden files in the ExplorerListGadget. In this case, I have a configuration (.cfg) file that I don't want listed. I can set its attribute to hidden, but ExplorerListGadget shows it anyway.
Bill
Thanks, but I have file managers (ie. Total Commander) that can be switched either way. If it's an OS setting, mine must be set to show hidden files.
What I'm trying to do is NOT show hidden files in the ExplorerListGadget. In this case, I have a configuration (.cfg) file that I don't want listed. I can set its attribute to hidden, but ExplorerListGadget shows it anyway.
Bill
PB 5.72 (32-bit) on Win 10.
Re: Hidden Files in ExplorerListGadget
If you know all the file-types you wish to use then you could use a pattern:
Manual wrote:Directory$ The initial displayed directory, it can include one or multiple patterns, like "C:\*.pb;*.pbi". If no pattern is included, the directory must end with a '\'. Including no directory will display the root containing the drives. Including no pattern defaults to '*.*'. So a Directory$ of "" will display the root and set '*.*' as pattern.
DE AA EB
Re: Hidden Files in ExplorerListGadget
The easiest way to suppress the listing of hidden files in Windows is to simply catch the event #PB_EventType_Change, check each file in a loop for the hidden attribute and remove the entry from the gadget list:
Code: Select all
OpenWindow(0, 0, 0, 492, 400, "ExplorerList", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ExplorerListGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20, "C:\Windows\")
SetGadgetItemAttribute(0, 0, #PB_Explorer_ColumnWidth, 150, 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0 And EventType() = #PB_EventType_Change
FilePath$ = GetGadgetText(0)
For i = CountGadgetItems(0) - 1 To 0 Step -1
Filename$ = GetGadgetItemText(0, i, 0)
If GetFileAttributes(FilePath$ + Filename$) & #PB_FileSystem_Hidden
RemoveGadgetItem(0, i)
EndIf
Next i
EndIf
EndSelect
ForEver
Re: Hidden Files in ExplorerListGadget
Ah, Shardik, you crafty devil you...
Since RemoveGadgetItem() isn't listed in the help as applying to the ExplorerListGadget, I never gave it a thought.
But it works! You can even see it work as the hidden files appear, then disappear in the blink of an eye.
Good enough. Thank you ever so much!
Bill
PS. Seems like keeping hidden and system files from application users would be a good thing. Seems like there should be a #PB_Explorer_NoHiddenFiles and #PB_Explorer_NoSystemFiles flags
Since RemoveGadgetItem() isn't listed in the help as applying to the ExplorerListGadget, I never gave it a thought.
But it works! You can even see it work as the hidden files appear, then disappear in the blink of an eye.
Good enough. Thank you ever so much!
Bill
PS. Seems like keeping hidden and system files from application users would be a good thing. Seems like there should be a #PB_Explorer_NoHiddenFiles and #PB_Explorer_NoSystemFiles flags
PB 5.72 (32-bit) on Win 10.
Re: Hidden Files in ExplorerListGadget
> RemoveGadgetItem() isn't listed in the help as applying to the ExplorerListGadget
That means it's unofficial, so use it at your own risk; as it may not work in future.
That means it's unofficial, so use it at your own risk; as it may not work in future.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: Hidden Files in ExplorerListGadget
I would say that it is fairly safe to use RemoveGadgetItem() for the ExplorerListGadget because according to freak's blog entry the underlying control for the ExplorerListGadget in Windows is the same as for the ListIconGadget: a WC_LISTVIEW.PB wrote:> RemoveGadgetItem() isn't listed in the help as applying to the ExplorerListGadget
That means it's unofficial, so use it at your own risk; as it may not work in future.
Re: Hidden Files in ExplorerListGadget
Modified version for Shardik approach
Windows only
Windows only
Code: Select all
Global oldCallback
Procedure ExplorerCallback(hwnd, msg, wParam, lParam)
result = CallWindowProc_(oldCallback, hwnd, msg, wParam, lParam)
Select msg
Case #WM_LBUTTONDBLCLK
For x = CountGadgetItems(2) To 1 Step -1
If (GetFileAttributes(GetGadgetText(2) + GetGadgetItemText(2,x)) & #PB_FileSystem_Hidden) And FindString(GetGadgetItemText(2,x,0),"\") <> 3
RemoveGadgetItem(2,x)
EndIf
Next
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 700, 540,"Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ExplorerListGadget(2, 10, 10, 680, 520, "*.*", #PB_Explorer_GridLines|#PB_Explorer_FullRowSelect)
SetGadgetItemAttribute(2, -1, #PB_Explorer_ColumnWidth , 200 , 0)
RemoveGadgetColumn(2,3)
AddGadgetColumn(2, 3, #PB_Explorer_Attributes , 120)
SetGadgetItemText(2,-1,"Attributes",3)
oldCallback = SetWindowLong_(GadgetID(2), #GWL_WNDPROC, @ExplorerCallback())
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
End
Egypt my love
Re: Hidden Files in ExplorerListGadget
Thanks, Rashad, this goes into my snippets folder, too.
PB, I know, undocumented is always a risk. But Sardik's comment is persuasive. Perhaps the PB crew will replace RemoveGadgetItem() with a couple of useful flags for ExplorerListGadget() that will accomplish the same thing.
Thanks to all who commented.
Bill
PB, I know, undocumented is always a risk. But Sardik's comment is persuasive. Perhaps the PB crew will replace RemoveGadgetItem() with a couple of useful flags for ExplorerListGadget() that will accomplish the same thing.
Thanks to all who commented.
Bill
PB 5.72 (32-bit) on Win 10.
Re: Hidden Files in ExplorerListGadget
Nice tips here! A clever and surprisingly-simple way to hide Hidden files on (Windows) ExplorerListGadgets.
Thanks Shardik and Rashad!
Thanks Shardik and Rashad!
Re: Hidden Files in ExplorerListGadget
Since PB 5.30 it has actually become very easy in Linux and MacOS X to display or suppress hidden files in the ExplorerListGadget with the new flag #PB_Explorer_HiddenFile:
An example (tested successfully with PB 5.31 on Kubuntu 14.04 x64 with KDE and MacOS X Snow Leopard):PureBasic [url=http://www.purebasic.com/news69.php][color=#0040FF]news[/color][/url] for 5.30 wrote:Added: #PB_Explorer_HiddenFiles to show hidden files in the explorer gadgets
Code: Select all
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
MessageRequester("Info", "The flag #PB_Explorer_HiddenFiles is not " +
"supported in Windows!", #MB_ICONINFORMATION)
CompilerElse
If CreateFile(0, GetTemporaryDirectory() + ".TestFile")
OpenWindow(0, 100, 100, 400, 300,
"ExplorerListGadget without hidden files (default)")
ExplorerListGadget(0, 10, 10, 380, 280, GetTemporaryDirectory(),
#PB_Explorer_NoFolders)
OpenWindow(1, 520, 100, 400, 300, "ExplorerListGadget with hidden files")
ExplorerListGadget(1, 10, 10, 380, 280, GetTemporaryDirectory(),
#PB_Explorer_NoFolders | #PB_Explorer_HiddenFiles)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
DeleteFile(GetTemporaryDirectory() + ".TestFile")
EndIf
CompilerEndIf
Re: Hidden Files in ExplorerListGadget
All things come to those who wait ...
Thanks, Shardik, missed that one.
Bill

Thanks, Shardik, missed that one.
Bill
PB 5.72 (32-bit) on Win 10.