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
| EnvoiPDFThread = class(TThread)
private
etat: string;
index: integer;
procedure RemoveLine(StrGrid: TStringGrid; Row: Integer);
procedure effaceLigne;
procedure majEtat;
{ Déclarations privées }
protected
procedure Execute; override;
procedure envoie1PDF(sendID: integer);
public
constructor Create;
end;
constructor EnvoiPDFThread.Create;
begin
inherited Create(true); //créé suspendu
etat := 'En attente';
//Détruire à la sortie
FreeOnTerminate := True;
end;
procedure EnvoiPDFThread.Execute;
begin
while true do
begin
//boucle sur les fichiers PDF
//quand trouve un fichier, l'envoyer !
envoie1PDF(identifiant_du_fichier);
if y''a plus de PDF then
begin //cache le StringGrid sur le formulaire
main.FicMain.panelKiContientLeGrid.visible := false; //<--- ça marche !
suspend;
end;
end;
end;
procedure EnvoiPDFThread.envoie1PDF(sendID: integer);
begin
//recherche sa ligne dans le StringGrid
//on obtient alors index = 0 <- première ligne, 1 <- 2e ligne...
index := 0;
etat := 'Traitement en cours...';
Synchronize(majEtat);
//...
etat := 'Envoi...';
Synchronize(majEtat);
//...
etat := 'OK';
Synchronize(majEtat);
sleep(500); //Juste le temps de voir que c''est OK
Synchronize(effaceLigne); //efface la ligne du string grid
end;
procedure EnvoiPDFThread.majEtat;
(* met à jour l'état de la ligne en cours *)
begin
main.FicMain.envois.cells[index, 2] := etat;
main.FicMain.envois.Update;
end; |
Partager