Sign in Join
Wiki copytemporary

Howto Use TOpenDialog: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11Simple and short guidelines:
22
331\. Place a [[TOpenDialog]] widget ![](/wiki-images/9/90/Topendialog.png) on your [[TForm|form]]. It can be placed anywhere on your form as it is not visible during program [[runtime|run time]] but only during design time.
44
5-![`Component_Palette_Dialogs.png`](/wiki-images/7/72/Component_Palette_Dialogs.png)` `
5+```text
6+Image:Component_Palette_Dialogs.png
7+```
68
79It is located in the [[Dialogs tab]] of the [[Component Palette|component palette]] and is the leftmost component.
810
9112\. In your code write something similar to:
1012
1113``` pascal
1214if OpenDialog1.Execute then
1315 begin
1416 if fileExists(OpenDialog1.Filename) then
1517 ShowMessage(OpenDialog1.Filename);
1618 end
1719else
1820 ShowMessage('No file selected');
1921```
2022
2123The dialog [[doc:lcl/dialogs/tcommondialog.execute.html|Execute]] [[Method|method]] displays the file open dialog. It returns [[True|true]] when user has selected a file, [[False|false]] when user has aborted.
2224
2325The dialog [[doc:lcl/dialogs/tfiledialog.filename.html|Filename]] [[Property|property]] returns the full filename including drive and path.
2426
2527> **Note:** This control only collects the filename. It does not actually open the file. Your code must do that.
2628
2729## See also
2830
2931- [[Howto Use TSaveDialog]]
3032- [[CopyFile]]
3133
3234---
3335*From the Free Pascal wiki, page "Howto Use TOpenDialog", as it stood on 2021-03-27 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history