Difference between revisions of "Howto Use TOpenDialog"
From Lazarus wiki
Jump to navigationJump to searchm (typos) |
|||
Line 15: | Line 15: | ||
2. In your code write something similar to: | 2. In your code write something similar to: | ||
− | < | + | <syntaxhighlight> |
− | + | var | |
+ | filename: string; | ||
− | + | if OpenDialog1.Execute then | |
− | + | begin | |
− | + | filename := OpenDialog1.Filename; | |
− | + | ShowMessage(filename); | |
− | + | end; | |
− | </ | + | </syntaxhighlight> |
The [[doc:lcl/dialogs/tcommondialog.execute.html | Execute]] method displays the file open dialog. It returns [[True|true]] when user has selected a file, [[False|false]] when user has aborted. | The [[doc:lcl/dialogs/tcommondialog.execute.html | Execute]] method displays the file open dialog. It returns [[True|true]] when user has selected a file, [[False|false]] when user has aborted. | ||
Line 34: | Line 35: | ||
* [[Howto Use TSaveDialog]] | * [[Howto Use TSaveDialog]] | ||
* [[Dialogs_tab| Dialogs tab]] | * [[Dialogs_tab| Dialogs tab]] | ||
+ | |||
+ | [[Category:Lazarus]] | ||
+ | [[Category:Tutorials]] |
Revision as of 23:07, 14 April 2012
│
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:
1. Place the OpenDialog widget on your form (anyplace, since it will be not visible).
(It is the left most dialog under Dialog)
2. 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.