0

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?

Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384
Para
  • 1,299
  • 4
  • 11
  • This is a very broad question. – Andreas Rejbrand Aug 27 '21 at 10:20
  • Office applications do not use MDI. Excel only starts once, and then opens multiple child windows, which is why the first one takes so much longer - Excel is starting when you open the first one, and is already running when it creates the child windows for the second and subsequent workbooks. And as @AndreasRejbrand has said, this is a very broad question; you need to do some research on your own, because asking us to tutor you through the whole thing is too much to ask here. There are topics in the Delphi help, as well as online references and tutorials, that should help you get started. – Ken White Aug 28 '21 at 00:50

2 Answers2

2

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.

AmigoJack
  • 5,234
  • 1
  • 15
  • 31
-2

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.

AmigoJack
  • 5,234
  • 1
  • 15
  • 31
fpiette
  • 11,983
  • 1
  • 24
  • 46
  • 2
    First, Office applications do not use MDI. Second, MDI has been outdated for at least two decades, and is only supported for legacy reasons by both Windows and Delphi. Advising anyone now to use MDI is simply poor advice. – Ken White Aug 28 '21 at 00:49
  • @KenWhite I have not advised to use MDI, just MDI style that is a window in which several documents are open. That's not the same and that is what the OP says: *behaves like an MDI application*. – fpiette Aug 28 '21 at 06:19
  • @KenWhite MDI still has its benefits: while many programs nowadays use tabs you have no chance to resize or rearrange any of them, i.e. for laying two side by side and the third on the bottom - only MDI achieves this, because of having windows instead of tabs. Navigation wise I also prefer MDI over any other solution. – AmigoJack Aug 28 '21 at 07:29
  • 2
    Classic Win32 MDI should not be used in new applications, IMHO, mainly because of its poor behaviour on systems with multiple monitors. – Andreas Rejbrand Aug 28 '21 at 13:56