Re: More mdi fun
"Brian" <[email protected]> Mon, 17 Feb 2003 21:02:35 -0800 (PST)
| Newsgroups | gmane.comp.lang.delphi.kylix |
|---|---|
| Message-ID | <[email protected]> |
This doesn't work when you run it as a clx application...
works just fine as vcl.
>
>
>
>
> Try the following code, is that the way you want?
>
> ======
>
> unit Unit1;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Variants, Classes,
> Graphics, Controls, Forms, Dialogs, Menus;
>
> type
> // main form is the mdi parent window
> TForm1 = class(TForm)
> MainMenu1: TMainMenu;
> Window1: TMenuItem;
> New1: TMenuItem;
> ArrangeHorz1: TMenuItem;
> ArrangeVert1: TMenuItem;
>
> procedure New1Click(Sender: TObject);
> procedure ArrangeHorz1Click(Sender: TObject);
> procedure ArrangeVert1Click(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> {$R *.dfm}
>
> // this unit contains TForm2 as the mdi child form
> uses
> Unit2;
>
> procedure TForm1.New1Click(Sender: TObject);
> var
> Child: TForm2;
> begin
> // create new child form window
> Child := TForm2.Create(Application);
> end;
>
> procedure TForm1.ArrangeHorz1Click(Sender: TObject);
> var
> i: integer;
> FrameWidth: integer;
> begin
> // measure form's frame width
> FrameWidth := (Width - ClientWidth) div 2;
>
> // check if there is childform available
> if MDIChildCount > 0 then
> for i := 0 to MDIChildCount-1 do
> begin
> { arrange form(s) horizontally }
>
> // same top and height
> MDIChildren[i].Top := 0;
> MDIChildren[i].Height := ClientHeight-FrameWidth;
>
> // measure form(s)'s width
> MDIChildren[i].Left := i*((ClientWidth-FrameWidth) div
> MDIChildCount);
> MDIChildren[i].Width := (ClientWidth-FrameWidth) div
> MDIChildCount;
> end;
> end;
>
> procedure TForm1.ArrangeVert1Click(Sender: TObject);
> var
> i: integer;
> FrameWidth: integer;
> begin
> // measure form's frame width
> FrameWidth := (Width - ClientWidth) div 2;
>
> // check if there is childform available
> if MDIChildCount > 0 then
> for i := 0 to MDIChildCount-1 do
> begin
> { arrange form(s) vertically }
>
> // same left and width
> MDIChildren[i].Left := 0;
> MDIChildren[i].Width := ClientWidth-FrameWidth;
>
> // measure form(s)'s height
> MDIChildren[i].Top := i*((ClientHeight-FrameWidth) div
> MDIChildCount);
> MDIChildren[i].Height := (ClientHeight-FrameWidth) div
> MDIChildCount;
> end;
> end;
>
> end.
>
>
> ======
>
> If you place a status bar or any components on mdi parent form which
> reduce the space (height or width) for mdi child form but not decrease
> the parent's ClientHeight/Width value, then you must substract the
> ClientHeight/Width of the parent form with the component's
> Height/Width to get the child form's position correct.
>
> Hope this helps.
>
> -Bee-
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.455 / Virus Database: 255 - Release Date: 13-02-2003
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Sponsor
>
>
> ADVERTISEMENT
>
>
>
>
>
>
>
>
>
> -------------------------------------------------------
> Forum / mailing list for Borland Kylix programmers
> Our web page: http://groups.yahoo.com/group/kylixgroup
> To join the forum: [email protected]
> To unsubscribe: [email protected]
> To post your messages:
> [email protected]
> To contact the moderator: [email protected]
> -------------------------------------------------------
>
>
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/FpY02D/vN2EAA/xGHJAA/i7folB/TM
---------------------------------------------------------------------~->
-------------------------------------------------------
Forum / mailing list for Borland Kylix programmers
Our web page: http://groups.yahoo.com/group/kylixgroup
To join the forum: [email protected]
To unsubscribe: [email protected]
To post your messages: [email protected]
To contact the moderator: [email protected]
-------------------------------------------------------
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/