CityGame Posted Friday at 03:20 PM Posted Friday at 03:20 PM (edited) Hello everyone, I'm having trouble with the _GUICtrlComboBox_AddDir function. It does not add to the combox box any files with the I (contents not indexed) file attribute and no other attributes included in $DDL_READWRITE (A archive or R read only, I think), and there is no constant to include (or exclude) them on the Help about this function. There doesn't seem to exist an equivalent attribute on the Microsoft site (https://learn.microsoft.com/en-us/cpp/mfc/reference/ccombobox-class)... Do someone know the value to include files with that attribute? My problem is that the drive has that attribute enabled on all files and directories, and so the function does not add any files to the combo box unless they have other attributes included in $DDL_READWRITE (A archive or R read only), so I'm getting unexpected lists with missing files. Is there any constant or syntax for this case that I may have missed? This problem can be found using the example code on the help file and running it on a directory with files with the I attribute on and no attributes A or R. Thank you very much Edited Friday at 03:21 PM by CityGame
Solution Nine Posted Friday at 05:37 PM Solution Posted Friday at 05:37 PM The value of the attribute FILE_ATTRIBUTE_NOT_CONTENT_INDEXED is 0x2000 (8192). But it does not work with this function. You will need to add the files manually in the combo. #include <GUIConstants.au3> #include <File.au3> Example() Func Example() GUICreate("ComboBox Example", 400, 296) Local $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296) Local $aList = _FileListToArray(@ScriptDir, "*.txt", $FLTA_FILES) For $i = 1 To $aList[0] If BitAND(_WinAPI_GetFileAttributes($aList[$i]), $FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) Then GUICtrlSetData($idCombo, $aList[$i]) Next GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example CityGame 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
CityGame Posted 10 hours ago Author Posted 10 hours ago Hello, and thank you again for helping me I have changed my code to use the _FileListToArray function and then adding each file to the combobox in a loop, as you showed on your example. My purpose wasn't to add files with the "I" attribute enabled (sorry if you thought that from my original post) but to add any files regardless of the "I" attribute (just as it happens with compressed files, attribute "C"). The _GUICtrlComboBox_AddDir function with default attributes parameter does not add files with the "I" attribute enabled and no attributes "A" or "R" (probably a bug? of the Windows function that seems to be called on the _GUICtrlComboBox_AddDir code on GUIComboBox.au3... I doesn't seem a problem of the function itself or AutoIt). But the _FileListToArray works perfectly, and if needed, files could still be filtered by their attributes as you showed on your example, so it's a perfect replace. The result code that now works as expected (just added an error macro check to prevent accessing the files array if there are no files, or the path doesn't exist...) is: _GUICtrlComboBox_BeginUpdate($idCombo) _GUICtrlComboBox_ResetContent($idCombo) $aFiles = _FileListToArray($sPath, "*.txt", $FLTA_FILES) If (Not @error) Then For $iFilesCurrent = 1 To $aFiles[0] _GUICtrlComboBox_AddString($idCombo, $aFiles[$iCHDFilesCurrent]) Next GUICtrlComboBox_EndUpdate($idCombo) EndIf If (_GUICtrlComboBox_GetCount($idCombo) < 1) Then _GUICtrlComboBox_SetCurSel($idCombo, -1) MsgBox(64, "Result", "No files found.") Else _GUICtrlComboBox_SetCurSel($idCombo, 0) MsgBox(64, "Result", "File(s) found.") EndIf Thank you
Nine Posted 7 hours ago Posted 7 hours ago Glad it works out. One comment, the Begin update is outside the If statement while the End update is inside. I think this is a mistake you should amend. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now