Radsam Posted January 5, 2005 Share Posted January 5, 2005 Hi I need to use a List control to display all files in a folder so that later, when a user highlights an item and clicks a button control, that particular file will load. I know this is similar to using the FileOpenDialog, but that is not what I want to do. Any help is appreciated. Here is what I go so far. It will list all zip files in a folder but then empty itself out. #Include <GUIConstants.au3> $search = FileChangeDir("C:\somefolder") $search = FileFindFirstFile("*.zip") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf GuiCreate("Test", 600, 600,-1, -1) $list = GuiCtrlCreateList("", -1, -1, 600,600) GUICtrlSetFont (-1,20,400,0,"Arial Bold") GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit $file = FileFindNextFile($search) GUICtrlSetData($list, $file) WEnd FileClose($search) Thanks, Steve Link to comment Share on other sites More sharing options...
Radsam Posted January 5, 2005 Author Share Posted January 5, 2005 Hi all, I got it working. Here is the code. #include <GUIConstants.au3> #include <_FileSearch.au3> ;search $path = "C:\somefolder\" $alpha = _FileSearch($path,0,"",1) ;GUI $guiwidth = @DesktopWidth/2 $guiheight = @DesktopHeight/2 $gui = GUICreate("list files",$guiwidth,$guiheight,-1,-1,$WS_SIZEBOX+$WS_MINIMIZEBOX+$WS_MAXIMIZEBOX) GuiSetState(@SW_SHOW) $tv = GuiCtrlCreateList("",-1, -1, $guiwidth, $guiheight-20) For $i = 1 to $alpha[0] $alpha[$i] = StringReplace($alpha[$i], $path, "") GuiCtrlSetData($tv,$alpha[$i]) Next While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd L8tr, Steve Link to comment Share on other sites More sharing options...
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