Search code examples
delphitaskmanager

How to write a "child" application in Delphi like Office does?


Office 2016 behaves like an MDI application, although it isn't: if you open many files in Taskmgr.exe there is one EXCEL.EXE process running (tab "Details"):

Task Manager details list

But there are multiple entries in the tab "Processes" (which actually lists windows):

Task Manager "processes" (actually windows) list

When I open the first file Excel starts slow. But when I open the second and third file Excel is faster than first.

How to do this in a Delphi program?


Solution

  • Windows' Task Manager unneedingly uses misleading terms to what actually happens:

    • The tab "Processes" actually lists windows for its category "Apps" and either succeeds in listing multiple windows for one process or doesn't. In older versions of Windows the Task Manager listed the windows this way, already having the suspicious tab title "Applications", but without grouping and associating multiple windows to one process:

      Windows 7 Task Manager: window list, tab "Applications"

    • The tab "Details" lists the actual processes that run, unbound to how many windows they have or display. In previous versions this tab was titled "Processes":

      Windows 7 Task Manager: process list, tab "Processes"

    Which situation do we have? One process displaying multiple windows. This can be accomplished easily just like ages ago: you just ensure only running one instance which handles multiple documents. Does not even need to be a true MDI for that.

    What you want on top is, that the Task Manager also groups multiple windows. How does Excel achieve this? Look at your taskbar: for each document a separate button exists, not only one in general for Excel itself. In your Delphi program you must ensure that each window must also appear on the taskbar: How to correctly have modeless form appear in taskbar along with its answer has evaluated many ways of doing so.