Subversion Repositories delphiutils

Rev

Rev 75 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. unit MAIN;
  2.  
  3. // TODO: Wenn man das Hauptfenster schließt, sollen nicht alle Uhren meckern
  4. // TODO: Uhrzeiten abspeichern?
  5. // TODO: Uhrzeitenwert manuell änderbar machen?
  6. // TODO: Automatische Fenster-Anordnung funktioniert nicht korrekt mit poDefaultSizeOnly
  7.  
  8. interface
  9.  
  10. uses Windows, SysUtils, Classes, Graphics, Forms, Controls, Menus,
  11.   StdCtrls, Dialogs, Buttons, Messages, ExtCtrls, ComCtrls, StdActns,
  12.   ActnList, ToolWin, ImgList;
  13.  
  14. type
  15.   TMainForm = class(TForm)
  16.     MainMenu1: TMainMenu;
  17.     File1: TMenuItem;
  18.     FileNewItem: TMenuItem;
  19.     FileCloseItem: TMenuItem;
  20.     Window1: TMenuItem;
  21.     Help1: TMenuItem;
  22.     N1: TMenuItem;
  23.     FileExitItem: TMenuItem;
  24.     WindowCascadeItem: TMenuItem;
  25.     WindowTileItem: TMenuItem;
  26.     WindowArrangeItem: TMenuItem;
  27.     HelpAboutItem: TMenuItem;
  28.     OpenDialog: TOpenDialog;
  29.     WindowMinimizeItem: TMenuItem;
  30.     StatusBar: TStatusBar;
  31.     ActionList1: TActionList;
  32.     FileNew1: TAction;
  33.     FileExit1: TAction;
  34.     WindowCascade1: TWindowCascade;
  35.     WindowTileHorizontal1: TWindowTileHorizontal;
  36.     WindowArrangeAll1: TWindowArrange;
  37.     WindowMinimizeAll1: TWindowMinimizeAll;
  38.     HelpAbout1: TAction;
  39.     FileClose1: TWindowClose;
  40.     WindowTileVertical1: TWindowTileVertical;
  41.     WindowTileItem2: TMenuItem;
  42.     ToolBar2: TToolBar;
  43.     ToolButton9: TToolButton;
  44.     ToolButton8: TToolButton;
  45.     ToolButton10: TToolButton;
  46.     ToolButton11: TToolButton;
  47.     ImageList1: TImageList;
  48.     Einstellungen1: TMenuItem;
  49.     NureineUhrgleichzeitig1: TMenuItem;
  50.     AlleUhrenstoppen1: TMenuItem;
  51.     N2: TMenuItem;
  52.     procedure FileNew1Execute(Sender: TObject);
  53.     procedure FileOpen1Execute(Sender: TObject);
  54.     procedure HelpAbout1Execute(Sender: TObject);
  55.     procedure FileExit1Execute(Sender: TObject);
  56.     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  57.     procedure NureineUhrgleichzeitig1Click(Sender: TObject);
  58.     procedure FormShow(Sender: TObject);
  59.     procedure AlleUhrenstoppen1Click(Sender: TObject);
  60.   private
  61.     procedure CreateMDIChild(const Name: string);
  62.   public
  63.     procedure StopAllTimers;
  64.   end;
  65.  
  66. var
  67.   MainForm: TMainForm;
  68.  
  69. implementation
  70.  
  71. {$R *.dfm}
  72.  
  73. uses CHILDWIN, about, IniFiles;
  74.  
  75. var
  76.   StopUhrCount: integer = 1;
  77.  
  78. procedure TMainForm.AlleUhrenstoppen1Click(Sender: TObject);
  79. begin
  80.   StopAllTimers;
  81. end;
  82.  
  83. procedure TMainForm.CreateMDIChild(const Name: string);
  84. var
  85.   Child: TMDIChild;
  86. begin
  87.   Child := TMDIChild.Create(Application);
  88.   Child.Caption := Name;
  89.   Child.Memo1.Lines.Text := Name;
  90. end;
  91.  
  92. procedure TMainForm.FileNew1Execute(Sender: TObject);
  93. begin
  94.   CreateMDIChild('Stoppuhr #' + IntToStr(StopUhrCount));
  95.   Inc(StopUhrCount);
  96. end;
  97.  
  98. procedure TMainForm.FileOpen1Execute(Sender: TObject);
  99. begin
  100.   if OpenDialog.Execute then
  101.     CreateMDIChild(OpenDialog.FileName);
  102. end;
  103.  
  104. procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  105. begin
  106.   // Brauchen wir nicht, da die einzelnen MDI-Fenster ja schon meckern
  107.   //CanClose := MessageDlg('Programm wirklich beenden?', mtConfirmation, mbYesNoCancel, 0) = mrYes;
  108. end;
  109.  
  110. procedure TMainForm.FormShow(Sender: TObject);
  111. var
  112.   x: TMemIniFile;
  113. begin
  114.   x := TMemIniFile.Create('Settings.ini');
  115.   try
  116.     NureineUhrgleichzeitig1.Checked := x.ReadBool('Settings', 'SingleClockMode', false);
  117.   finally
  118.     FreeAndNil(x);
  119.   end;
  120. end;
  121.  
  122. procedure TMainForm.HelpAbout1Execute(Sender: TObject);
  123. begin
  124.   AboutBox.ShowModal;
  125. end;
  126.  
  127. procedure TMainForm.NureineUhrgleichzeitig1Click(Sender: TObject);
  128. var
  129.   x: TMemIniFile;
  130. begin
  131.   x := TMemIniFile.Create('Settings.ini');
  132.   try
  133.     x.WriteBool('Settings', 'SingleClockMode', NureineUhrgleichzeitig1.Checked);
  134.     x.UpdateFile;
  135.   finally
  136.     FreeAndNil(x);
  137.   end;
  138. end;
  139.  
  140. procedure TMainForm.StopAllTimers;
  141. var
  142.   i: integer;
  143. begin
  144.   for i := 0 to MDIChildCount - 1 do
  145.   begin
  146.     TMdiChild(MDIChildren[i]).StopTimer;
  147.   end;
  148. end;
  149.  
  150. procedure TMainForm.FileExit1Execute(Sender: TObject);
  151. begin
  152.   Close;
  153. end;
  154.  
  155. end.
  156.