unit savedlg;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TSaveDlg =
class(TForm)
btbtn_ok: TBitBtn;
btbtn_cancel: TBitBtn;
lbl_filename: TLabel;
ed_filename: TEdit;
procedure btbtn_okClick(Sender: TObject);
procedure ed_filenameKeyPress(Sender: TObject;
var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
function ShowModal(
var AFileName :
String): TModalResult;
ReIntroduce;
end;
var
frm_SaveDlg: TSaveDlg;
implementation
{$R *.dfm}
function TSaveDlg.ShowModal(
Var AFileName:
String): TModalResult;
begin
ed_filename.Text := AFileName;
result :=
inherited ShowModal;
if ( Result = mrOk )
then
AFileName := ed_filename.Text;
end;
procedure TSaveDlg.btbtn_okClick(Sender: TObject);
begin
If ( Length(Trim(ed_filename.Text)) = 0 )
Then // ok, nix eingegeben oder nur leerzeichen
Begin
MessageDlg('
Bitte geben Sie einen Dateinamen an!', mtError, [mbOk], 0);
ed_filename.SetFocus;
Exit;
End;
ModalResult := mrOk;
end;
procedure TSaveDlg.ed_filenameKeyPress(Sender: TObject;
var Key: Char);
const
cValidFileNameKey :
set of Char = [#8,#32,#33,#35..#41,#43..#46,#48..#57,#59,#61,#65..#91,#93..#123,#125,#126];
begin
if not ((Key
in cValidFileNameKey))
then Key := #0;
end;
end.