TtMain.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:5k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit TtMain;
  2. interface
  3. uses
  4.   Windows, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls,
  5.   ExtCtrls, ComCtrls, Menus, Graphics, CoolTrayIcon, TextTrayIcon;
  6. type
  7.   TMainForm = class(TForm)
  8.     Timer1: TTimer;
  9.     FontDialog1: TFontDialog;
  10.     ColorDialog1: TColorDialog;
  11.     Button1: TButton;
  12.     Button2: TButton;
  13.     Button3: TButton;
  14.     Button7: TButton;
  15.     GroupBox1: TGroupBox;
  16.     Label1: TLabel;
  17.     Edit1: TEdit;
  18.     CheckBox1: TCheckBox;
  19.     CheckBox2: TCheckBox;
  20.     Button4: TButton;
  21.     Button5: TButton;
  22.     Button6: TButton;
  23.     Label2: TLabel;
  24.     Edit2: TEdit;
  25.     UpDown2: TUpDown;
  26.     Label3: TLabel;
  27.     Edit3: TEdit;
  28.     UpDown3: TUpDown;
  29.     Label4: TLabel;
  30.     Edit4: TEdit;
  31.     UpDown4: TUpDown;
  32.     TrayIcon1: TTextTrayIcon;
  33.     procedure FormCreate(Sender: TObject);
  34.     procedure FormDestroy(Sender: TObject);
  35.     procedure Edit1Change(Sender: TObject);
  36.     procedure CheckBox1Click(Sender: TObject);
  37.     procedure CheckBox2Click(Sender: TObject);
  38.     procedure Button1Click(Sender: TObject);
  39.     procedure Button2Click(Sender: TObject);
  40.     procedure Button3Click(Sender: TObject);
  41.     procedure Button4Click(Sender: TObject);
  42.     procedure Button5Click(Sender: TObject);
  43.     procedure Button6Click(Sender: TObject);
  44.     procedure Button7Click(Sender: TObject);
  45.     procedure Timer1Timer(Sender: TObject);
  46.     procedure TrayIcon1MouseDown(Sender: TObject; Button: TMouseButton;
  47.       Shift: TShiftState; X, Y: Integer);
  48.     procedure Edit2Change(Sender: TObject);
  49.     procedure Edit3Change(Sender: TObject);
  50.     procedure Edit4Change(Sender: TObject);
  51.   private
  52.     TrayCounter: Integer;
  53.     LoopNumbers: Boolean;
  54.     BgIcon: TIcon;
  55.   end;
  56. var
  57.   MainForm: TMainForm;
  58. implementation
  59. {$R *.DFM}
  60. procedure TMainForm.FormCreate(Sender: TObject);
  61. begin
  62.   BgIcon := TIcon.Create;
  63.   BgIcon.Assign(TrayIcon1.BackgroundIcon);
  64.   Edit1Change(Self);
  65.   CheckBox1Click(Self);
  66.   CheckBox2Click(Self);
  67.   Edit2Change(Self);
  68.   Edit3Change(Self);
  69.   Edit4Change(Self);
  70. end;
  71. procedure TMainForm.FormDestroy(Sender: TObject);
  72. begin
  73.   BgIcon.Free;
  74. end;
  75. procedure TMainForm.Button7Click(Sender: TObject);
  76. begin
  77.   Close;
  78. end;
  79. procedure TMainForm.Timer1Timer(Sender: TObject);
  80. begin
  81.   if TrayCounter < 91 then
  82.   begin
  83.     if LoopNumbers then
  84.       Edit1.Text := IntToStr(TrayCounter-65)
  85.     else
  86. //      Edit1.Text := Char(TrayCounter) + #13 + Char(TrayCounter+32);
  87.       Edit1.Text := Char(TrayCounter) + Char(TrayCounter) + #13 + Char(TrayCounter) + Char(TrayCounter);
  88.     Inc(TrayCounter);
  89.   end;
  90.   if TrayCounter = 91 then
  91.     TrayCounter := 65;
  92. end;
  93. procedure TMainForm.Button1Click(Sender: TObject);
  94. begin
  95.   // Loop numbers
  96.   LoopNumbers := True;
  97.   TrayCounter := 65;
  98.   Timer1.Enabled := True;
  99. end;
  100. procedure TMainForm.Button2Click(Sender: TObject);
  101. begin
  102.   // Loop characters
  103.   LoopNumbers := False;
  104.   TrayCounter := 65;
  105.   Timer1.Enabled := True;
  106. end;
  107. procedure TMainForm.Button3Click(Sender: TObject);
  108. begin
  109.   Timer1.Enabled := False;
  110. end;
  111. procedure TMainForm.Button4Click(Sender: TObject);
  112. begin
  113.   FontDialog1.Font.Assign(TrayIcon1.Font);
  114.   if FontDialog1.Execute then
  115.     TrayIcon1.Font.Assign(FontDialog1.Font);
  116. //  Alternative:   TrayIcon1.Font := FontDialog1.Font;
  117. end;
  118. procedure TMainForm.Button5Click(Sender: TObject);
  119. begin
  120.   ColorDialog1.Color := TrayIcon1.Color;
  121.   if ColorDialog1.Execute then
  122.     TrayIcon1.Color := ColorDialog1.Color;
  123. end;
  124. procedure TMainForm.Button6Click(Sender: TObject);
  125. begin
  126.   ColorDialog1.Color := TrayIcon1.BorderColor;
  127.   if ColorDialog1.Execute then
  128.     TrayIcon1.BorderColor := ColorDialog1.Color;
  129. end;
  130. procedure TMainForm.Edit1Change(Sender: TObject);
  131. begin
  132.   TrayIcon1.Text := Edit1.Text;
  133. end;
  134. procedure TMainForm.CheckBox1Click(Sender: TObject);
  135. begin
  136.   TrayIcon1.Border := CheckBox1.Checked;
  137. end;
  138. procedure TMainForm.CheckBox2Click(Sender: TObject);
  139. begin
  140.   if CheckBox2.Checked then
  141.     TrayIcon1.BackgroundIcon := BgIcon
  142.   else
  143.     TrayIcon1.BackgroundIcon := nil;
  144. end;
  145. procedure TMainForm.Edit2Change(Sender: TObject);
  146. begin
  147.   TrayIcon1.Options.OffsetX := StrToInt(Edit2.Text);
  148. end;
  149. procedure TMainForm.Edit3Change(Sender: TObject);
  150. begin
  151.   TrayIcon1.Options.OffsetY := StrToInt(Edit3.Text);
  152. end;
  153. procedure TMainForm.Edit4Change(Sender: TObject);
  154. begin
  155.   TrayIcon1.Options.LineDistance := StrToInt(Edit4.Text);
  156. end;
  157. procedure TMainForm.TrayIcon1MouseDown(Sender: TObject;
  158.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  159. begin
  160. //  Timer1.Enabled := not Timer1.Enabled;
  161. end;
  162. end.