On-Line  www.XServer.ru - , , , ,  .
                                      
     XServer.ru




...




 

MDI

MDI (Multiple Document Interface) , . (File Manager).
MDI- - . FormStyle fsMDIForm. fsMDIChild.
, , , , . , - , - .


MDI-, , . , , . Delphi ,
.

Delphi . Delphi .
- .

type
TForm1 = class (TForm)
private
{ .}
public
{ .}
end;

TForm1.
, .

var Form1: TForm1;

Form1, TForm1 . .
, View/ Project Source. :

Application.CreateForm(TForm1, Form1);

: , , . Application .


SDI-, MDI- , , .
Create . TForm1 Caption 'New Form'.

Form1:= TForm1.Create(Application);
Form1.Caption:= 'New Form';

Create TComponent, . Application, . Nil, ( - ), . , ...
Form1 . , - , :

with TFormI.Create(Application) do
Caption:= 'New Form';


: MDI- Show , Delphi MDI-. SDI- Show.



Delphi . , Project Options, . 1.14, Auto-create forms.
. 1.14. Project Options

, MDIChildren, .

MDI- TForm
TForm , MDI-.

ActiveMDIChild
TForm, . , , .
, , , TMemo, memDailyNotes. - TfrmMDIChild. Clear , memDailyNotes . .

procedure TfrmMDIParent.spbtnClearClick(Sender: TObject);
begin
if not (ActiveMDIChild = Nil) then
if ActiveMDIChild is TfrmMDIChild then
TfrmMDIChild(ActiveMDIChild).memDailyNotes.Clear;
end;

, ActiveMDIChild Nil, .


: ActiveMDIChild Nil, FormStyle fsMDIForm.


ActiveMDIChild TForm, memDailyNotes - TfrmMDIChild. , .. ActiveMDIChild TfrmMDIChild.
Clear memDailyNotes.

MDIChildren MDIChildCount
MDIChildren TForm, . MDIChildCount MDIChildren.
- . Minimize All.

procedure TFormI.mnuMinimizeAllClick(Sender: TObject);
var
iCount: Integers;
begin
for iCount:= MDIChildCount-1 downto 0 do
MDIChildren[iCount].WindowState:= wsMinimized;
end;

, , MDIChildren , .

TileMode
- , , Tile. tbHorizontal ( ) tbVertical .

WindowMenu
MDI- , . WindowMenu TMenuItem, Delphi .
TMenuItem . Caption, swindow.

MDI- TForm
MDI- OnActivate . MDI- MDI-, OnActivate , Active True. : , OnActivate , .

MDI- TForm
MDI- .
Arrangelcons .
Cascade , .
Next Previous , <Ctrl+Tab> <Ctrl+Shift+Tab>.
Tile , .

MDI-
.


MDI- SDI-, , . .

1. File/New Application, .
2. .

Caption Image Viewer
FormStyle fsMDIForm
Name frmMDIParent ShowHint True

3. TPanel . .

Align alTop
Caption -
4. TSpeedButton TPanel spbtnLoad, spbtnStretch spbtnCenter. .

spbtnLoad.Hint Load
spbtnLoad.Left 8
spbtnLoad.Top 8
spbtnStretch.AllowAlIUp True
spbtnStretch.Grouplndex 1
spbtnStretch.Hint Stretch
spbtnStretch.Left 48
spbtnStretch.Top 8
spbtnCenter.AllowAlIUp True
spbtnCenter.Grouplndex 2
spbtnCenter.Hint Center
spbtnCenter.Left 80
spbtnCenter.Top 8
Glyph , SDI-.

5. TOpenDialog .

Filter Bitmaps (*.bmp)]*.bmp
Name opndlgLoad
Options [ofPathMustExist,ofFileMustExist]

.

1. File/New Form, .
2. .

FormStyle fsMDIChild
Name frmMDIChild
Position poDefaultPosOnly
3. TImage .

Align alClient
Name imgMain

.

1. Project/ Options, Project Options, . 1.14.
2. frmMDIChild Auto-create forms.
3. . frmMDIChild Available forms.
4. .

, File/Save Project As. Unit1 MDIParent, - EgMDIApp.


, , SDI-.
. OnClick spbtnLoad.

procedure TfrmMDIParent.spbtnLoadClick(Sender: TObject);
begin
if opndlgLoad.Execute then
with TfrmMDIChild.Create(Application) do
begin
Caption:= opndlgLoad.FileName;
imgMain.Picture.LoadFromFile(opndlgLoad.FileName);
ClientWidth:= imgMain.Picture.Width;
ClientHeight:= imgMain.Picture.Height;
end;
end;

. , .
- , . TfrmMDIChild, MDIChild, implementation :

uses MDIChild;

. , , Close, , . , OnClose TfrmMDIChild - Action:

Action:= caFree;

TSpeedButton Stretch Center , SDI-, OnClick

if not (ActiveMDIChild = Nil) then
if ActiveMDIChild 15 TfrmMDIChild then
TfrmMDIChild(ActiveMDIChild).imgMain.Stretch:= spbthStretch.Down;

if not (ActiveMDIChild = Nil) then
if ActiveMDIChild is TfrmMDIChild then
TfrmMDIChild(ActiveMDIChild).imgMain.Center:= spbthCenter.Down;

- Stretch Center OnActivate TfrmMDIChild .

frmMDIParent.spbtnStretch.Down:= imgMain.Stretch;
frmMDIParent.spbtnCenter.Down:= imgMain.Center;

, , - MDIChild implementation .

uses MDIParent;

, . MDI- !


: Down TSpeedButton n-click. , , .
             



 
 |   |   |   |   |