Einzelnen Beitrag anzeigen

IIIMADDINIII
(Gast)

n/a Beiträge
 
#1

Events von untergeordneter Komponente werden nicht angezeigt

  Alt 20. Feb 2010, 16:48
Hallo mein Vater hat ein Problem.

Beim Erstellen einer eigenen Komponente (Tdateiformat) hat er Komponenten kreiert deren Funktion
es ist einen Dateibrowser darzustellen. Nun hat er die Komponenten im Objektinspektor dargestellt aber die dazugehörigen Events fehlen.

Hier ist der Code zu der Komponente:
Delphi-Quellcode:
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)) = '.USPthen openusp(filename)
    else if uppercase(extractfileext(filename)) = '.SPEthen openspe(filename)
    else if uppercase(extractfileext(filename)) = '.DATthen opendat(filename)
    else if uppercase(extractfileext(filename)) = '.TXTthen 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.
  Mit Zitat antworten Zitat