Bonjour,
Je souhaite faire une fenêtre d'attente pendant l'execution d'une requête SELECT qui est un peu longue.
Pour ce faire, j'ai suivi les explications se trouvant dans le tutorial suivant :
http://lberne.developpez.com/delphi/...us_threads.pdf
Mon problème, c'est que la barre de progression n'avance pas...
Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 unit MThreadWait; interface uses Forms, Classes, MWait, SysUtils; type ThreadWait = class(TThread) private { Déclarations privées } FWait : TFWait; procedure OnTerminateProcedure(Sender : TObject); protected procedure Execute; override; public constructor Create(Suspended : Boolean); end; implementation { Important : les méthodes et propriétés des objets de la VCL peuvent uniquement être utilisés dans une méthode appelée en utilisant Synchronize, comme : Synchronize(UpdateCaption); où UpdateCaption serait de la forme procedure ThreadWait.UpdateCaption; begin Form1.Caption := 'Mis à jour dans un thread'; end; } { ThreadWait } procedure ThreadWait.Execute; begin repeat if FWait.JvXPProgressBar1.Position < 100 then FWait.JvXPProgressBar1.Position := FWait.JvXPProgressBar1.Position + 1 else FWait.JvXPProgressBar1.Position := 0; FWait.Refresh; Application.ProcessMessages; until true; end; constructor ThreadWait.Create(Suspended: Boolean); begin FreeOnTerminate := True; inherited Create(Suspended); FWait := TFWait.Create(nil); FWait.Show; OnTerminate := OnTerminateProcedure; end; procedure ThreadWait.OnTerminateProcedure(Sender: TObject); begin if Assigned(FWait) then FWait.Release; end; end.J'ai pourtant bien mis le :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 MyThreadWait := ThreadWait.Create(false); FPrincipale.ClientDataSetRecherche.Active := false; FPrincipale.ClientDataSetRecherche.CommandText := 'SELECT * FROM [...]'; FPrincipale.ClientDataSetRecherche.Active := true; MyThreadWait.Terminate;
Que dois-je faire ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 FWait.Refresh; Application.ProcessMessages;
Merci,
Mathieu
Partager