home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / windows / c / mobjm260 / multidlg.pa_ / multidlg.pa
Encoding:
Text File  |  1994-09-06  |  5.4 KB  |  194 lines

  1. (*********************************************************************)
  2. (*                                                                   *)
  3. (*          Microworks ObjectMate 2.6                                                        *)
  4. (*                                                                   *)
  5. (*     Windows Interface Develpment Kit for the Borland Languages.   *)
  6. (*                                                                   *)
  7. (*         MULITDLG.PAS : Multiple Dialog Demonstration                      *)
  8. (*                                                                                                                             *)
  9. (*     Copyright 1992-94 Microworks Sydney, Australia.                 *)
  10. (*                                                                   *)
  11. (*********************************************************************)
  12.  
  13. (* MultiDlg creates a notebook style multiple dialog using child dialogs and
  14.  * a radio button style SFX toolbar. It's an easy and more stylish alternative
  15.  * to tabbed multiple dialogs. In the resource file multidlg.res there are two
  16.  * main templates: MULTIDLG and MULTIDLGC. MULTDLG is the Pascal template and
  17.  * MULTIDLGC is the C++ 4.0 template.
  18.  *)
  19.  
  20. program MultiDlg;
  21.  
  22. uses WinTypes, WinProcs, WIN31, SFX200,
  23.          {$IFDEF Ver15}
  24.              WObjects;
  25.          {$ELSE}
  26.              Objects, OWindows, ODialogs;
  27.          {$ENDIF}
  28.  
  29. {$R MultiDlg.res}
  30.  
  31. const
  32.  
  33.     id_Dlg1         = 1;
  34.     id_Dlg2         = 2;
  35.     id_Dlg3         = 3;
  36.     id_Dlg4         = 4;
  37.     id_Dlg5         = 5;
  38.     id_Shade        = 101;
  39.     id_Toolbar      = 102;
  40.     id_But1         = 301;
  41.     id_But2         = 302;
  42.     id_But3         = 303;
  43.     id_But4         = 304;
  44.     id_But5         = 305;
  45.     AppName : PChar = 'MultiDlg';
  46.  
  47. type
  48.  
  49.     PChildDlg = ^TChildDlg;
  50.     TChildDlg = object(TDialog)
  51.         procedure OK (var Msg: TMessage); virtual id_First + id_Ok;
  52.         procedure Cancel (var Msg: TMessage); virtual id_First + id_Cancel;
  53.     end;
  54.  
  55.     PMultiDlg = ^TMultiDlg;
  56.     TMultiDlg = object(TDlgWindow)
  57.         NextDlg : PChildDlg;
  58.         PrevDlg : PChildDlg;
  59.         Shade   : PSFXShade;
  60.         Toolbar : PSFXToolbar;
  61.         constructor Init(AParent: PWindowsObject; AName: PChar);
  62.         destructor Done; virtual;
  63.         function  GetClassName : PChar; virtual;
  64.         procedure GetWindowClass(var AWndClass: TWndClass); virtual;
  65.         procedure SetUpWindow; virtual;
  66.         procedure CreateChildDialog (AnID: Integer; Title: PChar);
  67.         procedure IDBut1 (var Msg: TMessage); virtual id_First + id_But1;
  68.         procedure IDBut2 (var Msg: TMessage); virtual id_First + id_But2;
  69.         procedure IDBut3 (var Msg: TMessage); virtual id_First + id_But3;
  70.         procedure IDBut4 (var Msg: TMessage); virtual id_First + id_But4;
  71.         procedure IDBut5 (var Msg: TMessage); virtual id_First + id_But5;
  72.     end;
  73.  
  74.     PMultiApp = ^TMultiApp;
  75.     TMultiApp = object(TApplication)
  76.         procedure InitMainWindow; virtual;
  77.     end;
  78.  
  79. {********** TMultiApp **********}
  80.  
  81. procedure TMultiApp.InitMainWindow;
  82. begin
  83.     MainWindow := New(PMultiDlg, Init(nil, AppName));
  84. end;
  85.  
  86. {********** TMultiDlg **********}
  87.  
  88. constructor TMultiDlg.Init(AParent: PWindowsObject; AName: PChar);
  89. begin
  90.     TDlgWindow.Init(AParent, AName);
  91.     Attr.Param := mws_SFXFrame or MWS_SFXCAPTION;
  92.     Shade := New(PSFXShade, InitResource(@Self, id_Shade));
  93.     Toolbar := New(PSFXToolbar, InitResource(@Self, id_Toolbar));
  94.     NextDlg := nil;
  95.     PrevDlg := nil;
  96. end;
  97.  
  98. destructor TMultiDlg.Done;
  99. begin
  100.     TDlgWindow.Done;
  101. end;
  102.  
  103. function TMultiDlg.GetClassName;
  104. begin
  105.     GetClassName := AppName;
  106. end;
  107.  
  108. procedure TMultiDlg.GetWindowClass(var AWndClass: TWndClass);
  109. begin
  110.     TDlgWindow.GetWindowClass(AWndClass);
  111.     AWndClass.hIcon := LoadIcon(HInstance, AppName);
  112. end;
  113.  
  114. procedure TMultiDlg.SetUpWindow;
  115. var
  116.     Msg     : TMessage;
  117.     WinRect : TRect;
  118. begin
  119.     TDlgWindow.SetUpWindow;
  120.     IDBut1(Msg);
  121.     Toolbar^.CheckTool(id_But1);
  122.     if GetSystemMetrics(SM_CYSIZE) = 26 then
  123.     begin
  124.         GetWindowRect(HWindow, WinRect);
  125.         with WinRect do
  126.             SetWindowPos(HWindow, 0, 0, 0, Right- Left- 22, Bottom-Top, SWP_NOZORDER or SWP_NOMOVE);
  127.         ShowWindow(GetDlgItem(HWindow, id_Cancel), SW_SHOW);
  128.     end;
  129.     CenterWindow(0, HWindow);
  130. end;
  131.  
  132. procedure TMultiDlg.CreateChildDialog (AnID: Integer; Title: PChar);
  133. var
  134.     WinRect : TRect;
  135. begin
  136.     PrevDlg := NextDlg;
  137.     NextDlg := New(PChildDlg, Init(@Self, MakeIntResource(AnID)));
  138.     Application^.MakeWindow(NextDlg);
  139.     SetWindowPos(NextDlg^.HWindow, HWND_TOP, 33, 50, 0, 0, SWP_NOSIZE);
  140.     SetWindowText(Shade^.HWindow, Title);
  141.     ShowWindow(NextDlg^.HWindow, SW_NORMAL);
  142.     if (PrevDlg <> nil) and (PrevDlg^.HWindow <> 0) then
  143.         DestroyWindow(PrevDlg^.HWindow);
  144. end;
  145.  
  146. procedure TMultiDlg.IDBut1 (var Msg: TMessage);
  147. begin
  148.     CreateChildDialog(id_Dlg1, ' Edit Controls...');
  149. end;
  150.  
  151. procedure TMultiDlg.IDBut2 (var Msg: TMessage);
  152. begin
  153.     CreateChildDialog(id_Dlg2, ' List Boxes...');
  154. end;
  155.  
  156. procedure TMultiDlg.IDBut3 (var Msg: TMessage);
  157. begin
  158.     CreateChildDialog(id_Dlg3, ' Combo Boxes...');
  159. end;
  160.  
  161. procedure TMultiDlg.IDBut4 (var Msg: TMessage);
  162. begin
  163.     CreateChildDialog(id_Dlg4, ' Check Boxes...');
  164. end;
  165.  
  166. procedure TMultiDlg.IDBut5 (var Msg: TMessage);
  167. begin
  168.     CreateChildDialog(id_Dlg5, ' Radio Buttons...');
  169. end;
  170.  
  171. {********** TChildDlg **********}
  172.  
  173. procedure TChildDlg.Ok (var Msg: TMessage);
  174. begin
  175.     with Msg do
  176.         SendMessage(Parent^.HWindow, Message, wParam, lParam);
  177. end;
  178.  
  179. procedure TChildDlg.Cancel (var Msg: TMessage);
  180. begin
  181.     with Msg do
  182.         SendMessage(Parent^.HWindow, Message, wParam, lParam);
  183. end;
  184.  
  185. {********** Main program **********}
  186.  
  187. var
  188.     App: TMultiApp;
  189. begin
  190.     App.Init(AppName);
  191.     App.Run;
  192.     App.Done;
  193. end.
  194.