views:

185

answers:

3

Hi,

I am trying hard to align MDIChild form to the left of the parent MDIForm setting Align:=alLeft at design time. On the Parent MDIForm is toolbar aligned to alTop. Apparently aligned MDIChild is higher than parents client area (I do not know why), that's why vertical scrollbar appears on parent form. The problem is, that I want this form create dynamically; putting vertical Splitter between these MDIchild forms, in order to size them by mouse. But when I create Splitter it aligns itself totally on the left, as if MDIChild form was not aligned (alLeft) at all.

I set MDIChild parameters to:

Align:=alLeft;
Windowstate:=wsNormal; 
Borderstyle:=bsSizable;

Does anybody solved this problem before?

thanx a lot

P.S Delphi 7, Win XP

A: 

MDI children are handled separately from regular nested controls like TSplitter, so things like "Align := alLeft" won't work with them. The MDI area is what's left after all of the other controls are aligned.

Your best bet is to use frames or to place the child form directly on the form without using the MDI support (set Child.Parent := MainForm). If you really want to use the MDI support I think you'll need to write your own TMDISplitter component. You can try creating the TSplitter at runtime using TSplitter.CreateParented(MainForm.ClientHandle), but I doubt it will work.

Craig Peterson
I tried also placing child form directly inside TPanel (alClient), which was nested in Parent form. This good idea crushed on the fact, that TEdit, TMemo ... component ceased to work (I could not write in them) unless borderstyle of child form was bsNone. I am not sure, if it is not dependent on Delphi version. I didnt try to use Frames, so maybe now...
lyborko
I haven't tried it, but I'm not too surprised having the border style wrong causes problems. If you want draggable windows with captions you're going to need to use the MDI support, and that means you'll need to create a new splitter class that knows how to handle MDI windows. It's certainly possible, but Delphi's existing alignment and splitter code won't help.
Craig Peterson
lyborko
Use dockable Forms instead. Using your original TForm approach, call the form's ManualDock() method instead of setting its Parent property. Then, set your parent TPanel's DockSite property to true.
Remy Lebeau - TeamB
Thanx. I tried, but titlebar disapears completely...
lyborko
A: 

If you are using the MDI interface just to put "aligned" forms inside the main form, I suggest you to use other approach, for example, working with main and child fsNormal forms and docking the child inside the parent form (maybe in a panel).

If you're interested, take a look at ManualDock method for the child form's and DockSite property for main form panel(s).

In that case, regular splitters will work well for you.

jachguate
yes, I mentioned that in the last comment... The child forms in Formstyle = fsNormal look like regular panels inside Docked Control. Title bar completely disappears. For unknown reason parented form in the Tpanel works well ONLY when borderstyle:=bsNone. Otherwise it looks pretty like I want, but you can not use TEdit or TMemo or other edit controls...
lyborko
A: 

The solution I found the best is based on combination of TFrame and normal TForm approach. I created all borders, title bar, form buttons and their behavior in TFrame object from various components (TPanel, TButton, TShape). This object I put on the "normal" TForm. I set TForm properties to:

TForm.FormStyle:=fsNormal; TForm.BorderStyle:=bsNone; TForm.WindowState:=wsMaximized;
TForm.Align:=alClient;

and programatically I parented this TForm into container TPanel, which was normal TPanel with alClient property.

lyborko