Autor Beitrag
Andreas_Sans
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: So 10.08.03 06:09 
Wenn ich die untenstehende Procedure mit
nachclick (transfer,stapel1,stapel2,stapel3,stapel4,stapel5,stapel6,stapel7,welchstapel);
aufrufe, meint er es hätte eine Zugriffsverletzung gegeben. ich weis aber nicht warum, liegt es vielleicht am FindGlobalComponent ?

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:
procedure nachclick (
    var transfer : array of string;
    var stapel1,stapel2,stapel3,stapel4,stapel5,stapel6,stapel7 : array of string
    var welchstapel : string
  );
var i,j : integer;
begin

 if welchstapel = '1' then begin
             for i := 1 to 14 do begin
              for j := 1 to 14 do begin
               if transfer[i] = stapel1[j] then begin
                  tbitbtn(findglobalcomponent('bitbtn'+IntToStr(j))).visible := false;
                  transfer[i] := '';
                                               end;
                                  end;
                                 end;
                           end;

 if welchstapel = '2' then begin
             for i := 1 to 14 do begin
              for j := 1 to 15 do begin
               if transfer[i] = stapel2[j] then begin
                  tbitbtn(findglobalcomponent('bitbtn'+IntToStr(j+14))).visible := false;
                  transfer[i] := '';
                                               end;
                                  end;
                                 end;
                           end;

 if welchstapel = '3' then begin
             for i := 1 to 14 do begin
              for j := 1 to 16 do begin
               if transfer[i] = stapel2[j] then begin
                  tbitbtn(findglobalcomponent('bitbtn'+IntToStr(j+30))).visible := false;
                  transfer[i] := '';
                                               end;
                                  end;
                                 end;
                           end;

 if welchstapel = '4' then begin
             for i := 1 to 14 do begin
              for j := 1 to 17 do begin
               if transfer[i] = stapel2[j] then begin
                  tbitbtn(findglobalcomponent('bitbtn'+IntToStr(j+46))).visible := false;
                  transfer[i] := '';
                                               end;
                                  end;
                                 end;
                           end;

 if welchstapel = '5' then begin
             for i := 1 to 14 do begin
              for j := 1 to 18 do begin
               if transfer[i] = stapel2[j] then begin
                  tbitbtn(findglobalcomponent('bitbtn'+IntToStr(j+62))).visible := false;
                  transfer[i] := '';
                                               end;
                                  end;
                                 end;
                           end;

 if welchstapel = '6' then begin
             for i := 1 to 14 do begin
              for j := 1 to 19 do begin
               if transfer[i] = stapel2[j] then begin
                  tbitbtn(findglobalcomponent('bitbtn'+IntToStr(j+80))).visible := false;
                  transfer[i] := '';
                                               end;
                                  end;
                                 end;
                           end;

 if welchstapel = '7' then begin
             for i := 1 to 14 do begin
              for j := 1 to 18 do begin
               if transfer[i] = stapel2[j] then begin
                  tbitbtn(findglobalcomponent('bitbtn'+IntToStr(j+99))).visible := false;
                  transfer[i] := '';
                                               end;
                                  end;
                                 end;
                           end;

end;
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: So 10.08.03 06:17 
Hi,

benutz mal Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT anstatt FindGlobalComponent.

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Andreas_Sans Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: So 10.08.03 06:33 
wenn ich FindComponent anstatt FindGlobalComponent benutze meint Delphi FindComponent wäre ein undefinierter Bezeichner. Wenn ich den Inhalt der Procedure durch einen Button direkt und mit FindComponent aufrufe funktioniert sie.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 10.08.03 09:09 
findcomponent ist eine Methode von Tform
ausblenden Delphi-Quelltext
1:
TBitBtn (Form1.FindComponent ('bitbtn'+IntToStr(j)))					

oder du nimmst deine nachklick Procedure mit in den private-abschnitt der Form auf. deine Zugriffsverletzung entsteht wahrscheinlich dadurch, das findglobalcomponent NIL liefert und Nil.visible geht nicht. evtl wäre es ratsam, zu prüfen, ob Findcomponent überhaupt ein button gefunden hat.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Andreas_Sans Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76



BeitragVerfasst: So 10.08.03 17:50 
Danke

@ Keldorn : hat mit deinem Vorschlag geklappt