I use the following function to show controls on my form:
class procedure TFormMain.FadeControls(ctrl:Array of TwinControl);
var element:TwinControl;
begin
for element in ctrl do
begin
PrepareForAnimation(element);
element.Visible := true;
AnimShowControl(element,250);
end;
end;
However,it slows down with 250 ms on each control so I’d like to put it in a thread.I read a few tutorials about theading in Delphi,but I don’t understand how to create a thread with a parameter? In my case ctrl:Array of TWinControl.
I want to make a thread that does what the function above does,but I don’t understand how to call it with a parameter.Threading in Delphi is harder.
Any help will be appreciated!
Since the Delphi VCL is not threadsafe, you cannot use a thread for your purpose. It’s even worse: Not only is it not threadsafe, you are only allowed to call VCL code from the application’s main thread.
That said, creating a thread in Delphi is as simple as declaring a descendant class of TThread, overriding its Execute method and instantiating it. That was the easy part, everything that follows is the hard part.
Sorry for being not helpful, but without knowing more about the particular control you are using, I have no idea how to solve the issue.