Autor Beitrag
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 12.07.06 16:49 
Ich programmiere laut dem Buch Delphi for Kids einen runden Button (TOButton). Hier der Source:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
unit OButton;

interface

uses
  SysUtils, Classes, Controls;

const OColor: array[1..3of TColor=(clBlack,ClGray,ClWhite);

type
  TOButton = class(TCustomControl)
  private
    Pressed : boolean;
    Color : TColor;
    { Private-Deklarationen }
  protected
    procedure Paint; override;
    { Protected-Deklarationen }
  public
    { Public-Deklarationen }
    constructor Create (AOwner : TComponent); override;
  published
    { Published-Deklarationen }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Win32', [TOButton]);
end;

procedure TOButton.Paint;
var i:integer;
begin
  if Pressed then
    for i := 1 to 3 do
    begin
      Canvas.Pen.Color := OCOlor[(i+1div 2);
      Canvas.ArcTan(i,i,Width,i,Height-i,i,i,i,i);
    end
  else
    for i := 1 to 3 do
    begin
      Canvas.Pen.Color:=OColor[i];
      Canvas.Arc(i,i,Width-i,Height-i,i,i,i,i);
    end:
  Canvas.Ellipse(3,3,Width-3,Height-3);
end;

constructor TOButton.Create (AOwner : TComponent);
begin
  inherited Create(AOwner);
  Color := clBtnFace;
  Canvas.Brush.Color := Color;
  Pressed := false;
  SetBounds(0,0,50,50);
end;
end.

Das Programm:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
unit main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OButton;

type
  TForm1 = class(TForm)
  private
    { Private-Deklarationen }
    OButton1: TOButton;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}



end.

Wenn ich nun compilieren will, kommt das:
Zitat:

[Fataler Fehler] OButton.pas(1): Das Programm oder die Unit 'OButton.pas' ruft sich selbst wieder auf

Wo ruft denn OButton sich selber auf? :lupe: Es geht um den Eintrag in der uses-Klausel von main aber ohne die sagt er unbekannter Bezeichner.


Moderiert von user profile iconTino: Topic aus Sonstiges (Delphi) verschoben am Fr 14.07.2006 um 15:09

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
root_at_localhost
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 191



BeitragVerfasst: Mi 12.07.06 17:16 
Pack mal das ganze Projekt und stell es hier rein, ich finde in deinem Quelltext zwar einige Fehler aber den angegebenen kann ich nicht reproduzieren.
Fehler bei mir sind:
- In der OButton.pas muss in der Uses-Klausel im Interface Graphics angegeben werden, sonst ist TColor undefiniert
- Canvas.ArcTan gibt es nicht, Canvas.Arc hat einen Parameter weniger
- Nach dem end kommt ein ; und kein :

Ansonsten kompiliert es fehlerfrei...
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 12.07.06 17:21 
Bitte.
Einloggen, um Attachments anzusehen!
_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
root_at_localhost
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 191



BeitragVerfasst: Mi 12.07.06 17:57 
Ah, jetzt versteh ich. Dein Projekt heißt OButton.dpr, die Unit heißt OButton.pas. Da kommt Delphi mit den Namen durcheinander. Du musst nur die OButton.dpr umbenennen, z.B. in OButton_Test.dpr, dann öffnest du das Projekt, gehst auf Projekt->Quelltext anzeigen und änderst die erste Zeile von program OButton; in program OButton_Test;
Speichern, neu restliche Fehler korrigieren und es sollte gehen...
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 12.07.06 18:04 
Ja das klingt logisch. Dankeschön ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot