Jump to content

Display the contents of a directory in a frame


FlavioMacedo

Recommended Posts

​Hi

 

I use a uniListbox for that with the following functions/code :

 

 

function FindFiles(searchstr: string; list: TStrings): boolean;
 var
   hn: THandle;
   fd: WIN32_FIND_DATA;
 begin
   Result := False;
   hn := FindFirstFile(PChar(searchstr),fd);
   if hn <> INVALID_HANDLE_VALUE then begin
     Result := True;
     list.Add(StrPas(fd.cFileName));
     while FindNextFile(hn,fd) = True do
       list.Add(StrPas(fd.cFileName));
   end;
   Windows.FindClose(hn);
 end;

 

 

On the form activate the uniLisbox is filled with the names of pdf files

procedure TFormExplorAccreditation.UniFormActivate(Sender: TObject);
begin
  UniListBox_Files.Items.Clear;
  FindFiles(uniServerModule.StartPath+'\files\pdf\'+'*.pdf',UniListBox_Files.Items);
end;

When the user double clicks on a file name you can use/do something  with the file, in this
​case a var will be used and gets the selected file name

     sSenderFILE  := UniListBox_files.Items[uniListBox_Files.ItemIndex];

for extract the directory you can use ExtractFilePath function, but in you case you already know
​the directory name because you need the show the content of a given directory :)

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...