Problem z odczytaniem danych

0

Witam, mam problem z odczytaniem komponentu z pliku :

function TForm1.FileToComponent(Component : TComponent):String; //ReadToFile
begin
tbar := TFileStream.Create('SetButton.dat',fmOpenRead);
tbar.ReadComponent(Component);
tbar.Free;
end;

{ function TForm1.ComponentToFile(Component : TComponent):String; //WriteToFile
begin
tbar := TFileStream.Create('SetButton.dat',fmCreate);
tbar.WriteComponent(Component);
tbar.Free;
end; }

Jest taki blad : Class TToolButton not found !.
Co mam zrobic ?

0

Może pomoże procedura RegisterClasses() w sekcji initialization modułu?

0
procedure TForm1.ComponentToFile
var
  FileStream : TFileStream;
begin
  if FileExists('c:\plik.dat') then
  FileStream := TFileStream.Create('c:\plik.dat', fmOpenWrite) else
  FileStream := TFileStream.Create('c:\plik.dat', fmCreate);

  FileStream.WriteComponent(Komponent); // zapisz ustawienia komponentu "Komponent"
  FileStream.Free;
end;


procedure TForm1.FileToComponent;
var
  FileStream : TFileStream;
begin
  if not FileExists('c:\plik.dat') then Exit; 

  FileStream := TFileStream.Create('c:\plik.dat', fmOpenRead);
  FileStream.ReadComponent(Komponent);
  FileStream.Free;
end;
0

Ale pojawia sie caly czas blad typu :
Project Main.exe raised exception class EClassNotFound with message 'Class TToolButton not found'

wywoluje funkcje : FileToComponent(ToolBar1);

O co chodzi, dlaczegi to nie chce dzialac?

Czy nikt nie potrafi tego rozwiazac

0

Może pomoże procedura RegisterClasses() w sekcji initialization modułu?

0

Nie rozumiem zbytnio, mam sobie sam napisac taka procedurke, czy co. Moze jest gotowa

0

Jest już, w module bodajże Classes (chociaż pewnie się mylę, jakby coś to sprawdzaj po kolei standardowe moduły dołączane przy formularzu):

initialization
  RegisterClasses([TButton, TEdit, TForm]); // np.

1 użytkowników online, w tym zalogowanych: 0, gości: 1