-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuSaveFileDialog.pas
56 lines (45 loc) · 1.4 KB
/
uSaveFileDialog.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
unit uSaveFileDialog;
//The following code example illustrates creating a SaveFileDialog, setting members,
//calling the dialog box using the ShowDialog method, and saving the current file.
interface
uses
{$IF CompilerVersion > 22}
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
{$ELSE}
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
{$IFEND}
CNClrLib.Control.EnumTypes, CNClrLib.Control.Base, CNClrLib.Component.SaveFileDialog;
type
TForm17 = class(TForm)
Button1: TButton;
CnSaveFileDialog1: TCnSaveFileDialog;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form17: TForm17;
implementation
{$R *.dfm}
uses CNClrLib.Core;
procedure TForm17.Button1Click(Sender: TObject);
var
myStream: _Stream;
begin
CnSaveFileDialog1.Filter := 'txt files (*.txt)|*.txt|All files (*.*)|*.*';
CnSaveFileDialog1.FilterIndex := 2;
CnSaveFileDialog1.RestoreDirectory := True;
if CnSaveFileDialog1.ShowDialog = TDialogResult.drOK then
begin
myStream := CnSaveFileDialog1.OpenFile;
if myStream <> nil then
begin
// Code to write the stream goes here.
myStream.Close();
end;
end;
end;
end.