My application has many many mdi forms and they are created after successfull user login. How can I best hide this creation process? It looks stupid and it takes longer time while mdi forms are painted after new form is created and so on.
So far I have used LockWindowUpdate, which doesn’t hide everything, but I would like to use a splash screen showing the creation progress, but I can’t with LockWindowUpdate.
Best Regards
Janne
To create MDI child forms invisible you set their
Visibleproperty toFalse, and in addition you have to disable the VCL behaviour of force-showing them during creation. This happens by theFormStyleproperty setter ofTCustomForm, which setsVisibletoTruefor MDI child forms.If you set the
FormStylein the object inspector, then the property setter will be called during form creation already, and the form will not be shown immediately, but only after the construction is complete. This allows you to reset the request to show the form, by overriding theAfterConstruction()method like so:This will create an invisible MDI child form.
To test this you can create a new MDI application in the IDE, override the method in the child form class like shown above, and simulate a long initialization:
Without the overridden
AfterConstruction()method it will create and show a MDI child every half second. With the overridden method it will show them all after a busy period of 5 seconds, which will give you the chance to show your splash screen instead.Important:
Using
LockWindowUpdate()to reduce flicker or suppress any screen output is wrong, wrong, wrong. Don’t do it, read the series of Raymond Chen articles on the topic to understand why that is so.