formsdelphivcltaskbardelphi-xe6

Delphi Change main form while application is running


I have this problem. When I hide my main form, then the taskbar icon of my application is also hidden. I saw a new question about this problem as well and the answers didn't really help. They suggested to minimize it, but I do not want to minimize the application.

Is it possible to change the main form while the application is already running?

for instance. I have two forms. when I want to hide the one form and show the other form, then the taskbar icon should stay at the taskbar and the main form should switch to the other form.

I am using Delphi XE6 and it is a VCL Forms application.

I have also seen a different old question about changing main form while runtime, but it is very old and still based on Delphi 6.


Solution

  • Is it possible to change the main form while the application is already running?

    It is not possible to change the VCL main form whilst the program is running. This property is determined once and for all when the program starts.

    One possible way to proceed for you is to arrange for the secondary form, the form that is not the main form, to have a button on the taskbar. Do that by making it unowned, or by using the WS_EX_APPWINDOW extended window style.

    Update

    Well, you can change Application.MainForm, but it requires you to destroy the current main form, and then create a new one.