unit dateiformat;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, FileCtrl;
type
Tdateiformat =
class(TCustomControl)
private
{ Private declarations }
con_filename:
string;
con_anz: integer;
con_strings: Tstrings;
con_openstndformat: boolean;
con_drivecombobox: tdrivecombobox;
con_directorylistbox: tdirectorylistbox;
con_filtercombobox: Tfiltercombobox;
con_filelistbox: Tfilelistbox;
protected
procedure paint;
override;
{ Protected declarations }
public
{ Public declarations }
constructor create(aowner: tcomponent);
override;
procedure setfilename(filename:
string);
virtual;
procedure setopenstndformat(openstndformat: boolean);
virtual;
procedure setstrings(strings: Tstrings);
virtual;
function openfile(filename:
string = '
'): boolean;
procedure openusr(filename:
string);
procedure openusp(filename:
string);
procedure openspe(filename:
string);
procedure opendat(filename:
string);
published
property align;
property openstndformat: boolean
read con_openstndformat
write setopenstndformat;
property filename:
string read con_filename
write setfilename;
property anz: integer
read con_anz;
property strings: Tstrings
read con_strings
write setstrings;
property Filelistbox: TFilelistbox
read con_Filelistbox;
property filtercombobox: Tfiltercombobox
read con_filtercombobox;
property directorylistbox: Tdirectorylistbox
read con_directorylistbox;
property drivecombobox: Tdrivecombobox
read con_drivecombobox;
{ Published declarations }
end;
procedure Register;
implementation
procedure Tdateiformat.openusr(filename:
string);
begin
//
end;
procedure Tdateiformat.openusp(filename:
string);
var
filn: Tstringlist;
begin
filn := Tstringlist.Create;
filn.LoadFromFile(filename);
con_strings := filn;
end;
procedure Tdateiformat.openspe(filename:
string);
begin
//
end;
procedure Tdateiformat.opendat(filename:
string);
begin
//
end;
function tdateiformat.openfile(filename:
string = '
'): boolean;
begin
result := true;
if filename = '
'
then filename := con_filelistbox.FileName;
if not fileexists(filename)
then
begin
result := false;
halt;
end;
if con_openstndformat = false
then openusr(filename)
else
begin
if uppercase(extractfileext(filename)) = '
.USP'
then openusp(filename)
else if uppercase(extractfileext(filename)) = '
.SPE'
then openspe(filename)
else if uppercase(extractfileext(filename)) = '
.DAT'
then opendat(filename)
else if uppercase(extractfileext(filename)) = '
.TXT'
then openusr(filename)
else openusr(filename);
end;
end;
procedure tdateiformat.paint;
begin
con_drivecombobox.SetBounds(0, 0, round(0.25 * self.Width), 10);
con_filtercombobox.SetBounds(0, con_drivecombobox.Height + con_directorylistbox.Height, round(0.25 * self.Width), 10);
con_directorylistbox.SetBounds(0, con_drivecombobox.Height, round(0.25 * self.Width), self.Height - con_drivecombobox.Height - con_filtercombobox.Height);
con_filelistbox.SetBounds(con_drivecombobox.Width, 0, round(0.75 * self.Width), self.Height);
end;
procedure Tdateiformat.setstrings(strings: Tstrings);
begin
con_strings.Assign(strings);
repaint;
end;
procedure Tdateiformat.setopenstndformat(openstndformat: boolean);
begin
con_openstndformat := openstndformat;
repaint;
end;
procedure Tdateiformat.setfilename(filename:
string);
begin
con_filename := filename;
con_drivecombobox.Drive := extractfiledrive(filename)[1];
con_directorylistbox.Directory := extractfiledir(filename);
con_filelistbox.FileName := filename;
repaint;
end;
constructor tdateiformat.create(aowner: tcomponent);
begin
inherited create(aowner);
con_drivecombobox := tdrivecombobox.Create(self);
con_drivecombobox.Parent := self;
con_directorylistbox := tdirectorylistbox.Create(self);
con_directorylistbox.Parent := self;
con_filtercombobox := tfiltercombobox.Create(self);
con_filtercombobox.Parent := self;
con_filelistbox := tfilelistbox.Create(self);
con_filelistbox.Parent := self;
con_drivecombobox.DirList := con_directorylistbox;
con_directorylistbox.FileList := con_filelistbox;
con_filtercombobox.Filter := '
USP-Datei|*.usp|SPE-Datei|*.spe|DAT-Datei|*.dat|TXT-Datei|*.txt|Alle Datein|*';
con_filtercombobox.FileList := con_filelistbox;
con_strings := Tstrings.Create;
repaint;
end;
procedure Register;
begin
RegisterComponents('
Standard', [Tdateiformat]);
end;
end.