开发者

How to align MDIChild on left?

开发者 https://www.devze.com 2022-12-27 02:03 出处:网络
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

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?

t开发者_StackOverflow中文版hanx a lot

P.S Delphi 7, Win XP


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消