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
|
Procedure FichePrincipale.TraitementLong;
Begin
...
Pt_Enreg := Point(0,Query.RecordCount)
Fiche_Attendez_Creation(Self,"Comptage des voix en cours...",0,Nbr_Enreg)
While Not Query.Eof Do
Begin
Inc(Pt_Enreg.X);
....
If Fiche_Attendez_MAJ_ArretDemander(Pt_Enreg.X)
Then Begin
//Arret demandez par utilisateur
Break;
End;
Query.Next;
End
Fiche_Attendez_Detruire;
...
End;
//
Fiche_Attendez_Creation(Form:TForm;Msg:String;Indice_Depart,Indice_Max:Integer);
Begin
Fiche_Attendez := TFiche_Attendez.Create(Application);
Fiche_Attendez.Init(Form,Msg,Indice_depart,Indice_Max);
End;
Procedure Fiche_Attendez.Init(Form:TForm;Msg:String;Indice_Depart,Indice_Max:Integer);
Begin
Desactiver_Composants_Fiche(Form);//Utilise GetControls pour mettre à Enabled := False, les principaux controls(boutton,checkbox,ListBox,TEdit,...) mais sauvegarde leur etat avant
Lbl_Msg.Caption := Msg;
Gauge.MinValue := 0;
Gauge.Progress := Indice_Min;
Gauge.MaxValue := Indice_Max;
Show;
End;
Procedure Fiche_Attendez.Bt_PauseClick()
Begin
MsgBox("Pause demandée...");//Cette fenetre etant modale, on attends que l'utilisateur appuye sur Ok, puis le traitement reprendra
End;
Procedure Fiche_Attendez.Bt_StopClick()
Begin
Bt_Stop.Tag := 1;
End;
Fonction Fiche_Attendez_MAJ_ArretDemander(Indice_Progress:Integer):Boolean;
Begin
if Fiche_Attendez = Nil Then Exit
With Fiche_Attendez Do
Begin
Gauge.Progress := Indice_Progress;
If Bt_Stop.Tag = 1
Then Begin
Return := True;
//Le bouton Stop a ete pressé
End;
Else return := False
End;
End; |
Partager