Not quite sure I understand your question. The best way, generally, to wait for something to happen is with await() if possible. So if there is a function or procedure defined with the [async] attribute, you can use await to call it and then continue on from there.
Another less desirable approach is to just use a TWebTimer. The general idea is something like this.
- Add a TWebTimer to your form. Call it, say, tmrFormCreation or something.
- Set a short interval, like 50ms.
- Set it to disabled by default.
- Call whatever procedures or functions that you want executed.
- Enable tmrFormCreation.
In tmrFormCreation's OnTimer event, you do something like the following.
- Check if what you're waiting for is ready. Like, do all the forms exist (are they assigned?) or has each form set some value in your main form that you can use to confirm that the thing your waiting for is ready? This check should be very quick and simple if possible. Maybe the forms load data, so you can set a flag once you've loaded the data.
- If it is ready, then disable the timer and then call whatever you want to do next.
- If it is not ready, then do nothing - the timer will fire again in 50ms and check if it is ready again.
This is kind of a busy-wait solution, which you don't particularly want to do. But if you set the timer to something reasonably closely matched to how long the wait actually is, then it works pretty well. What I mean is, as long as the event isn't firing hundreds of times, and as long as the check that it performs is only a few operations (like checking if something is assigned, or if an integer value is non-zero or something) then it works pretty well and is mostly harmless.
So in your code, the Timer would be checking for the existance of the forms created in TfrmMain, and if they've all been created, then it would call frmMenuOrd.Call_MenuOrd(). It might be that in the AfterCreate is where you first enable the timer.
In your frmMain WebFormCreate, you could add another AfterCreate procedure in the same way that you have in frmLogin, and it could just update a counter in that form. So the timer just checks if counter=4, and if it does, it disables the timer and then calls frmMenuOrd.Call_MenuOrd(). For example.