Modality implies lifetime nesting. When one modal form opens another modal form, the first form needs to remain during the entire lifetime of the second modal form.
So, what you need to do is close the first modal form before you show the second modal form. That's a little tricky to do from inside the first modal form so it may be best to ask the main form for help. The main form can:
- Call
Free
on the first modal form.
- Create and show the second modal form.
If the first modal form needs to trigger this from one of its own event handlers, then the best way forward is for the first modal form to queue a message to the main form. For instance with PostMessage
or TThread.Queue
.