Mne to chodi - pri edite mam speedbutton, ked sa nan klikne zvoli sa subor. Dalsie tlacidlo savuje do INI suboru...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
EditCesta: TEdit;
SpeedButtonVybratAdresar: TSpeedButton;
BitBtnUlozitDoINI: TBitBtn;
procedure SpeedButtonVybratAdresarClick(Sender: TObject);
procedure BitBtnUlozitDoINIClick(Sender: TObject);
private
function DajKonfigCestu: String;
procedure NastavKonfigCestu(const Hodnota: String);
public
property KonfigCesta: String read DajKonfigCestu write NastavKonfigCestu;
end; // TForm1
var
Form1: TForm1;
implementation
uses
IniFiles;
{$R *.dfm}
// *****************************************************************************
procedure TForm1.SpeedButtonVybratAdresarClick(Sender: TObject);
begin
with TOpenDialog.Create(nil) do
try // FINALLY
if Execute then
KonfigCesta := FileName;
finally
Free;
end; // FINALLY
end;
// *****************************************************************************
procedure TForm1.BitBtnUlozitDoINIClick(Sender: TObject);
begin
with TMemIniFile.Create('C:\A.INI') do
try // FINALLY
WriteString('PATHS', 'Template', KonfigCesta);
UpdateFile;
finally
Free;
end; // FINALLY
end;
// *****************************************************************************
// Vratime iba tie subory, ktore existuju
function TForm1.DajKonfigCestu: String;
begin
if FileExists(EditCesta.Text) then
Result := EditCesta.Text
else
Result := '';
// Pripadny log
end;
// *****************************************************************************
procedure TForm1.NastavKonfigCestu(const Hodnota: String);
begin
EditCesta.Text := Hodnota;
end;
end.