14

I currently have an SDI application that is build with Delphi 7, I want the final user to choose the type of interface between SDI and MDI at runtime. my question is how can I change the behavior of the application between SDI and MDI at runtime?

Currently I know a couple of applications build with delphi that allow this: EMS SQL Manager and TOAD.

alt text

thanks in advance.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Salvador
  • 16,132
  • 33
  • 143
  • 245

4 Answers4

7

Download the Jedi JVCL and install it and look at the Demos for JvDocking "docking in code". They do this exactly.

They mean that you do not actually use the FormStyle=fsMDIChild unless you want lots of problems. MDI is "emulated" when you need it by docking in code.

Do not convert windows into frames. This is a bad solution.

For an MDI-like environment, that does not have the MDI problems, use a docking solution (components either commercial or open source that support docking). I use JvDocking which is included in the JEDI JVCL, which is free and open source.

You use your forms in both "docked" and "undocked" (floating) modes, and this gives you a docked IDE look and feel (VIsual Studio and RAD Studio), and an undocked IDE Look and feel (RAD Studio in undocked, or classic delphi 7).

Warren P
  • 65,725
  • 40
  • 181
  • 316
4

I would convert my current windows into frames and put these frames with align=alClient into either mdi child windows or normal windows as configured.

But beware: I have never actually done this, so there might be problems that I don't know about.

dummzeuch
  • 10,975
  • 4
  • 51
  • 158
  • 3
    You don't need to convert anything. You can put the FOrms onto your windows without changing them into frames, using TForm.ManualDock. – Warren P Jan 29 '10 at 21:53
2

At runtime set TForm.FormStyle either to fsNormal or fsMDIChild depending on if you want SDI or MDI.

Lars Truijens
  • 42,837
  • 6
  • 126
  • 143
  • 2
    "real MDI" is bad news. see http://stackoverflow.com/questions/1463221/delphi-mdi-vs-tabs-for-multi-document-interface – Warren P Jan 29 '10 at 21:54
  • 1
    @WarrenP: I'm sorry if you do not like MDI, but it is an valid answer to this question – Lars Truijens Jan 29 '10 at 23:18
  • 1
    It's NOTHING to do with NOT LIKING it. It has BAD usability problems. see the link. Today's users have multi-monitor systems, and MDI is just not a good fit any more. Docking allows all the advantages of MDI without it's disadvantages. Not caring about usability doesn't make it "like or not like". It's users I care about. user experience matters. Also, MDI is full of glitches. – Warren P Apr 07 '11 at 01:56
1

Like @WarrenP's solution, I strongly recommend a docking-based solution. It should be said that you don't need to use Jedi VCL to achieve this. As an example, here's a very simple (all-native-vcl) component I've produced which allows you to simply drop on as many instances to your form(s) and set their alignment to enable docking (and tabbed docking) in those regions.

MDI itself is an accident waiting for a place to happen. There are solutions available to achieve the "MDI look and feel" without using MDI itself, though I've yet to encounter one I'd consider "neat" (probably for a lack of looking).

Ultimately you should probably question the wisdom in providing MDI as an option. Docking (with or without the ability to undock, and especially when Tabbed Docking is a user-determined choice) feels more modern, and (done properly) can be far more flexible and intuitive than MDI ever was.

Just my 2-pence worth.

LaKraven
  • 5,804
  • 2
  • 23
  • 49