Difference between revisions of "Howto Use TOpenDialog"
From Lazarus wiki
Jump to navigationJump to searchLine 22: | Line 22: | ||
The [[doc:lcl/dialogs/tfiledialog.filename.html | Filename]] property returns the full filename including drive and path. | The [[doc:lcl/dialogs/tfiledialog.filename.html | Filename]] property returns the full filename including drive and path. | ||
− | '''Note''': This control only collects the filename. It does not actually open the file. Your code must do that. | + | '''Note''': This control only collects the filename. It does not actually open the file. Your code must do that. It also does not check to see if the file actually exists. |
== See also == | == See also == |
Revision as of 15:31, 24 December 2017
│
Deutsch (de) │
English (en) │
español (es) │
suomi (fi) │
français (fr) │
日本語 (ja) │
polski (pl) │
русский (ru) │
slovenčina (sk) │
Howto Use TOpenDialog
Simple and short guideline:
- Place a TOpenDialog widget on your form (anyplace, since it will be not visible).
- In your code write something similar to:
var
filename: string;
if OpenDialog1.Execute then
begin
filename := OpenDialog1.Filename;
ShowMessage(filename);
end;
The Execute method displays the file open dialog. It returns true when user has selected a file, false when user has aborted.
The Filename property returns the full filename including drive and path.
Note: This control only collects the filename. It does not actually open the file. Your code must do that. It also does not check to see if the file actually exists.