Autor Beitrag
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 21.12.04 18:24 
hi,

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
  type 
 
  TFeld = class(TImage)
   private
     Gespielt: Boolean;
     kwert: byte;
     kfarbe: char;
     index:byte;
   procedure Click(Sender:TObject);
  // published
  // property MyObject: TMyObject read getMyObject write setMyObject;
  end;

  TForm1 = class(TForm)
    Button1: TButton;
  ...

var Feld : array[1..9] of TFeld;

das ist mein von Timage abgeleiteter Typ.
Wenn ich dann im Code folgenden Aufruf mache bekomme ich einen Fehler "inkompatible Typen TFeld und TImage"
ausblenden Delphi-Quelltext
1:
   Feld[i] := TImage.Create(self);					

mit folgendem Aufruf funktioniert es ohne Fehler, aber alle 9 Felder haben dann das selbe Bitmap geladen, obwohl ich die die einzelnen Felder mit verschiedenen Bitmaps bemale...
ausblenden Delphi-Quelltext
1:
   Feld[i] := TFeld.Create(self);					


sonderbarerweise kam der fehler früher nicht, ich muss irgendwas geändert haben was ihm nicht passt aber ich komme nicht dahinter...

den code zur erstellung der einzelnen Felder habe ich von hier geklaut www.delphi-forum.de/...ght=position+onclick

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
herzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 168

WINXP pro, SUSE Linux 9.0
D7 Pers.
BeitragVerfasst: Di 21.12.04 19:07 
Hi,

kaannst du mal den Code schreiben, wo du die Imaages bemalst ?
retnyg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 21.12.04 19:13 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure tform1.drawcardlist(var amemo: tstringlist);
var
   bmp:tbitmap;
   i:integer;
begin

  bmp := tbitmap.create;
  for i := 0 to amemo.count - 1 do
  begin
     bmp.LoadFromResourceName(HInstance,amemo.strings[i]);
     Feld[i+1].Canvas.Draw(0,0,bmp);
  end;
  bmp.FreeImage;

end;
herzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 168

WINXP pro, SUSE Linux 9.0
D7 Pers.
BeitragVerfasst: Di 21.12.04 19:44 
Hab mir mal die Sachen zusammengesucht..
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:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
unit Unit1;

interface

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

type
  TFeld = class(TImage)
   private
     index:byte;
  end;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    amemo: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    procedure starte(n:integer);
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Feld: Array[1..16] of TFeld;

implementation

{$R *.dfm}

procedure Tform1.starte(n:integer);
var
  i : integer;
begin
  for i := 1 to n do
  begin
    if (Feld[i] = nil) then
    begin   //gucken ob pointer existiert
      Feld[i] := TFeld.Create(self); //neues objekt erzeugen
      Feld[i].Parent := Form1;       //Form zuweisen
      Feld[i].Width := 20;
      Feld[i].Height := 20;
      Feld[i].Canvas.Brush.Style := bssolid;
      Feld[i].index := i;
    end;
    Feld[i].top := ((i-1) div round(sqrt(n)))*Feld[1].Height+10 ; //position
    Feld[i].Left := ((i-1) mod round(sqrt(n)))*Feld[1].Width+10;
    Feld[i].Visible := true;
    Feld[i].Canvas.Brush.Color := clred;
    Feld[i].Canvas.Rectangle(0,0,Feld[1].width,Feld[1].height);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  starte(16);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
   bmp:tbitmap;
   i:integer;
begin
  bmp := tbitmap.create;
  for i := 0 to amemo.Lines.Count - 1 do
  begin
     bmp.loadfromfile(amemo.Lines[i]);
     Feld[i+1].Canvas.Draw(0,0,bmp);
  end;
  bmp.FreeImage;
end;

end.

... klappt bei mir wunderbar. Wenn du damit nicht weiterkommst dann schreib bitte mal den kompletten quellcode . danke und mfg herzi
retnyg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 21.12.04 20:20 
dein code funktioniert bei mir auch prächtig...
ich habe das ganze projekt samt bildressourcen gezippt und online gestellt, ich komm nicht dahinter warum das nicht so will - die resourcenamen werden alle richtig überwiesen...
wäre super wenn du dir er kurz ansiehst.

danke retnyg
www.krazz.net/jassgui2.zip
herzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 168

WINXP pro, SUSE Linux 9.0
D7 Pers.
BeitragVerfasst: Di 21.12.04 20:50 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure tform1.drawcardlist(var amemo: tstringlist);
var
   bmp:tbitmap;
   i:integer;
   s:string;
begin
  for i := 0 to amemo.count - 1 do
  begin
     s:= amemo.strings[i];
     bmp := tbitmap.create;
     bmp.LoadFromResourceName(HInstance,s);
     Feld[i+1].Canvas.Draw(0,0,bmp);
     bmp.FreeImage;
  end;
end;


Bmp erstellen und wieder freigeben für jedes Feld ...

viel spass noch

herzi
retnyg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 21.12.04 20:57 
|-)

manchmal sieht man den wald vor läuter bäumen nicht :P

danke für deine hilfe !