MainForm.pas
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit MainForm;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics,
  5.   Controls, Forms, Dialogs, Menus, ComCtrls, ToolWin, DBActns, ActnList,
  6.   ImgList;
  7. type
  8.   TFormMain = class(TForm)
  9.     ToolBar1: TToolBar;
  10.     StatusBar1: TStatusBar;
  11.     ImageList1: TImageList;
  12.     ActionList1: TActionList;
  13.     DataSetCancel1: TDataSetCancel;
  14.     DataSetDelete1: TDataSetDelete;
  15.     DataSetEdit1: TDataSetEdit;
  16.     DataSetFirst1: TDataSetFirst;
  17.     DataSetInsert1: TDataSetInsert;
  18.     DataSetLast1: TDataSetLast;
  19.     DataSetNext1: TDataSetNext;
  20.     DataSetPost1: TDataSetPost;
  21.     DataSetPrior1: TDataSetPrior;
  22.     DataSetRefresh1: TDataSetRefresh;
  23.     ToolButton1: TToolButton;
  24.     ToolButton2: TToolButton;
  25.     ToolButton3: TToolButton;
  26.     ToolButton4: TToolButton;
  27.     ToolButton5: TToolButton;
  28.     ToolButton6: TToolButton;
  29.     ToolButton7: TToolButton;
  30.     ToolButton8: TToolButton;
  31.     ToolButton9: TToolButton;
  32.     ToolButton10: TToolButton;
  33.     PageControl1: TPageControl;
  34.     TabCompanies: TTabSheet;
  35.     TabClasses: TTabSheet;
  36.     TabFreeQ: TTabSheet;
  37.     procedure FormCreate(Sender: TObject);
  38.     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  39.     procedure PageControl1Change(Sender: TObject);
  40.   public
  41.     procedure ShowForm (Form: TForm; Tab: TTabSheet); overload;
  42.   end;
  43. var
  44.   FormMain: TFormMain;
  45. implementation
  46. uses
  47.   MainData, CompaniesForm,
  48.   FreeQueryForm, ClassesForm;
  49. {$R *.DFM}
  50. procedure TFormMain.FormCreate(Sender: TObject);
  51. begin
  52.   ShortDateFormat := 'dd/mm/yyyy';
  53.   ShowForm (TFormCompanies.Create (self), TabCompanies);
  54. end;
  55. procedure TFormMain.ShowForm (Form: TForm; Tab: TTabSheet);
  56. begin
  57.   Form.BorderStyle := bsNone;
  58.   Form.Align := alClient;
  59.   Form.Parent := Tab;
  60.   Form.Show;
  61. end;
  62. procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  63. var
  64.   i: integer;
  65. begin
  66.   // ask permission to close each subform
  67.   CanClose := True;
  68.   for i := 0 to Screen.FormCount - 1 do
  69.     if Screen.Forms[I] <> self then
  70.       CanClose := CanClose and Screen.Forms[I].CloseQuery;
  71. end;
  72. procedure TFormMain.PageControl1Change(Sender: TObject);
  73. begin
  74.   if PageControl1.ActivePage.ControlCount = 0 then
  75.     if PageControl1.ActivePage = TabFreeQ then
  76.       ShowForm (TFormFreeQuery.Create (self), TabFreeQ)
  77.     else if PageControl1.ActivePage = TabClasses then
  78.       ShowForm (TFormClasses.Create (self), TabClasses);
  79. end;
  80. end.