Hello!

Whether prompt, please, it is possible to make so that in a delph operations were fulfilled simultaneously? I have the following code:

TForm4.TreeView1DblClick(Sender: TObject); begin if TreeView1.Items.Item[0].Selected=True then Form2.Show; if TreeView1.Items.Item[1].Selected=True then Form3.Show; if TreeView1.Items.Item[3].Selected=True then begin Form4.Label4.Caption:='1234567'; Form4.Show; end; if TreeView1.Items.Item[4].Selected=True then ListBox1.Items.LoadFromFile('21.txt'); if TreeView1.Items.Item[5].Selected=True then ListBox1.Items.LoadFromFile('22.txt'); if TreeView1.Items.Item[6].Selected=True then ListBox1.Items.LoadFromFile('23.txt'); if TreeView1.Items.Item[7].Selected=True then ListBox1.Items.LoadFromFile('24.txt'); if TreeView1.Items.Item[8].Selected=True then ListBox1.Items.LoadFromFile('25.txt'); end; 

It is necessary for me that when I click on the branch with the index 3, the form was shown and the text on the form was entered immediately. And it does not work right away. First, a form appears, and if you click on a branch again, a label will appear with an inscription. And it is necessary that this happens immediately. Anyone know how?

  • Not the fact that it works, but you can try in the reverse order: Form4.Show; Form4.Label4.Caption: = '1234567'; - insolor
  • There was such a thought. I tried. Does not work ((( - Margarita
  • Not sure if it is worth using additional streams for this, but I will ask just in case - have you tried? - teanYCH
  • one
    @ teanYCH, it’s hardly so severe. The only problem is that one of the sequential operations "does not want" to be executed. - insolor
  • I did not try, but I also think that it should be easier. I have so many bloat for one course. They are consistently executed. In parallel, they do not want. You can, of course, get around this, make a button and display it calmly by a button. But this is already a matter of principle)) - Margaret

2 answers 2

You can try writing in Label when onShow an onShow event ... And what exactly is it to write to a global variable? Or const save ...

  • Yes, I tried everything. And in OnShow tried. Does not exceed. I thought maybe there is some kind of team that I don’t know or a special function - Margarita
  • Doesn't OnActivate roll too? Or OnPaint? .. - mike_live
  • mike_live! Thank! It helped! - Margarita

Try changing the logic a bit, it will turn out:

 TForm4.TreeView1DblClick(Sender: TObject); var LabelCaption: boolean; begin LabelCaption:= False; if TreeView1.Items.Item[0].Selected=True then Form2.Show; if TreeView1.Items.Item[1].Selected=True then Form3.Show; if TreeView1.Items.Item[3].Selected=True then begin LabelCaption:= True; Form4.Show; end; if TreeView1.Items.Item[4].Selected=True then ListBox1.Items.LoadFromFile('21.txt'); if TreeView1.Items.Item[5].Selected=True then ListBox1.Items.LoadFromFile('22.txt'); if TreeView1.Items.Item[6].Selected=True then ListBox1.Items.LoadFromFile('23.txt'); if TreeView1.Items.Item[7].Selected=True then ListBox1.Items.LoadFromFile('24.txt'); if TreeView1.Items.Item[8].Selected=True then ListBox1.Items.LoadFromFile('25.txt'); if LabelCaption then Form4.Label4.Caption:='1234567'; end;