Autor Beitrag
schuetzejanett
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: Di 23.01.07 18:24 
Hallo,

ich habe mir eine Klasse TImagebox definiert, die von Tpaintbox erbt in dieser Klasse soll beim Aufruf eine bmp Datei angezeigt werden. Erstelle ich mir aber eine TImagebox laüft das programm erst durch den konstruktor und dann gleich durch den destruktor. Und ich erhalte danach die fehlermeldung Abstrakter fehler.

Woran liegt das? und was mache ich falsch?

ausblenden volle Höhe 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:
unit DartBoard;

interface

uses
   Messages, SysUtils, Variants, Classes, Graphics, Controls,
   Dialogs, ExtCtrls, StdCtrls;

type
  TImageBox = class(TPaintBox)
  private
    Tboard: TGraphic;

  public
    constructor Create(AOwner: TComponent);
    destructor Destroy; override;
    procedure OnPaint(Sender : TObject);
  end;

implementation

{ TImageBox }

constructor TImageBox.Create;
begin
  inherited Create(AOwner);
  TBoard := TGraphic.Create;
  TBoard.LoadFromFile('Dartbrett.bmp');
end;

destructor TImageBox.Destroy;
begin
  FreeAndNil(TBoard);
  inherited;
end;

procedure TImageBox.OnPaint(Sender : TObject);
begin
  Canvas.Draw(0,0,TBoard); 
end;
end.


Und der aufruf
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
    private
       Gameboard : TImageBox; 

    Gameboard := TImageBox.Create(self);
    Gameboard.Left := 410;
    Gameboard.Top := 125;
    Gameboard.Width := 350;
    Gameboard.height := 350;
    Gameboard.OnPaint(self);


Zuletzt bearbeitet von schuetzejanett am Di 23.01.07 18:32, insgesamt 1-mal bearbeitet
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: Di 23.01.07 18:28 
Warum:
ausblenden Delphi-Quelltext
1:
Gameboard : TImageBoard;					

? Die Klasse heißt TImageBox!

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
schuetzejanett Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: Di 23.01.07 18:30 
ja heißt sie auch war bloß ein tippfehler weil ich diese zeile nicht rauskopiert habe sondern selber geschrieben und mich dabei vertan habe