les procédures buttonclick - Delphi/Pascal - Programmation
Marsh Posté le 26-04-2005 à 10:10:34
Ça veut dire quoi qu'elle ne fonctionne plus "individuellement" ?
Ce que tu dois passer à la fonction (paramètre Sender) c'est l'objet qui a déclanché l'événement, ou celui sur lequel ça s'applique. Dans ton exemple tu passes la méthode elle-même, j'imagine que c'est une erreur quand t'as recopié le code ici ?
Marsh Posté le 03-05-2005 à 20:28:38
Bonsoir,
C'est exact je le suis trompé dans le code.
Il faut lire button2click(button2)
J'accède bien dans la procédure button1click à la procédure button2click et j'obtiens les résultas désirés.
Mais par après si j'utilise la procédure button2click ,elle reste muette et je n'obtiens plus rien.
J'ai aussi d'autres bizarreries.Je liste un fichier dans une listebox .Tout est ok j'utilise d'autres procédures qui effecent la listebox et voulant lister à nouveau le fichier,il ne se passe plus rien.
Alors ?????? Qjue se p
Marsh Posté le 03-05-2005 à 20:42:02
Il doit y avoir un problème dans ton code, mais je peux pas en dire plus sans le code ou une boule de cristal
Marsh Posté le 04-05-2005 à 11:35:46
Bonjour,
J'ai parlé de ce problème avec d'autres amis et on me dit de réinitialiser les boutons ?????????
Comment faire alors !
Si pas de réponses satisfaisantes j'envoye mon code à antp qui a la gentillesse de me répondre.
Rogerone
Marsh Posté le 04-05-2005 à 12:05:22
T'es pas obligé d'envoyer tout le code, juste poster un exemple de ce qu'il y a dans le onclick de tes boutons.
Je ne vois pas ce qu'ils veulent dire par "réinitialiser"
Marsh Posté le 04-05-2005 à 16:10:52
Bonjour et merci encore
Voici le code de ma procédure paresseuse
Procedure TRésultats.creationclick(Sender:TObject);
Var
nomfich:string;
genre;string[1];
begin
listbox1.clear;
genre:=upprcase(edit33.text
if genre='H' then
nomfich:='c:\tendelphi\exploite\clihom.dta ;
if genre='D' then
nomfich:='c:\tendelphi\exploite\clidam.dta;
assignfile(fichcli,c:\tendelphi\membres\clubadr1.dat);
// ce fichier existe réellement;
{$i-};reset(fichcli);{$i+};
if ioresult<>0 then rewrite(fichcli);
Assignfile(fichjou,nomfich);
{$i-};reset(fichjou);{$i+};
if ioresult<>0 then rewrite(fichjou);
reset(fichccli);reset(fichjou);
while not eof(fichcli) do
begin
Marsh Posté le 04-05-2005 à 16:23:23
Sorry mais j'ai effectué une mauvaise manoeuvre...je continue
begin
read(fichcli,membre);
if genre='H' then
begin
joueur.nom:=membre.nom;
joueur.clt:=membre.cltH;
joueur.pts:=0;
joueur.cat:=genre;
write(fichjou,joueur);
listbox1.items.add(joueur.nom+' 'inttostr(joueur.lf)+' '+joueur.clt+' '+inttostr(joueur.pts+' '+joueur.cat);
end;
// idem pour les Dames
closefile(fichcli);closefile(fichjou);
end;
end;
Je pourrais abréger mes écritures en employant with joueur
mais j'avais commencé avec un mode et je l'ai continué;
Je vous enverrai le code des procédures où je fais appel à une autre qui ne fonctionne pas si on l'appelle par un click sur son bouton
Rogertwo1
Marsh Posté le 04-05-2005 à 16:24:02
Ouais enfin dans ce code-là il n'y a rien qui soit en relation avec les boutons, montre le code où t'appelles l'autre procédure
Marsh Posté le 05-05-2005 à 16:13:42
Bonjour,
Voici deux procédures extraites de mon programme.
La première fait appel à la seconde et tout est ok
Par contre,la seconde ne fonctionne pas si on clique sur le bouton approprié.
L'appel à la seconde est en gras dans le code.
procedure TForm1.EquipeClick(Sender: TObject);
var
maine:string[8];
x,k,l,m,n,p:byte;
y:string[30];
z:string[2];
rue:array[1..4] of string[30];
fl:array[1..4] of byte;
tlc:array[1..4] of string[2];
i,j,h,xx:integer;
bl:string[35];
ligne,ligne1:string;
jou,inlf,hlf,dlf,inld,qui,s,selection:string[3];
didi:string[5];
index:string[7];
CHAINE:string;
fema,fcomp,fvisit:textfile;
begin
AssignFile(Fichclub,'c:\tendelphi\clubs\ClubsRen.dat');
{$i-} ;reset(fichclub);{$i+};
assignfile(fichcal,'c:\tendelphi\calendrier\calend05.dat');
{$i-} ;reset(fichcal); {$i+} ;
if ioresult<>0 then rewrite(fichcal);
assignfile(fema,'c:\tendelphi\documents\fema.txt');rewrite(fema);append(fema);
assignfile(fcomp,'c:\tendelphi\documents\compequi.txt');rewrite(fcomp);append(fcomp);
assignfile(fvisit,'c:\tendelphi\documents\visiteur.txt');rewrite(fvisit);append(fvisit);
assignfile(fichcli,'C:\tendelphi\membres\clubadr1.dat');
{$i-};reset(fichcli);{$i+};
if ioresult<>0 then rewrite(fichcli);
bl:=' ';
maine:=inputbox('Semaine désirée','**/**/**',maine);
ligne1:='EQUIPES en DEPLACEMENT LE ' +' '+maine;
writeln(fcomp,ligne1);
l:=0;i:=0;ligne:='';p:=0 ;
reset(fichcal);
repeat
ligne:='';ligne1:='';
read(fichcal,cal);
if (cal.date_aller=maine) and (cal.nrcluba<>'N130') then
begin
l:=l+1;p:=p+1;
if ((l mod 2<>0) and (l>1)) then writeln(fvisit,'.');
if (l=2) then writeln(fvisit,' ');
if (l>2) and (l mod 2=0) then writeln(fvisit,' ');
write(fvisit,' ',cal.division);
writeln(fvisit,' ',cal.date_aller);
writeln(fvisit,' ');
write(fvisit,' ',cal.hraller);
writeln(fvisit,' ',cal.nraller);
write(fvisit,' ',cal.indeqb ,' rend visite
');
reset(fichclub);
repeat
read(fichclub,rensclub);
until (cal.nrcluba= rensclub.indclub) or (eof(fichclub));
writeln(fvisit,rensclub.nom,' ',cal.indeqa,' ',cal.nrcluba);
writeln(fvisit,' ',rensclub.adrloc,' ',rensclub.loclocal);
writeln(fvisit,' ');writeln(fvisit,' ');writeln(fvisit,' ');
end ;
if (cal.nrcluba='N130') and (cal.date_aller=maine) then
begin
reset(fichclub);p:=p+1;
repeat
read(fichclub,rensclub);
until (cal.nrclubb= rensclub.indclub) or (eof(fichclub));
if copy(cal.division,1,2)<>'DA' then
begin
ligne:=ligne+'X'+' '+'.' ;
end else
begin
ligne:=ligne+'.'+' '+'X';
end;
if copy(cal.division,1,2)<>'DA' then
begin
ligne:=ligne+copy(cal.date_aller+bl,1,8)+' '+copy(cal.nraller+bl,1,8)+' '+
copy(cal.diVision+bl,1,5)+copy(cal.division+bl,6,1)+' '+ cal.hraller+' '+
cal.indeqa+' '+cal.nrclubb+' '+copy(rensclub.nom+bl,1,30)+' '+cal.indeqb+' ';
end else
begin
didi:=(copy(cal.division,3,3)+'.'+copy(cal.division,6,1));
ligne:=ligne+copy(cal.date_aller+bl,1,8)+' '+copy(cal.nraller+bl,1,8)+' '+
didi+copy(cal.division+bl,7,1)+' '+cal.hraller+' '+
cal.indeqa+' '+cal.nrclubb+' '+copy(rensclub.nom+bl,1,30)+' '+cal.indeqb+' ';
end;
end;
if (cal.date_retour=maine) and (cal.nrcluba='N130' ) then
begin
l:=l+1;p:=p+1;
if ((l mod 2<>0) and (l>1)) then writeln(fvisit,'.');
if (l=2) then writeln(fvisit,' ');
if (l>2) and (l mod 2=0) then writeln(fvisit,' ');
write(fvisit,' ',cal.division);
writeln(fvisit,' ',cal.date_retour);
writeln(fvisit,' ');
write(fvisit,' ',cal.hrretour);
writeln(fvisit,' ',cal.nrretour);
write(fvisit,' ',cal.indeqa ,' rend visite
: ');
reset(fichclub);
repeat
read(fichclub,rensclub);
until (cal.nrclubb= rensclub.indclub) or (eof(fichclub));
writeln(fvisit,rensclub.nom,' ',cal.indeqb,' ',cal.nrclubb);
writeln(fvisit,' ',rensclub.adrloc,' ',rensclub.loclocal);
writeln(fvisit,' ');writeln(fvisit,' ');writeln(fvisit,' ');
end ;
if (cal.nrclubb='N130') and (cal.date_retour=maine) then
begin
reset(fichclub);p:=p+1;
repeat
read(fichclub,rensclub);
until (cal.nrcluba= rensclub.indclub) or (eof(fichclub));
if copy(cal.division,1,2)<>'DA' then
begin
ligne:=ligne+'X'+' '+'.' ;
end else
begin
ligne:=ligne+'.'+' '+'X';
end;
if copy(cal.division,1,2)<>'DA' then
begin
ligne:=ligne+copy(cal.date_retour+bl,1,8)+' '+copy(cal.nrretour+bl,1,8)+' '+
copy(cal.division,1,5)+copy(cal.division,6,1)+' '+cal.hrretour+' ';
end else
begin
didi:=(copy(cal.division+bl,3,3)+'.'+copy(cal.division+bl,6,1));
ligne:=ligne+copy(cal.date_retour+bl,1,8)+' '+copy(cal.nrretour+bl,1,8)+' '+
didi+copy(cal.division,7,1)+' '+cal.hrretour+' ';
end;
if cal.nrclubb='N130' then
begin
reset(fichclub);
repeat
read(fichclub,rensclub);
until (rensclub.indclub=cal.nrcluba) or (eof(fichclub));
ligne:=ligne+cal.indeqb+' '+cal.nrcluba+' '+copy(rensclub.nom+bl,1,30)+' '+cal.indeqa+' ';
end else
begin
write(fvisit,' ',cal.indeqa,' rend visite
: ');
reset(fichclub);
repeat
read(fichclub,rensclub);
until (cal.nrclubb=rensclub.indclub) or (eof(fichclub));
writeln(fvisit,rensclub.nom,' ',cal.indeqb,' ',cal.nrclubb);
writeln(fvisit,' ',rensclub.adrloc,' ',rensclub.loclocal);
writeln(fvisit,chr(10));writeln(fvisit,chr(10));
end;
end;
if (cal.date_aller=maine) or (cal.date_retour=maine) then
begin
for i:=1 to 4 do
begin
rue[i]:='';tlc[i]:='';fl[i]:=0;
end;
if ((cal.nrcluba='N130') and (cal.date_aller=maine) )
or ((cal.nrclubb='N130') and (cal.date_retour=maine)) then
begin
if copy(cal.division,1,2)<>'DA' then n:=4 else n:=3;
listbox2.items.add(chr(64+p));
For i:=1 to n do
begin
showmessage('joueur'+' '+inttostr(i)+' '+chr(64+p));
selection:=inputbox('Joueurs','3 lettres',selection);
selection:=uppercase(selection);EDIT1.Text:=selection;
joueurclick(joueur);
jou:=inputbox('Sélect N° Items','de 0 à ...',jou);
listbox1.Items.move(strtoint(jou),0);
chaine:=listbox1.items[listbox1.itemIndex];
reset(fichcli);
qui:=copy(chaine,1,3);
xx:=strtoint(qui);
seek(fichcli,xx);
read(fichcli,membre);
rue[i]:=membre.nom;
if copy(cal.division,1,2)<>'DA' then
begin
tlc[i]:=membre.clth;
fl[i]:=membre.lfh;
end else
begin
tlc[i]:=membre.cltd;
fl[i]:=membre.lfd;
end;
listbox2.items.add(membre.nom+' '+membre.clth);
if p mod 5 =0 then listbox2.Clear;
end;
for i:=1 to n-1 do
begin
for j:=i+1 to n do
begin
if tlc[j]<tlc[i] then
begin
x:=fl[i];fl[i]:=fl[j];fl[j]:=x;
y:=rue[i];rue[i]:=rue[j];rue[j]:=y;
z:=tlc[i];tlc[i]:=tlc[j];tlc[j]:=z;
end;
end;
end;
for i:=1 to n do
begin
str(fl[i],hlf);
index:=copy(hlf+bl,1,3);
ligne:=ligne+copy(rue[i]+bl,1,30)+' '+tlc[i]+' '+copy(index+bl,1,3);
end;
writeln(fema,ligne);flush(fema);
end else
begin
if cal.nrcluba='N130' then
begin
ligne1:='Equipe '+' '+cal.indeqa;
end else
begin
ligne1:='Equipe '+' '+cal.indeqb;
end;
writeln(fcomp,ligne1);ligne1:='';
if copy(cal.division,1,2)<>'DA' then n:=4 else n:=3;
listbox2.items.add(chr(64+p));
For i:=1 to n do
begin
showmessage('joueur'+' '+inttostr(i)+' '+chr(64+p));
selection:=inputbox('Joueurs','3 lettres',selection);
selection:=uppercase(selection);EDIT1.Text:=selection;
joueurclick(joueur);
jou:=inputbox('Sélect N° Items','de 0 à ...',jou);
listbox1.Items.move(strtoint(jou),0);
chaine:=listbox1.items[listbox1.itemIndex];
qui:=copy(chaine,1,3);
xx:=strtoint(qui);
reset(fichcli);
seek(fichcli,xx);
read(fichcli,membre);
rue[i]:=membre.nom;
if copy(cal.division,1,2)<>'DA' then
begin
tlc[i]:=membre.clth;
fl[i]:=membre.lfh;
end else
begin
tlc[i]:=membre.cltd;
fl[i]:=membre.lfd;
end;
listbox2.items.add(membre.nom+' '+membre.clth);
if p mod 5 =0 then listbox2.Clear;
end;
for i:=1 to n-1 do
begin
for j:=i+1 to n do
begin
if tlc[j]<tlc[i] then
begin
x:=fl[i];fl[i]:=fl[j];fl[j]:=x;
y:=rue[i];rue[i]:=rue[j];rue[j]:=y;
z:=tlc[i];tlc[i]:=tlc[j];tlc[j]:=z;
end;
end;
end;
for i:=1 to n do
begin
writeln(fvisit,' ',copy(rue[i]+bl,1,30),
tlc[i],' ',fl[i]);
writeln(fvisit,chr(10));
str(fl[i],hlf);
ligne1:=ligne1+' '+copy(rue[i]+bl,1,30)+' '+ copy(tlc[i]+bl,1,2)+' '
+copy(hlf+bl,1,3);
end;
writeln(fcomp,ligne1);flush(fcomp);
if n=3 then
begin
writeln(fvisit,chr(10));writeln(fvisit,chr(10));
end;
if (l mod 2=1) then
begin
writeln(fvisit,chr(10));writeln(fvisit,chr(10));
writeln(fvisit,' ');writeln(fvisit,chr(10));
writeln(fvisit,chr(10));writeln(fvisit,' ');writeln(fvisit,chr(10));
end;
if l mod 2=0 then writeln(fvisit,chr(12));
end;
end;
until (eof(fichcal)) or (p=27);
closefile(fcomp);closefile(fema); closefile(fvisit);
end;
procedure TForm1.joueurClick(Sender: TObject);
var
i,x:integer;
s,jou:string;
begin
assignfile(fichcli,'C:\tendelphi\membres\clubadr1.dat');
{$i-};reset(fichcli);{$i+};
if ioresult<>0 then rewrite(fichcli);
reset(fichcli);
i:=-1;
listbox1.clear;
while not eof(fichcli)do
begin
read(fichcli,membre);
i:=i+1;
if copy(membre.nom,1,length(edit1.text))=edit1.text then
begin
IF I<10 then
begin
str(i,s);
s:='00'+inttostr(i);
end;
if (i<100) and (i>9) then
begin
str(i,s);
s:='0'+inttostr(i);
end;
if i>99 then str(i,s);
listbox1.items.Add(s+' '+membre.nom+' '+membre.cltH+' '+inttostr(membre.lfh));
end;
end;
end;
Merci de votre patience
rogertwo1
Marsh Posté le 05-05-2005 à 16:31:20
rogertwo1 a écrit : |
Seulement après appel de la 1e ou bien elle ne marche jamais ?
Marsh Posté le 05-05-2005 à 18:51:20
Bonsoir,
Elle ne marche jamais SAUF SI je la réécris avec un autre titre et évidemment avec une autre bouton.
Bonne soirée
Rogertwo1
Marsh Posté le 05-05-2005 à 18:54:15
C'est pas par hasard juste qu'elle a disparu du OnClick du bouton ?
Marsh Posté le 26-04-2005 à 09:12:28
Bonjour,
J'ai créé deux procédures Buttonclick (button1click et button2click)
qui fonctionnent parfaitement.
Dans l'évolution de mon programme j'ai du faire appel à la procédure butto2click au sein de la procédure button1click par l'instruction :
button2click(button2click);
ce qui foctionne parfaitement.
Le problème c'est que dès lors ma procédure button2click ne fonctionne plus ,disons individuellement !
Je l'ai reopiée sous un autre nom et alors cette nouvelle procédure fonctionne parfaitement.
Où est le problème ?
Merci de me renseigner
rogertwo1