home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue59 / Arch / Extended Sample / UnitFormMain.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-05-19  |  2.9 KB  |  110 lines

  1. unit UnitFormMain;
  2. {
  3. After you've added a new list add an action to display the list. Do this by
  4. adding an action to component ActionList. In the action's execute method
  5. put a line of code like: "FormListOrders.ShowForm;" For this to work you need
  6. to add FormListOrders as a TFormBase class method (function)
  7. }
  8. interface
  9.  
  10. uses
  11.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  12.   Menus, ToolWin, ComCtrls, ActnList, ImgList, UnitFormBase;
  13.  
  14. type
  15.   TFormMain = class(TFormBase)
  16.     ActionList: TActionList;
  17.     ToolBarMain: TToolBar;
  18.     MainMenu: TMainMenu;
  19.     File1: TMenuItem;
  20.     Find1: TMenuItem;
  21.     Exit1: TMenuItem;
  22.     ActionTerminate: TAction;
  23.     ActionSaveAll: TAction;
  24.     SaveAll1: TMenuItem;
  25.     N1: TMenuItem;
  26.     ToolButton5: TToolButton;
  27.     ActionFindOrders: TAction;
  28.     Orders1: TMenuItem;
  29.     ToolButton1: TToolButton;
  30.     ToolButton2: TToolButton;
  31.     ActionFindCustomer: TAction;
  32.     ToolButton3: TToolButton;
  33.     Customer1: TMenuItem;
  34.     ActionFindEmployee: TAction;
  35.     ToolButton4: TToolButton;
  36.     Employee1: TMenuItem;
  37.     procedure ActionTerminateExecute(Sender: TObject);
  38.     procedure ActionSaveAllExecute(Sender: TObject);
  39.     procedure ActionSaveAllUpdate(Sender: TObject);
  40.     procedure ActionFindOrdersExecute(Sender: TObject);
  41.     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  42.     procedure ActionFindCustomerExecute(Sender: TObject);
  43.     procedure ActionFindEmployeeExecute(Sender: TObject);
  44.   private
  45.   public
  46.   end;
  47.  
  48. var FormMain: TFormMain;
  49.  
  50. implementation
  51.  
  52. uses
  53.   UnitFormListBase
  54. , UnitObjectBase
  55. , UnitFormListOrders
  56. , UnitFormListCustomer
  57. , UnitFormListEmployee
  58.   ;
  59.  
  60. {$R *.DFM}
  61.  
  62. procedure TFormMain.ActionTerminateExecute(Sender: TObject);
  63. begin
  64.   inherited;
  65.     Application.Terminate;
  66. end;
  67.  
  68. procedure TFormMain.ActionSaveAllExecute(Sender: TObject);
  69. begin
  70.   inherited;
  71.   TObjectBase.SaveAll;
  72. end;
  73.  
  74. procedure TFormMain.ActionSaveAllUpdate(Sender: TObject);
  75. begin
  76.   inherited;
  77.   ActionSaveAll.Enabled := TObjectBase.AnyUpdatesPending;
  78. end;
  79.  
  80. procedure TFormMain.ActionFindOrdersExecute(Sender: TObject);
  81. begin
  82.   inherited;
  83.   // Using new integer means we get a new list every time the user chooses "Find"
  84.   TFormListOrders.FetchForm(NewInteger).ShowForm;
  85. end;
  86.  
  87. procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  88. begin
  89.   inherited;
  90.   TFormBase.CloseAll;
  91.   Application.ProcessMessages;
  92.   CanClose := (TFormBase.FormCount = 0);
  93. end;
  94.  
  95. procedure TFormMain.ActionFindCustomerExecute(Sender: TObject);
  96. begin
  97.   inherited;
  98.   // Using new integer means we get a new list every time the user chooses "Find"
  99.   TFormListCustomer.FetchForm(NewInteger).ShowForm;
  100. end;
  101.  
  102. procedure TFormMain.ActionFindEmployeeExecute(Sender: TObject);
  103. begin
  104.   inherited;
  105.   // Using new integer means we get a new list every time the user chooses "Find"
  106.   TFormListEmployee.FetchForm(NewInteger).ShowForm;
  107. end;
  108.  
  109. end.
  110.