E08 MDI
SDI(Single Document Interface) MDI(Multiple Document Interface) MDI (Client Window) (Child) MDI 1 MDI MDI MDI - File New Other Projects MDI Application - MDI - OK [ 1] MDI MDI MDI MDI Child MDI 3 MDI MDI, MDI Child 2
MDI MDI MDI MDI 3 MDI MDIChild MDI formstyle fsmdiform MDI Child formstyle fsmdichid MDI - [ 2] -, 3
[ 3] 1 [ 4] 2 Widow Cascade, Tile Horizontally, Tile Vertically File New Application FormStyle fsmdiform MDI File New Form FormStyle fsmdichild 4
Standard TmainMenu [ 5] New Close Window - File New procedure TForm1CreateMDIChild(const Name: string); var Child: TForm2; { create a new MDI child window } Child := TForm2Create(Application); ChildCaption := Name; procedure TForm1New1Click(Sender: TObject); CreateMDIChild('NONAME' + IntToStr(MDIChildCount + 1)); - Window Cascade procedure TForm1Cascade1Click(Sender: TObject); Form1Cascade; - Window Tile Horizontally procedure TForm1TileHorizontally1Click(Sender: TObject); Form1TileMode := tbhorizontal; 5
Form1Tile; - Window Tile Vertically procedure TForm1TileHorizontally1Click(Sender: TObject); Form1TileMode := tbvertical; Form1Tile; MDI Window, WindowMenu Window WindowMenu [ 6] MDIForm WindowMenu Window1 2 MDI - MDIChildCount MDIChild FormStyle fsmdiform 6
var I: Integer; with Form1 do for I := MDIChildCount-1 downto 0 do MDIChildren[I]Close; - MDIChildren MDIChildCount - ActiveMDIChid FormStyle MDIForm nil procedure TForm1Close1Click(Sender: TObject); // // if ActiveMDIChild <> nil then else ActiveMDIChildclose close; - Cascade - Tile 2 TileMode tbvertical tile 7
tilemode tbhorizontal tile - Next, Previous MDIChildren, NoName1, NoName2, NoName3, Next NoName2, NoName1, NoName3, Previous NoName1, NoName2, NoName3 3 MDI MDI MDI MDI MDI MDI Private Implementation Private FClientInstance : TFarProc; FprevClientProc : TFarProc; procedure ClientWndProc(var Message: TMessage); implementation // procedure TMainFormClientWndProc(var Message: TMessage); var Dc : hdc; I, j : Integer; Begin With Message do case Msg of WM_ERASEBKGND: Dc := TWMEraseBkGnd(Message)Dc; for I := 0 to ClientHeight div Image1PictureHeight do for j := 0 to ClientWidth div Image1PictureWidth do BitBlt(Dc, j * Image1PictureWidth, I * Image1PictureHeight, Image1PictureWidth, Image1PictureHeight, Image1PictureBitmapCanvasHandle, 8
0, 0, SRCCOPY); Result := 1; else Result := CallWindowProc(FPrevClientProc, ClientHandle, Msg, wparam, lparam); // // Procedure TMainFormMainFormClick(sender : Tobject); Begin FClientInstance := MakeObjectInstance(ClientWndProc); FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC)); SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FClientInstance)); End; MDI [ 7] MDI TImage Stretch True Stretch Form OnCreate Image1pictureBitmap := Form1GetFormImage; 9
[ 8] 4 MDI TMainMenu TMainMenu MDI MDI MDI [ 9] MDI 10
MDI MDI TmainMenu GroupIndex, MDI File Window GroupIndex 0 0 1 Group Index 0,1 3 GroupIndex GroupIndex, [ 10] 11
5 MDI MDI, MDI MDI - File New Application - TButton - File New Form MDI - FormStyle fsmdiform TmainMenu - - File New Form MDI - FormStyle fsmdichild - MDI MDI OnClick procedure TForm2CreateMDIChild(const Name: string); var Child: TForm3; Child := TForm3Create(Application); ChildCaption := Name; Childshow; procedure TForm2N2Click(Sender: TObject); CreateMDIChild('Hans'+IntToStr(MDIChildCount)); - Normal TButton OnClick MDI procedure TForm1Button1Click(Sender: TObject); Form2 := TForm2Create(Self); Form2Show; 12
Form2Free; end MDI MDI SDI [ 13], MDI [ 11] MDI MDI MDI 2 MDI MDI 2, 2 MDI - MDI MDI MDI, MDI ShowModal 2, MDI MDI 13
Tbutton // function WinExecAndWaitEx(Path, ComLine: Pchar; Visibility: word ): Boolean; var InstanceID: THandle; Msg: TMsg; Bstat: BOOL; pi: TProcessInformation; si: TStartupInfo; iexit: DWORD; bexit: boolean; FillMemory( @si, sizeof( TStartupInfo ), 0 ); with si do cb := sizeof( TStartupInfo ); dwflags := STARTF_USESHOWWINDOW; wshowwindow := Visibility; bstat := CreateProcess(Path, ComLine, nil, nil, false, NORMAL_PRIORITY_CLASS, Nil, nil, si, pi ); if (bstat) then WaitForSingleObject(pihProcess, INFINITE); CloseHandle( pihprocess ); CloseHandle( pihthread ); End Else ShowMessage(string(Path) + string(comline) + ' '); Result := bexit; procedure TForm1Button1Click(Sender: TObject); // MDI Visible False visible := false; WinExecAndWaitEx(PChar(ExtractFilepath(ParamStr(0))+'Project1exe'), nil, SW_NORMAL); // visible := true; - MDI 2? 2 2 2 COM 14
MDI MDI MDI [ ] ApplicationInitialize; // MDI // ShowMailForm False // TApplication ApplicationShowMainForm := False; // MDI ApplicationCreateForm(TForm2, Form2); // ApplicationCreateForm(TForm1, Form1); // Form1Show; ApplicationRun; MDI MDI [ ] procedure TForm1Form1Close(Sender: TObject; var Action: TCloseAction); ApplicationTerminate; [MDI ] procedure TForm2Form2Close(Sender: TObject; var Action: TCloseAction); var i : Integer; 15
// MDI // for i:=0 to MDIChildCount-1 do MDIChildren[i]close; Action := canone; Visible := False; 16