Autor Beitrag
chriss1988
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 11.05.06 10:19 
hi
hab von einem en programm (ist ein memory)
dieser hat das programm in delphi 7 geschrieben konnte es öffnen un auch spielen.
So nun wollte ich das memory in mein programm einbinden.Also habe ich die form nach gestellt und teilweise Kopiert, und den quellcode kopiert.
Natürlich habe ich meine form usw. dem code angepasst.
Mun habe ich ein Problem zwar er läd das Programm und wenn ich auf die Felder klicke kommt da nur mein Hintergrund aber irgendwie kein Bild??
Woran kann das liegen?

Hier mal mein code:
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:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
unit Unit8;

interface

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

const
MIN = 1; // kleinste Spielfeldposition
MAX = 34; // größte Spielfeldposition
BTN_NAME = 'Button'; // Namenspräfix der Buttons
IMG_NAME = 'Image'; // Namenspräfix der Images

type

TPosition = record
CardID: Integer; // Kartennummer
Button: TButton; // zugehöriger Button
Image: TImage; // zugehöriges Image
end;
TPlayGround = Array[MIN..MAX] of TPosition;

TGameState = (
gsOpenCards0, // keine Karte
gsOpenCards1, // eine Karte
gsOpenCards2); // zwei Karten

  TfrmMain = class(TForm)
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    Image4: TImage;
    Image5: TImage;
    Image6: TImage;
    Image7: TImage;
    Image8: TImage;
    Image9: TImage;
    Image10: TImage;
    Image11: TImage;
    Image12: TImage;
    Image13: TImage;
    Image14: TImage;
    Image15: TImage;
    Image16: TImage;
    Image17: TImage;
    Image18: TImage;
    Image19: TImage;
    Image20: TImage;
    Image21: TImage;
    Image22: TImage;
    Image23: TImage;
    Image24: TImage;
    Image25: TImage;
    Image26: TImage;
    Image27: TImage;
    Image28: TImage;
    Image29: TImage;
    Image30: TImage;
    Image31: TImage;
    Image32: TImage;
    Image33: TImage;
    Image34: TImage;
    BtnStart: TBitBtn;
    BtnExit: TBitBtn;
    LabZuege: TLabel;
    Emoves: TEdit;
    Epoints: TEdit;
    Button1: TButton;
    LabPoints: TLabel;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Button10: TButton;
    Button11: TButton;
    Button12: TButton;
    Button13: TButton;
    Button14: TButton;
    Button15: TButton;
    Button16: TButton;
    Button17: TButton;
    Button18: TButton;
    Button19: TButton;
    Button20: TButton;
    Button21: TButton;
    Button22: TButton;
    Button23: TButton;
    Button24: TButton;
    Button25: TButton;
    Button26: TButton;
    Button27: TButton;
    Button28: TButton;
    Button29: TButton;
    Button30: TButton;
    Button31: TButton;
    Button32: TButton;
    Button33: TButton;
    Button34: TButton;
    CardImage: TImageList;
    ImgBack: TImage;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure BtnStartClick(Sender: TObject);
    procedure BtnExitClick(Sender: TObject);

  private    { Private declarations }
    FMoves, FPoints: Integer; // interner Speicher
    procedure SetMoves(const Value: Integer);
    procedure SetPoints(const Value: Integer);

  public     { Public declarations }
    Cards: TPlayGround; // Spielfeld
    GameState: TGameState; // Spielzustand
    Move1, Move2: Integer; // vorangegangene Züge
    property Moves: Integer read FMoves write SetMoves default 0;
    property Points: Integer read FPoints write SetPoints default 0;
  end;

var
  frmMain: TfrmMain;

implementation

uses Unit2;

{$R *.dfm}

procedure TfrmMain.Button1Click(Sender: TObject);
begin
  (Sender as TButton).Visible := false;
  case GameState of
  gsOpenCards0: // kein Feld in der Warteschlange

    begin
      Move1 := (Sender as TButton).Tag; // Feld als 1. Zug merken
      GameState := gsOpenCards1; // jetzt ist ein Feld offen
  end;

gsOpenCards1: // ein Feld ist schon offen

begin
Move2 := (Sender as TButton).Tag; // 2. Zug vermerken
  // Pärchen?
  if (Cards[Move1].CardID = Cards[Move2].CardID) then
    begin
      GameState := gsOpenCards0; // ja, dann Karten offen lassen
      Points := Points +1; // 1 punkt
      end
      else begin
      GameState := gsOpenCards2; // nein, im nächsten Zug verdecken
      Moves := Moves +1; // sonst ein Zug mehr
    end;
  end;
gsOpenCards2: // zwei ungleiche Felder vom Zug vorher
begin
    Cards[Move1].Button.Visible := TRUE; // alte Felder verdecken
    Cards[Move2].Button.Visible := TRUE;
    Move1 := (Sender as TButton).Tag; // neuen Zug
    GameState := gsOpenCards1;
  end;
end;

end;

procedure TfrmMain.FormCreate(Sender: TObject);
var
i: Integer;
begin
  for i := MIN to MAX do begin
    Cards[i].Button := TButton(frmMain.FindComponent(BTN_NAME+IntToStr(i)));
    Cards[i].Image := TImage(frmMain.FindComponent(IMG_NAME+IntToStr(i)));
    Cards[i].Button.Tag := i; // Trick zum späteren identifizieren
    Cards[i].CardID := (i -MIN) div 2;
  end;
// jeder Programmstart ist auch ein Spielstart
  BtnStartClick(Self);
end;

procedure TfrmMain.BtnStartClick(Sender: TObject);
var
i, j, tmp: Integer;
begin
  Moves := 0;
  Points := 0;

// Karten mischen
  for i := MIN to MAX do begin
    j := Random(MAX -MIN +1) +MIN;
    tmp := Cards[i].CardID;
    Cards[i].CardID := Cards[j].CardID;
    Cards[j].CardID := tmp;
  end;
  // Karten umdrehen und Vorderseiten raussuchen
  for i := MIN to MAX do begin
    Cards[i].Button.Visible := TRUE; // Button anzeigen
    CardImage.GetBitmap(Cards[i].CardID,Cards[i].Image.Picture.Bitmap);
  end;
    GameState := gsOpenCards0; // kein Feld offen
end;

procedure TfrmMain.SetMoves(const Value: Integer);
begin
  FMoves := Value; // Wert übernehmen
  EMoves.Text := IntToStr(Value); // und ausgeben
end;

procedure TfrmMain.SetPoints(const Value: Integer);
begin
  FPoints := Value; // Wert übernehmen
  EPoints.Text := IntToStr(Value); // und ausgeben
end;

procedure TfrmMain.BtnExitClick(Sender: TObject);
begin
  Application.Terminate;
end;

end.


Zuletzt bearbeitet von chriss1988 am Mi 17.05.06 08:17, insgesamt 1-mal bearbeitet
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 11.05.06 10:40 
Ich vermute, dass die TImageList nicht mehr mit den Bilddaten gefüllt ist.
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 11.05.06 10:42 
doch da sind 15 bilder drin
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 11.05.06 11:12 
Du änderst nur die Sichtbarkeit der Buttons, aber nicht die der Images!

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 11.05.06 11:14 
??????
was meist du damit
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 11.05.06 11:24 
In der Proc Button1Click, wird nur Button.Visible gesetzt, aber nicht Image.Visible.

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 11.05.06 11:47 
aha ok
aber wenn ich image.visible:=true setzte geht das nicht
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 11.05.06 12:26 
nach Zeile 141
ausblenden Delphi-Quelltext
1:
Cards[Move1].Image.Visible := True;					

etc in nach Zeile 147

und mit False nach Zeile 162 (2x)

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 11.05.06 13:56 
hi
ehm das geht nicht

zugriffsverletztung bei Adresse 00424640 in modul Projet1.exe. Lesen von 0000047
was heißt das??

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:
procedure TfrmMain.Button1Click(Sender: TObject);
begin
  (Sender as TButton).Visible := false;
  case GameState of
  gsOpenCards0: // kein Feld in der Warteschlange

    begin
      Move1 := (Sender as TButton).Tag; // Feld als 1. Zug merken
      GameState := gsOpenCards1; // jetzt ist ein Feld offen
      Cards[Move1].Image.Visible := True; //hier
  end;

gsOpenCards1: // ein Feld ist schon offen

begin
Move2 := (Sender as TButton).Tag; // 2. Zug vermerken
Cards[Move2].Image.Visible := True;{Und hier}
  // Pärchen?
  if (Cards[Move1].CardID = Cards[Move2].CardID) then
    begin
      GameState := gsOpenCards0; // ja, dann Karten offen lassen
      Points := Points +1; // 1 punkt
      end
      else begin
      GameState := gsOpenCards2; // nein, im nächsten Zug verdecken
      Moves := Moves +1; // sonst ein Zug mehr
    end;
  end;
gsOpenCards2: // zwei ungleiche Felder vom Zug vorher
begin
    Cards[Move1].Button.Visible := TRUE; // alte Felder verdecken
    Cards[Move2].Button.Visible := TRUE;
    Cards[Move1].Image.Visible := false; Und hier die false}
    Cards[Move2].Image.Visible := false;
    Move1 := (Sender as TButton).Tag; // neuen Zug
    GameState := gsOpenCards1;
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 11.05.06 15:15 
zieh mal die Zeile 35 gleich nachs Begin!

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Di 16.05.06 08:06 
ne bringt er den selben fehler
Einloggen, um Attachments anzusehen!
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Di 16.05.06 08:11 
Wenn Du einen Breakpoint auf den Begin der Proc und gehe sie langsam durch! Wo entststeht der Fehler?

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Di 16.05.06 08:38 
der fehler tritt immer dann auf, wenn ich auf eine Karte klicke.
Diese sollte sich normalerweise umdrehn nur kommt jezt die fehler meldung und es kommt kein bild soner ich seh nur den hintergrung meines spieles.

ich stell mal mein programm hier rein
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Di 16.05.06 14:04 
ok dann hier meine exe damit ihr seht was da nicht geht.
der 2 button ist der fürs memory.
Einloggen, um Attachments anzusehen!
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mi 17.05.06 06:59 
was soll ich denn mit der exe :?: , die Quellen um den Fehler zu finden wären doch wohl besser, oder :wink:

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Mi 17.05.06 07:57 
stimmt da hab ich wohl nicht nachgedacht
Einloggen, um Attachments anzusehen!
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mi 17.05.06 09:00 
jetzt fehlt zumindestens die Datei "unit8.dfm"

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 18.05.06 09:30 
ok ich hab den fehler gefunden
es läuft endlich und ich kann weiter arbeiten
Horschdware
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 744
Erhaltene Danke: 54

Win XP Pro, Win 7 Pro x64
Delphi 7, Delphi XE, C++ Builder 5, SAP R/3
BeitragVerfasst: Do 18.05.06 09:32 
... und der Fehler war?

_________________
Delphi: XE - OS: Windows 7 Professional x64
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Do 18.05.06 09:59 
habe vergessen die karten mit ins spiel einzubauen und dann noch
was bei form create.