Class TButton not found

Für Fragen von Einsteigern und Programmieranfängern...
Antworten
felix96
Beiträge: 287
Registriert: So 29. Nov 2009, 17:44
CPU-Target: 32BitWin+64bitUbunt

Class TButton not found

Beitrag von felix96 »

Immer wenn Ich Form4 erstelle, und dann F9 drücke wird das Programm anstandslos Übersetzt.
Jetzt kommt aber die Windows Fehlermeldung: Class TButton not found.
Dannach wird das Programm Beendet.

Hie der Quelcode von Unit4:

Code: Alles auswählen

unit Unit5; 
 
{$mode objfpc}{$H+}
 
interface
 
uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls, ExtCtrls;
 
type
 
  { TForm5 }
 
  TForm5 = class(TForm)
    Edit1: TEdit;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Memo1: TMemo;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;
 
var
  Form5: TForm5;
 
implementation
 
{ TForm5 }
 
procedure TForm5.FormCreate(Sender: TObject);
begin
  memo1.Clear;
  memo1.Text := ('So das übliche bla bla, weiteres unter' +#13 +'www...');     ///////////////////////////
  if not fileexists ('C:\Dokumente und Einstellungen\All Users\Startmenü\Programme') then begin
   radiobutton2.checked := true;
   radiobutton2.enabled := false; end else radiobutton1.checked := true;
  end;
 
initialization
  {$I unit5.lrs}
 
end.
Zuletzt geändert von felix96 am Mo 21. Dez 2009, 20:26, insgesamt 1-mal geändert.
Danke schonmal für eure Antworten
it´s not a bug, it´s a feature!

Hitman
Beiträge: 512
Registriert: Mo 25. Aug 2008, 18:17
OS, Lazarus, FPC: ArchLinux x86, WinVista x86-64, Lazarus 0.9.29, FPC 2.4.1
CPU-Target: x86
Wohnort: Chemnitz

Re: Class TButton not found

Beitrag von Hitman »

irgendwas haut da nicht hin ...
unit Unit4 ... type TForm4 ...

aber dann:
var
form5: tform5

und {$i unit5.lrs} .... das passt alles nicht zusammen

felix96
Beiträge: 287
Registriert: So 29. Nov 2009, 17:44
CPU-Target: 32BitWin+64bitUbunt

Re: Class TButton not found

Beitrag von felix96 »

OK, Unit4 habe Ich Aus dem oben Beschriebenen Grund Gelöscht, jetzt ist das Original da.
Danke schonmal für eure Antworten
it´s not a bug, it´s a feature!

felix96
Beiträge: 287
Registriert: So 29. Nov 2009, 17:44
CPU-Target: 32BitWin+64bitUbunt

Re: Class TButton not found

Beitrag von felix96 »

Kann mir einer bitte mal erklären was das hier ist ?
http://mail.jabber.org/pipermail/exodus/2003-June/000181.html
Danke schonmal für eure Antworten
it´s not a bug, it´s a feature!

Benutzeravatar
theo
Beiträge: 10497
Registriert: Mo 11. Sep 2006, 19:01

Re: Class TButton not found

Beitrag von theo »

felix96 hat geschrieben:Kann mir einer bitte mal erklären was das hier ist ?
http://mail.jabber.org/pipermail/exodus/2003-June/000181.html

Hat das was mit Lazarus zu tun?

Die Meldung kommt, wenn man z.B. Buttons in ein Formular einfügt, während der Quellcode nicht compilerbar ist.
Dann steht der Button zwar im Formular (lfm) aber nicht in der Unit (pas) und es kommt zur Laufzeit zur o.g. Meldung.
Das passiert eigentlich nur, wenn man schludert.

felix96
Beiträge: 287
Registriert: So 29. Nov 2009, 17:44
CPU-Target: 32BitWin+64bitUbunt

Re: Class TButton not found

Beitrag von felix96 »

Danke schonmal für eure Antworten
it´s not a bug, it´s a feature!

Benutzeravatar
theo
Beiträge: 10497
Registriert: Mo 11. Sep 2006, 19:01

Re: Class TButton not found

Beitrag von theo »

Nicht begriffen was ich meinte?

Wenn du z.B. diesen Code hast (leere Form mit einem Fehler im Code. Siehe "initializatio"):

Code: Alles auswählen

unit Unit1; 
 
{$mode objfpc}{$H+}
 
interface
 
uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls;
 
type
 
  { TForm1 }
 
  TForm1 = class(TForm)
  private
    { private declarations }
  public
    { public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
initializatio
  {$I unit1.lrs}
 
end.


Wenn du jetzt einen Button auf die Form pappst, wird er nur im lfm aber nicht in der Unit eingetragen.

Code: Alles auswählen

object Form1: TForm1
  Left = 469
  Height = 300
  Top = 173
  Width = 400
  Caption = 'Form1'
  ClientHeight = 300
  ClientWidth = 400
  LCLVersion = '0.9.29'
  object Button1: TButton
    Left = 120
    Height = 25
    Top = 208
    Width = 75
    Caption = 'Button1'
    TabOrder = 0
  end
end


Im Code müsste jetzt eig. zus.

Code: Alles auswählen

Button1: TButton;

stehen. Tut aber nicht, weil der Code beim Einfügen "kaputt" war.

Das führt beim Ausführen zur o.g. Meldung, auch wenn der Fehler bei "initialization" behoben wurde.
Die Meldung bedeutet also, dass du auf dem Formular ein Objekt hast, welches im Code keine Entsprechung findet.
Also nachdeklarieren oder löschen und wieder einfügen.

felix96
Beiträge: 287
Registriert: So 29. Nov 2009, 17:44
CPU-Target: 32BitWin+64bitUbunt

Re: Class TButton not found

Beitrag von felix96 »

SUPER, DANKE :-)
Danke schonmal für eure Antworten
it´s not a bug, it´s a feature!

Antworten