Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to allow Delphi secondary forms behind the main form

If in Delphi 2010 or XE Application.MainFormOnTaskbar is set to true then all secondary forms are always in front of the main window. It does not matter what the Popupmode or PopupParent properties are set to. However I have secondary windows that I want to be able to show behind the the main form.

If I set MainFormOnTaskbar to false it works, but then the Windows 7 features are broken (Alt-tab, Windows bar icon, etc).

How can I keep the Windows 7 features working while still allowing secondary forms to hide behind the main form?

like image 228
Jan Derk Avatar asked Nov 22 '10 00:11

Jan Derk


People also ask

How do I show another form in Delphi?

Start a new project, and add one additional form (Delphi IDE Main menu: File -> New -> Form). This new form will have a 'Form2' name. Next add a TButton (Name: 'Button1') to the main form (Form1), double-click the new button and enter the following code: procedure TForm1.

How do you make a main form in Delphi?

To assign a different form to the MainForm property, select the form on the Project > Options > Forms dialog box at design time. MainForm cannot be modified at run time (it is read-only at run time). Note: By default, the form created by the first call to CreateForm in a project becomes the application's main form.

How do you hide a form in Delphi?

Application->ShowMainForm = false; Note: You can set the form's Visible property to False using the Object Inspector at design time rather than setting it at run-time as in the previous example.


1 Answers

Basically you can't. The whole point of MainFormOnTaskBar is to have Vista compatibility. If you don't set it, compatibility is gone.., if you set it, z-order is done. The following excerpt is from D2007's readme:

The property controls how Window's TaskBar buttons are handled by VCL. This property can be applied to older applications, but it affects the Z-order of your MainForm, so you should ensure that you have no dependencies on the old behavior.


But see this QC report, which describes the exact same problem (and closed as AsDesigned). The report states a workaround involving overriding CreateParams of a form to set the WndParent to '0'. It also describes a few problems which this workaround causes and a possible workaround for those problems too. Beware, it wouldn't be easy/possible to find and workaround all complications. See Steve Trefethen's article to have a feeling of what could be involved.

like image 77
Sertac Akyuz Avatar answered Oct 01 '22 20:10

Sertac Akyuz