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

Time:09-17

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?

CodePudding user response:

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.

CodePudding user response:

In Delphi you program one single application. It will have several secondary windows. The main window and the secondary windows shall have an MDI style.

When the application is started, it first looks if a copy of itself is already running. If not, it simply continues; if a previous copy is running, it sends to it the document (filename) that should be opened and then quits. The previously running application will open the passed document in a new secondary window.

This is the overall way of doing it. If there is something you don't know how to do then please open separate questions for each topic.

Please read the help pages, take the SO tour, read How to Ask, as well as this question checklist.

  • Related