Hello!

There is a program that starts to connect to the database. I use firemonkey. Connection takes place in a separate stream, so that the main one would not wait in case of unsuccessful (long) connection. After a successful connection in the TSQLConnection procedure - SQLConnection1AfterConnect , the label text is changed to "Online" and the GlowEffect and placed in the label container and the color changes to green.

Science fiction begins in the SQLConnection1AfterConnect procedure. Sometimes the text of the label 'does not change, sometimes the GlowEffect is not created, sometimes the GowEffect is created, but without the green color, sometimes it is created with the green color (as it should). But after I do Hide , and then Show this window, then everything becomes as it should! Label changes the text to the correct, GlowEffect 'color and becomes what you need.

I just don’t understand how it works here and what is happening. OnShow window OnShow disappeared ...

 procedure TForm1.SQLConnection1AfterConnect(Sender: TObject); begin label1.Text:='В сети'; ConnectionGlowEffect:= TGlowEffect.Create(Form1); ConnectionGlowEffect.Parent:=label1; (label1.Children[1] AS TGlowEffect).GlowColor:=claChartreuse; (label1.Children[1] AS TGlowEffect).Enabled:=true; end; 
  • magic port monkey - teanYCH
  • you can get the XE3 and see how things are going there. They say there are a lot of things fixed, especially in FireMonkey - teanYCH
  • The call to SQLConnection1.Open from the stream through the Synchronize () procedure helped. BUT! If you do not use threads and call everything sequentially, then an ACCESS VIOLATION error occurs! It looks like the object has not been created yet! If you add the check "if assigned (ConnectionGlowEffect)", it returns FALSE ..... - Alez
  • In delphi XE3 beta, if you use the second stream, it works with and without synchronization. But if you consistently call everything, then again it does not work, although the error is different now - the exception situation is "argument out of range". Occurs when trying to change the color of the glow. - Alez


1 answer 1

The form is not fully initialized, by the time of working with Label. Get started when the window is shown, if you want effects and fire shows.