In Delphi 2007, one of the changes we made in VCL was to provide better support for Window Vista, particularly in relation to window animations which occur when your application is minimized, restored or closed. Nathanial Woolls has a good write-up on some of the related issues.
Ok, I’d like to back up a little bit and explain why Delphi works this way in the first place. When Delphi first came out it used multiple free floating windows that all worked in concert with one another where the “main” window contained the menus and toolbars. When you minimized the main window the rest of the IDE’s windows disappeared and likewise when you restored they all came back. Well, that functionality doesn’t exactly come for free. There is a fair amount of code to try and make multi-window VCL applications behave like single window applications with regard to min/max/restore operations. Of course, this was well before Windows 95 and the taskbar which introduces additional complications.
The primary issue at hand is that the TApplication object has a hidden window used to deal with a lot of these operations although it wasn’t perfect either. In Delphi 2007, there is a new TApplication property called MainFormOnTaskbar that’s documented in the readme.txt (as it came in too late for formal documentation). The readme states:
“Delphi 2007 adds a new
property to TApplication called MainFormOnTaskBar. It
defaults to True for new Delphi 2007 applications and False for existing ones. The
property controls several aspects of how VCL applications perform with regard
to minimize/maximize/restore operations in Windows. Be aware that it will
affect the Z-order of your MainForm, in the event your applications depend on
the old behavior. MainFormOnTaskBar is intended to be set at startup and
persist throughout the duration of the application, changing this property at
runtime could result in unexpected behavior. The major reason for this change
was to better support several new features available on Windows Vista’s
Aero Theme. To update existing VCL applications, add the following line to the
project’s .dpr after “Application.Initialize;”:
Application.MainFormOnTaskbar := True;
Basically, what this property does is change the use of the TApplication hidden window and favor’s the MainForm’s window handle. This introduced a number of subtle changes like those mentioned above. Unfortunately, even prior to RTM we identified a few more issues and we’re actively investigating those now. I’ve seen a few posts on the public newsgroups like this and this which we are very much aware of. In the case of BDS 2006 minimizing the IDE should restore its taskbar button since Delphi 2007 replaces the VCL100.bpl package used by BDS 2006.
What you need to know
We’re working on identifying and fixing issues related to this property. In fact, Seppy has a spreadsheet that identifying 32 (at last count) scenarios and combinations thereof including things like MainFormOnTaskBar, ShowMainForm, programmatically setting Form.Visible, changing Visible in OnShow/OnCreate, changing Visible with a timer and Taskbar icons which we’ll continue to augment as we go. So, this isn’t the end of the MainFormOnTaskbar story.
Lastly, while this is a new property for Delphi 2007 it was added in a non-interface breaking manner just so we’re clear.
In case you missed, I’m currently on vacation and will follow-up next week.