Dans un thread je crée dynamiquement plusieurs items dans un contener (JvCaptionPanel) qui lui même va se mettre dans un autre contener (ScrollBox).

Le problème vient de l'assignation du parent des items qui vont se loger dans le conterner jvCaptionPanel. Le programme se bloque des que j'assigne un label au JvCaptionPanel.

Ci-dessous le code de création des divers items :


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
 
procedure CreateItems(sName : string);
var
  jvcnPanel : TjvCaptionPanel;
  lblSource : TLabel;
  lblDest   : TLabel;
  lblEtat   : TLabel;
begin
  jvcnPanel := TJvCaptionPanel.Create(frmMain.ScrollBox1);
  With jvcnPanel do
  begin
    Align := alTop;
    CaptionPosition := dpTop;
    Name := 'jvcn' + sName;
    OutlookLook := true;
    Height := 73;
    Parent := frmMain.ScrollBox1;
    Visible := True;
  end;
 
  lblSource := TLabel.Create(frmMain.ScrollBox1.findComponent('jvcn' + sName));
  With lblSource do
  begin
    Left := 8;
    Top := 32;
    Parent := TJvCaptionPanel(frmMain.ScrollBox1.findComponent('jvcn' + sName)); <<----- Bloque ici en pas à pas
    Visible := True;
  end;
 
  lblDest := TLabel.Create(frmMain.ScrollBox1.findComponent('jvcn' + sName));
  With lblDest do
  begin
    Top := 48;
    Left := 8;
    Parent := TJvCaptionPanel(frmMain.ScrollBox1.findComponent('jvcn' + sName));
    Visible := True;
  end;
 
  lblEtat := TLabel.Create(frmMain.ScrollBox1.findComponent('jvcn' + sName));
  With lblEtat do
  begin
    Top := 80;
    Left := 8;
    Name := 'ET' + sName;
    Parent := TJvCaptionPanel(frmMain.ScrollBox1.findComponent('jvcn' + sName));
    Visible := True;
  end;
  Application.ProcessMessages;
 
end;
Si quelqu'un voit d'où vient le problème, je lui en serais reconnaissant ^^