Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi open file with standard windows GUI window

I want to be able to open files in Delphi with a Windows GUI where you can scroll through the folders etc. I have already done this with Matlab with a single function that (after selecting the file) returns a string of the path. You could event specify which extension the be shown. Is this kind of function available in delphi and how should I use it.

like image 404
Jort Avatar asked Mar 23 '26 20:03

Jort


1 Answers

you can use the TOpenDialog component which is part of the Dialogs unit. you can create in runtime or drop this component from the Dialogs palette.

if you drop the component to your form you can use in this way

 OpenDialog1.Filter := 'Only Text files (*.txt)|*.txt';
 if OpenDialog1.Execute then
  //do you stuff here

or if you create the component in runtime

Var
  OpenDialog1 : TOpenDialog;
begin
 OpenDialog1:=TOpenDialog.Create(nil);
 try
   OpenDialog1.Filter := 'Only Text files (*.txt)|*.txt';
   if OpenDialog1.Execute then
    ShowMessage('Selected File '+OpenDialog1.FileName);
 finally
   OpenDialog1.Free;
 end;

end;
like image 141
RRUZ Avatar answered Mar 25 '26 14:03

RRUZ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!