1

Is there a way to show MDI child forms (FormStyle = fsMDIChild) on the main form that has a frame with Align = alClient?
Creating a frame on the main form:

Frame := TfrCalendar.Create(Self);
Frame.Parent := Self;   

Creating MDI child form on the main form:

if Assigned(FMDIRef)
then
  FMDIRef.BringToFront
else begin
  FMDIRef := TFReference.Create(Application);
  FMDIRef.Show;
end;

After this, the child form is not visible. If you do not create a frame, the form is visible. If you first show the child form, and then create a frame on the main form, then the child form becomes invisible again.

Fabrizio
  • 7,603
  • 6
  • 44
  • 104
LuFang
  • 191
  • 3
  • 12

1 Answers1

5

The issue here is that your frame is competing for space with the MDI client window. The MDI client window is the window which is parent to the MDI child windows.

In your scenario the frame consumes all remaining client area inside the main window, thus leaving no space for the MDI client window.

What you are attempting is not possible. The MDI client window has to go somewhere, and you must leave it some room.

Depending on what your actual goal is, different solutions are available:

  • If the frame is intended to be visible always, then use alTop. The remaining space below it will be available to the MDI client window.
  • If you wish to show an image on the MDI client window to act as a background, refer to my answer here: https://stackoverflow.com/a/15137740/505088
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • The customer of the application wants an MDI interface and an interactive background (grid and buttons) on the main form. I'm in a panic. How to implement it? – LuFang Nov 20 '18 at 08:12
  • 4
    Once the MDI children are showing, the background will be behind and neither use nor ornament. You need to revisit the requirement. – David Heffernan Nov 20 '18 at 08:14
  • 1
    @LuFang you can't use interactive controls on the MDI client window, that area is strictly for MDI child windows. You might be able to do something with custom-painting the MDI client window, but that would be a lot of work to simulate interactive controls. If you can provide a mockup of what you are trying to accomplish, maybe someone can give you ideas on how to approach it differently, than you can take that to your customer. – Remy Lebeau Nov 21 '18 at 10:53
  • Just an idea, but maybe you can put an non-MdiChild window on your mainform, and not parent it but keep it in place using code in resize and move events. Then you can keep using mdi for the other forms. – GuidoG Nov 21 '18 at 10:59
  • 1
    @GuidoG Well you can do this, but that window appears above the MDI child windows, which isn't a whole lot of use. Of course, it's no less useful than UI that is hidden by the child windows. The entire idea is stupid but we have the classic situation of a client telling their hired programmer to do something that cannot work. And the hired programmer, for whatever reason, having to implement something ridiculous. – David Heffernan Nov 21 '18 at 11:06