Re: More mdi fun

"Brian" <[email protected]> Mon, 17 Feb 2003 21:04:15 -0800 (PST)
Newsgroups gmane.comp.lang.delphi.kylix
Message-ID <[email protected]>
rather, I meant to say when using this code with clx (qt)
top and left seem to adjust the inside of the child window...

like in http://kychat.sourceforge.net/after_tile.png

>
>
>
>
> Try the following code, is that the way you want?
>
> ======
>
> unit Unit1;
>
> interface
>
> uses
> &nbsp; Windows, Messages, SysUtils, Variants, Classes,
> &nbsp; Graphics, Controls, Forms, Dialogs, Menus;
>
> type
> &nbsp; // main form is the mdi parent window
> &nbsp; TForm1 = class(TForm)
> &nbsp;&nbsp;&nbsp; MainMenu1: TMainMenu;
> &nbsp;&nbsp;&nbsp; Window1: TMenuItem;
> &nbsp;&nbsp;&nbsp; New1: TMenuItem;
> &nbsp;&nbsp;&nbsp; ArrangeHorz1: TMenuItem;
> &nbsp;&nbsp;&nbsp; ArrangeVert1: TMenuItem;
>
> &nbsp;&nbsp;&nbsp; procedure New1Click(Sender: TObject);
> &nbsp;&nbsp;&nbsp; procedure ArrangeHorz1Click(Sender: TObject);
> &nbsp;&nbsp;&nbsp; procedure ArrangeVert1Click(Sender: TObject);
> &nbsp; private
> &nbsp;&nbsp;&nbsp; { Private declarations }
> &nbsp; public
> &nbsp;&nbsp;&nbsp; { Public declarations }
> &nbsp; end;
>
> var
> &nbsp; Form1: TForm1;
>
> implementation
>
> {$R *.dfm}
>
> // this unit contains TForm2 as the mdi child form
> uses
> &nbsp; Unit2;
>
> procedure TForm1.New1Click(Sender: TObject);
> var
> &nbsp; Child: TForm2;
> begin
> &nbsp; // create new child form window
> &nbsp; Child := TForm2.Create(Application);
> end;
>
> procedure TForm1.ArrangeHorz1Click(Sender: TObject);
> var
> &nbsp; i: integer;
> &nbsp; FrameWidth: integer;
> begin
> &nbsp; // measure form's frame width
> &nbsp; FrameWidth := (Width - ClientWidth) div 2;
>
> &nbsp; // check if there is childform available
> &nbsp; if MDIChildCount &gt; 0 then
> &nbsp; for i := 0 to MDIChildCount-1 do
> &nbsp; begin
> &nbsp;&nbsp;&nbsp; { arrange form(s) horizontally }
>
> &nbsp;&nbsp;&nbsp; // same top and height
> &nbsp;&nbsp;&nbsp; MDIChildren[i].Top := 0;
> &nbsp;&nbsp;&nbsp; MDIChildren[i].Height := ClientHeight-FrameWidth;
>
> &nbsp;&nbsp;&nbsp; // measure form(s)'s width
> &nbsp;&nbsp;&nbsp; MDIChildren[i].Left := i*((ClientWidth-FrameWidth) div
> MDIChildCount);
> &nbsp;&nbsp;&nbsp; MDIChildren[i].Width := (ClientWidth-FrameWidth) div
> MDIChildCount;
> &nbsp; end;
> end;
>
> procedure TForm1.ArrangeVert1Click(Sender: TObject);
> var
> &nbsp; i: integer;
> &nbsp; FrameWidth: integer;
> begin
> &nbsp; // measure form's frame width
> &nbsp; FrameWidth := (Width - ClientWidth) div 2;
>
> &nbsp; // check if there is childform available
> &nbsp; if MDIChildCount &gt; 0 then
> &nbsp; for i := 0 to MDIChildCount-1 do
> &nbsp; begin
> &nbsp;&nbsp;&nbsp; { arrange form(s) vertically }
>
> &nbsp;&nbsp;&nbsp; // same left and width
> &nbsp;&nbsp;&nbsp; MDIChildren[i].Left := 0;
> &nbsp;&nbsp;&nbsp; MDIChildren[i].Width := ClientWidth-FrameWidth;
>
> &nbsp;&nbsp;&nbsp; // measure form(s)'s height
> &nbsp;&nbsp;&nbsp; MDIChildren[i].Top := i*((ClientHeight-FrameWidth) div
> MDIChildCount);
> &nbsp;&nbsp;&nbsp; MDIChildren[i].Height := (ClientHeight-FrameWidth) div
> MDIChildCount;
> &nbsp; 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:&nbsp; http://groups.yahoo.com/group/kylixgroup
> To join the forum: [email protected]
> To unsubscribe:&nbsp; [email protected]
> To post your messages:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> [email protected]
> To contact the moderator:&nbsp; [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/