Autor Beitrag
daholg
Hält's aus hier
Beiträge: 8



BeitragVerfasst: So 05.06.05 19:07 
Hi

ich muss für die Schule "Memory" programmieren. Um mit irgendwelche Probleme zu ersparen hab ich die Bilder als BitButtons festgelegt. Hier der Quellentext:

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:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button2: TButton;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Label1: TLabel;
    BitBtn3: TBitBtn;
    BitBtn4: TBitBtn;
    BitBtn5: TBitBtn;
    BitBtn6: TBitBtn;
    BitBtn7: TBitBtn;
    BitBtn8: TBitBtn;
    BitBtn9: TBitBtn;
    BitBtn10: TBitBtn;
    BitBtn11: TBitBtn;
    BitBtn12: TBitBtn;
    BitBtn13: TBitBtn;
    BitBtn14: TBitBtn;
    BitBtn15: TBitBtn;
    BitBtn16: TBitBtn;
    BitBtn17: TBitBtn;
    BitBtn18: TBitBtn;
    BitBtn19: TBitBtn;
    BitBtn20: TBitBtn;
    BitBtn21: TBitBtn;
    BitBtn22: TBitBtn;
    BitBtn23: TBitBtn;
    BitBtn24: TBitBtn;
    BitBtn25: TBitBtn;
    BitBtn26: TBitBtn;
    procedure Button2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  i,j,x:integer;
  arr:array[1..9of integer;
implementation

{$R *.DFM}


procedure TForm1.FormCreate(Sender: TObject);
begin
     randomize;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  close;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
label zufall;
begin
     for i:=1 to 9 do
     begin
         zufall:
              x:=random(9)+1;
                for j:=1 to i-1 do
                    if x = arr[j] then goto zufall;
         arr[i]:=x;
     end;

     bitbtn1.glyph.loadfromfile('auto'+inttostr(arr[1])+'.bmp');
     bitbtn2.glyph.loadfromfile('auto'+inttostr(arr[2])+'.bmp');
     bitbtn3.glyph.loadfromfile('auto'+inttostr(arr[3])+'.bmp');
     bitbtn4.glyph.loadfromfile('auto'+inttostr(arr[4])+'.bmp');
     bitbtn5.glyph.loadfromfile('auto'+inttostr(arr[5])+'.bmp');
     bitbtn6.glyph.loadfromfile('auto'+inttostr(arr[6])+'.bmp');
     bitbtn7.glyph.loadfromfile('auto'+inttostr(arr[7])+'.bmp');
     bitbtn8.glyph.loadfromfile('auto'+inttostr(arr[8])+'.bmp');
     bitbtn9.glyph.loadfromfile('auto'+inttostr(arr[9])+'.bmp');
     bitbtn10.glyph.loadfromfile('auto'+inttostr(arr[1])+'.bmp');
     bitbtn11.glyph.loadfromfile('auto'+inttostr(arr[2])+'.bmp');
     bitbtn12.glyph.loadfromfile('auto'+inttostr(arr[3])+'.bmp');
     bitbtn13.glyph.loadfromfile('auto'+inttostr(arr[4])+'.bmp');
     bitbtn14.glyph.loadfromfile('auto'+inttostr(arr[5])+'.bmp');
     bitbtn15.glyph.loadfromfile('auto'+inttostr(arr[6])+'.bmp');
     bitbtn16.glyph.loadfromfile('auto'+inttostr(arr[7])+'.bmp');
     bitbtn17.glyph.loadfromfile('auto'+inttostr(arr[8])+'.bmp');
     bitbtn18.glyph.loadfromfile('auto'+inttostr(arr[9])+'.bmp');

     bitbtn1.visible:=false;

     label1.caption:=inttostr(arr[1])+'; '+inttostr(arr[2])+'; '+inttostr(arr[3])+'; '+inttostr(arr[4])+'; '+inttostr(arr[5])+'; '+inttostr(arr[6])+'; '+inttostr(arr[7])+'; '+inttostr(arr[8])+'; '+inttostr(arr[9]);
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
label jump;
begin
     for i:=1 to 9 do
     begin
         jump:
              x:=random(9)+1;
                for j:=1 to i-1 do
                    if x = arr[j] then goto jump;
         arr[i]:=x;
     end;

     bitbtn1.glyph.loadfromfile('auto'+inttostr(arr[1])+'.bmp');
     bitbtn2.glyph.loadfromfile('auto'+inttostr(arr[2])+'.bmp');
     bitbtn3.glyph.loadfromfile('auto'+inttostr(arr[3])+'.bmp');
     bitbtn4.glyph.loadfromfile('auto'+inttostr(arr[4])+'.bmp');
     bitbtn5.glyph.loadfromfile('auto'+inttostr(arr[5])+'.bmp');
     bitbtn6.glyph.loadfromfile('auto'+inttostr(arr[6])+'.bmp');
     bitbtn7.glyph.loadfromfile('auto'+inttostr(arr[7])+'.bmp');
     bitbtn8.glyph.loadfromfile('auto'+inttostr(arr[8])+'.bmp');
     bitbtn9.glyph.loadfromfile('auto'+inttostr(arr[9])+'.bmp');
     bitbtn10.glyph.loadfromfile('auto'+inttostr(arr[1])+'.bmp');
     bitbtn11.glyph.loadfromfile('auto'+inttostr(arr[2])+'.bmp');
     bitbtn12.glyph.loadfromfile('auto'+inttostr(arr[3])+'.bmp');
     bitbtn13.glyph.loadfromfile('auto'+inttostr(arr[4])+'.bmp');
     bitbtn14.glyph.loadfromfile('auto'+inttostr(arr[5])+'.bmp');
     bitbtn15.glyph.loadfromfile('auto'+inttostr(arr[6])+'.bmp');
     bitbtn16.glyph.loadfromfile('auto'+inttostr(arr[7])+'.bmp');
     bitbtn17.glyph.loadfromfile('auto'+inttostr(arr[8])+'.bmp');
     bitbtn18.glyph.loadfromfile('auto'+inttostr(arr[9])+'.bmp');

     bitbtn1.visible:=false;

     label1.caption:=inttostr(arr[1])+'; '+inttostr(arr[2])+'; '+inttostr(arr[3])+'; '+inttostr(arr[4])+'; '+inttostr(arr[5])+'; '+inttostr(arr[6])+'; '+inttostr(arr[7])+'; '+inttostr(arr[8])+'; '+inttostr(arr[9]);
end;

end.


Wenn ich das Programm ausführen will kommt folgende Meldung:
"Im Projekt Project1.exe ist eine Exception der Klasse EClassNotFound aufgetreten. Meldung:'Klasse TImage nicht gefunden'. Prozess wurde angehalten.....".

Hab ich was falsch gemacht? Wenn ja, was? War es geschickt BitButtons zu nutzen oder würden sich Images oder Speedbuttons besser verarbeiten lassen?

MfG daholg

PS: Ich hab nur geringes Wissen von Delphi, deswegen bitte Fachsprache vermeiden :)

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.

_________________
Wenn Du dich mit dem Teufel einlässt, verändert sich nicht der Teufel, sondern der Teufel verändert Dich!


Zuletzt bearbeitet von daholg am Di 07.06.05 22:45, insgesamt 1-mal bearbeitet
daholg Threadstarter
Hält's aus hier
Beiträge: 8



BeitragVerfasst: So 05.06.05 22:08 
Hmmmm ok sowas passiert wohl wenn man n Image erstellt, es aus dem Quelltext, aber nicht aus dem Formular löscht. Gefixt :)