home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / pas / swag / oop.swg / 0011_OOP-WIND.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  4KB  |  131 lines

  1. {
  2.      I'm still rather new (hence unexperienced) to this development
  3. environment. Since the number of users of the Pascal For Windows product
  4. is very limited in Belgium, I have little opportUnity to exchange ideas
  5. and talk about problems. ThereFore, I dare to ask the following question
  6. directly on the US-BBS.
  7.  
  8.      I contacted Borland Belgium With the following question:
  9. Is it possible to create an MDI-Interface, which consists of TDlgWindow's
  10. (Even of different Types of DialogWindows).
  11. The Program printed below was their answer. However, possibly because of
  12. my limited experience in the field, this Program does not seem to work on
  13. my Computer running the Borland Pascal 7.0 .
  14.  
  15.      Could someone explain why the Program below does not create dialog-
  16. Windows as MDI client Windows of the main MDI Window (when I select the
  17. "create"-menu element), but instead only normal client Windows.
  18. }
  19.  
  20. {********************************************************}
  21. {   MDI - Programm of TDlgWindow - ChildWindows          }
  22. {                                                        }
  23. {   This is an adapted version of the Borland demo       }
  24. {   Programm  MDIAPP.PAS of Borland Pascal 7.0           }
  25. {********************************************************}
  26. Program MDI;
  27. {$R MDIAPP.RES}
  28. Uses
  29.   WinTypes, WinProcs, Strings, OWindows, ODialogs;
  30.  
  31. Type
  32.   { Define a TApplication descendant }
  33.   TMDIApp = Object(TApplication)
  34.     Procedure InitMainWindow; Virtual;
  35.   end;
  36.  
  37.   PMyMDIChild = ^TMyMDIChild;
  38.   TMyMDIChild = Object(TDlgWindow)
  39.     Num : Integer;
  40.     CanCloseCheckBox : PCheckBox;
  41.     Constructor Init(AParent: PWindowsObject; AName: PChar);
  42.     Procedure SetupWindow; Virtual;
  43.     Function CanClose: Boolean; Virtual;
  44.   end;
  45.  
  46.   PMyMDIWindow = ^TMyMDIWindow;
  47.   TMyMDIWindow = Object(TMDIWindow)
  48.     Procedure SetupWindow; Virtual;
  49.     Function CreateChild: PWindowsObject; Virtual;
  50.   end;
  51.  
  52.   {**********************  MDI Child  ************************}
  53.   Constructor TMyMDIChild.Init(AParent: PWindowsObject; AName: PChar);
  54.   begin
  55.     inherited Init(AParent, AName);
  56.     New(CanCloseCheckBox, Init(@Self, 102, 'Can Close',
  57.                                10, 10, 200, 20, nil));
  58.   end;
  59.  
  60.   Procedure TMyMDIChild.SetupWindow;
  61.   begin
  62.     inherited SetupWindow;
  63.     CanCloseCheckBox^.Check;
  64.     ShowWindow(HWindow, CmdShow);
  65.   end;
  66.  
  67.   Function TMyMDIChild.CanClose;
  68.   begin
  69.     CanClose := CanCloseCheckBox^.GetCheck = bf_Checked;
  70.   end;
  71.  
  72.   {*****************  MDI Window  ******************}
  73.   Procedure TMyMDIWindow.SetupWindow;
  74.   Var
  75.     NewChild : PMyMDIChild;
  76.   begin
  77.     inherited SetupWindow;
  78.     CreateChild;
  79.   end;
  80.  
  81.   Function TMyMDIWindow.CreateChild: PWindowsObject;
  82.   begin
  83.     CreateChild := Application^.MakeWindow(New(PMyMDIChild,
  84.                                            Init(@Self, PChar(1))));
  85.   end;
  86.  
  87. Procedure TMDIApp.InitMainWindow;
  88. begin
  89.   MainWindow := New(PMDIWindow, Init('MDI ConFormist',
  90.                                 LoadMenu(HInstance, 'MDIMenu')));
  91. end;
  92.  
  93. Var
  94.   MDIApp: TMDIApp;
  95.  
  96. { Run the MDIApp }
  97. begin
  98.   MDIApp.Init('MDIApp');
  99.   MDIApp.Run;
  100.   MDIApp.Done;
  101. end.
  102.  
  103. {
  104. ***************************************************************************
  105.                  Content of the MDIAPP.RES File
  106. ***************************************************************************
  107. }
  108. MDIMENU MENU
  109. begin
  110.         POPUP "&MDI Children"
  111.         begin
  112.                 MENUITEM "C&reate", 24339
  113.                 MENUITEM "&Cascade", 24337
  114.                 MENUITEM "&Tile", 24336
  115.                 MENUITEM "Arrange &Icons", 24335
  116.                 MENUITEM "C&lose All", 24338
  117.         end
  118. end
  119.  
  120. 1 DIALOG 18, 18, 142, 92
  121. STYLE DS_SYSMODAL | WS_CHILD | WS_VISIBLE | WS_CAPTION |
  122.                     WS_MinIMIZEBOX | WS_MAXIMIZEBOX
  123. CLASS "BorDlg"
  124. CAPTION "TEST"
  125. begin
  126.         CHECKBOX "Text", 101, 26, 25, 28, 12
  127.         LText "Text", -1, 34, 48, 16, 8
  128.         CONTROL "Text", 102, "BorStatic", 0 | WS_CHILD |
  129.                                               WS_VISIBLE, 33, 70, 66, 8
  130. END
  131.