We have a GUI of several frames that build their contents dynamically. Each frame creates panels, labels, edits, comboboxes etc to be used as input fields. This is working very well and we are also planning to let each frame build its content in separate threads.
However there is one big problem: it is rather slow! Creating the controls takes no time but setting the Parent property seems to be very time consuming.
I have tried several ways to speed up the process but with no luck. I have tried Enabled=False, Visible=False, DisableAlign, LockWindowUpdate, WM_SETREDRAW... but nothing seem to affect the time consuming process of setting the Parent of the controls.
Even if we use threads this will take time since the VCL functions must be called within Synchronize.
Is there any other way to speed up the creation and showing of controls?
Kind regards, Magnus
Edit: There are no data aware components or any events triggered in the GUI. I am only creating the controls and displaying them. Using timers I have identified the assignment of controls parent (AControl.Parent := AOwner) as the time consuming part.
Edit 2: As shown in the answer below the speed problem is not setting the parent but the painting of the control. When I tested the timing the container was visible and setting the parent caused immediate painting of the control.
Edit 3: Another time consuming part of our dynamic GUI is assigning items to comboboxes. ComboBox.Items.Assign(DataItems) where DataItems have no more than three to six items.
Thank you all for taking the time helping me!