1 |
(* ***** BEGIN LICENSE BLOCK *****
|
2 |
* Version: MPL 1.1
|
3 |
*
|
4 |
* The contents of this file are subject to the Mozilla Public License Version
|
5 |
* 1.1 (the "License"); you may not use this file except in compliance with
|
6 |
* the License. You may obtain a copy of the License at
|
7 |
* http://www.mozilla.org/MPL/
|
8 |
*
|
9 |
* Software distributed under the License is distributed on an "AS IS" basis,
|
10 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
11 |
* for the specific language governing rights and limitations under the
|
12 |
* License.
|
13 |
*
|
14 |
* The Original Code is TurboPower SysTools
|
15 |
*
|
16 |
* The Initial Developer of the Original Code is
|
17 |
* TurboPower Software
|
18 |
*
|
19 |
* Portions created by the Initial Developer are Copyright (C) 1996-2002
|
20 |
* the Initial Developer. All Rights Reserved.
|
21 |
*
|
22 |
* Contributor(s):
|
23 |
*
|
24 |
* ***** END LICENSE BLOCK ***** *)
|
25 |
|
26 |
{*********************************************************}
|
27 |
{* SysTools: StPropEd.pas 4.04 *}
|
28 |
{*********************************************************}
|
29 |
{* SysTools: Property Editors *}
|
30 |
{*********************************************************}
|
31 |
|
32 |
{$I StDefine.inc}
|
33 |
|
34 |
unit StPropEd;
|
35 |
|
36 |
interface
|
37 |
|
38 |
uses
|
39 |
Dialogs,
|
40 |
{$IFDEF VERSION6}
|
41 |
DesignIntf,
|
42 |
DesignEditors,
|
43 |
{$ELSE}
|
44 |
DsgnIntf,
|
45 |
{$ENDIF}
|
46 |
Forms,
|
47 |
Controls;
|
48 |
|
49 |
type
|
50 |
TStFileNameProperty = class(TStringProperty)
|
51 |
public
|
52 |
function GetAttributes: TPropertyAttributes; override;
|
53 |
procedure Edit; override;
|
54 |
end;
|
55 |
|
56 |
TStGenericFileNameProperty = class(TStringProperty)
|
57 |
public
|
58 |
function GetAttributes: TPropertyAttributes; override;
|
59 |
procedure Edit; override;
|
60 |
end;
|
61 |
|
62 |
implementation
|
63 |
|
64 |
function TStFileNameProperty.GetAttributes: TPropertyAttributes;
|
65 |
begin
|
66 |
Result := [paDialog];
|
67 |
end;
|
68 |
|
69 |
procedure TStFileNameProperty.Edit;
|
70 |
var
|
71 |
Dlg : TOpenDialog;
|
72 |
begin
|
73 |
Dlg := TOpenDialog.Create(Application);
|
74 |
try
|
75 |
Dlg.DefaultExt := '*.exe';
|
76 |
Dlg.Filter := 'Executable Files (*.exe)|*.exe' +
|
77 |
'|Dynamic Link Libraries (*.dll)|*.dll';
|
78 |
Dlg.FilterIndex := 0;
|
79 |
Dlg.Options := [];
|
80 |
if GetName = 'ShortcutFileName' then
|
81 |
Dlg.Options := [ofNoDereferenceLinks];
|
82 |
Dlg.FileName := Value;
|
83 |
if Dlg.Execute then
|
84 |
Value := Dlg.FileName;
|
85 |
finally
|
86 |
Dlg.Free;
|
87 |
end;
|
88 |
end;
|
89 |
|
90 |
|
91 |
function TStGenericFileNameProperty.GetAttributes: TPropertyAttributes;
|
92 |
begin
|
93 |
Result := [paDialog];
|
94 |
end;
|
95 |
|
96 |
procedure TStGenericFileNameProperty.Edit;
|
97 |
var
|
98 |
Dlg : TOpenDialog;
|
99 |
begin
|
100 |
Dlg := TOpenDialog.Create(Application);
|
101 |
try
|
102 |
Dlg.DefaultExt := '*.*';
|
103 |
Dlg.Filter := 'Text files (*.txt)|*.txt' +
|
104 |
'|Pascal files (.pas)|*.pas' +
|
105 |
'|C++ files (*.cpp)|*.cpp' +
|
106 |
'|All files (*.*)|*.*';
|
107 |
Dlg.FilterIndex := 0;
|
108 |
Dlg.Options := [];
|
109 |
Dlg.FileName := Value;
|
110 |
if Dlg.Execute then
|
111 |
Value := Dlg.FileName;
|
112 |
finally
|
113 |
Dlg.Free;
|
114 |
end;
|
115 |
end;
|
116 |
|
117 |
end.
|