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.
In the current Delphi implementation, I am sure that there are no consequences using a pointer to change Application.MainForm.
If you look into TApplication class, you can see that FMainForm is used only to check if the application has at least one form, and iterates the main loop inside the TApplication.Run method while the FMainForm exists. If you do not want to use a pointer to hack this property, you can implement your own TApplication class, like TMyApplication, copy all the routines inside it and define MainForm property to read and write
It is not possible to change the
Application.MainForm
once it has been assigned. However, you do not need to, either. The simpliest solution to this issue would be to create a blank hiddenTForm
to act as the realApplication.MainForm
and let it manage the taskbar normally, and then you can show/hide any secondaryTForm
objects when needed, where your desired "MainForm" is a secondary form not the realMainForm
.