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

Delphi控件源码

开发平台:

Delphi

  1. unit Main;
  2. interface
  3. uses
  4.   Windows, Messages, Classes, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
  5.   CoolTrayIcon;
  6. type
  7.   TMainForm = class(TForm)
  8.     CoolTrayIcon1: TCoolTrayIcon;
  9.     Label1: TLabel;
  10.     RadioGroup1: TRadioGroup;
  11.     Button1: TButton;
  12.     procedure FormCreate(Sender: TObject);
  13.     procedure CoolTrayIcon1Click(Sender: TObject);
  14.     procedure CoolTrayIcon1MinimizeToTray(Sender: TObject);
  15.     procedure Button1Click(Sender: TObject);
  16.     procedure RadioGroup1Click(Sender: TObject);
  17.   private
  18.     IsMinimized: Boolean;
  19.     procedure FloatRectangles(Minimizing, OverrideUserSettings: Boolean);
  20.     procedure FadeWindow(Minimizing: Boolean);
  21.     procedure ImplodeWindow(Minimizing: Boolean);
  22.     procedure ImplodeOutlineWindow(Minimizing: Boolean);
  23.   public
  24.     StartX, StartY, StartW, StartH: Integer;
  25.   end;
  26. var
  27.   MainForm: TMainForm;
  28. implementation
  29. uses
  30.   TrayAnimation;
  31. {$R *.dfm}
  32. {--------------------- TMainForm ----------------------}
  33. procedure TMainForm.FormCreate(Sender: TObject);
  34. begin
  35.   StartW := Width;
  36.   StartH := Height;
  37.   RadioGroup1Click(Self);
  38. end;
  39. procedure TMainForm.CoolTrayIcon1MinimizeToTray(Sender: TObject);
  40. begin
  41.   case RadioGroup1.ItemIndex of
  42.     1: FloatRectangles(True, True);
  43.     2: FadeWindow(True);
  44.     3: ImplodeWindow(True);
  45.     4: ImplodeOutlineWindow(True);
  46.   end;
  47.   IsMinimized := True;
  48. end;
  49. procedure TMainForm.CoolTrayIcon1Click(Sender: TObject);
  50. begin
  51.   if IsMinimized then
  52.   begin
  53.     case RadioGroup1.ItemIndex of
  54.       1: begin
  55.         FloatRectangles(False, True);
  56.         CoolTrayIcon1.ShowMainForm;
  57.       end;
  58.       2: begin
  59.         CoolTrayIcon1.ShowMainForm;
  60.         FadeWindow(False);
  61.       end;
  62.       3: begin
  63.         CoolTrayIcon1.ShowMainForm;
  64.         ImplodeWindow(False);
  65.       end;
  66.       4: begin
  67.         ImplodeOutlineWindow(False);
  68.         CoolTrayIcon1.ShowMainForm;
  69.       end;
  70.       else
  71.         CoolTrayIcon1.ShowMainForm;
  72.     end;
  73.     IsMinimized := False;
  74.   end;
  75. end;
  76. procedure TMainForm.FloatRectangles(Minimizing, OverrideUserSettings: Boolean);
  77. begin
  78.   FloatingRectangles(Minimizing, OverrideUserSettings);
  79. end;
  80. procedure TMainForm.FadeWindow(Minimizing: Boolean);
  81. var
  82.   WindowFader: TWindowFader;
  83. begin
  84.   WindowFader := TWindowFader.Create(False);
  85.   WindowFader.FadeOut := Minimizing;
  86.   WindowFader.Execute;
  87.   WindowFader.Free;
  88. end;
  89. procedure TMainForm.ImplodeWindow(Minimizing: Boolean);
  90. var
  91.   WindowImploder: TWindowImploder;
  92. begin
  93.   WindowImploder := TWindowImploder.Create(False);
  94.   WindowImploder.Imploding := Minimizing;
  95.   WindowImploder.Execute;
  96.   WindowImploder.Free;
  97. end;
  98. procedure TMainForm.ImplodeOutlineWindow(Minimizing: Boolean);
  99. var
  100.   WindowOutlineImploder: TWindowOutlineImploder;
  101. begin
  102.   WindowOutlineImploder := TWindowOutlineImploder.Create;
  103.   WindowOutlineImploder.Imploding := Minimizing;
  104.   WindowOutlineImploder.Execute;
  105.   WindowOutlineImploder.Free;
  106. end;
  107. procedure TMainForm.Button1Click(Sender: TObject);
  108. begin
  109.   Close;
  110. end;
  111. procedure TMainForm.RadioGroup1Click(Sender: TObject);
  112. begin
  113.   { We turn AlphaBlend on/off as needed because when AlphaBlend is true
  114.     the form flickers when it's resized. }
  115. {$IFDEF DELPHI_6_UP}
  116.   if RadioGroup1.ItemIndex = 2 then
  117.   begin
  118.     AlphaBlend := True;
  119.     AlphaBlendValue := 255;
  120.   end
  121.   else
  122.     AlphaBlend := False;
  123. {$ELSE}
  124.   if RadioGroup1.ItemIndex = 2 then
  125.     MessageDlg('Alpha-blend (fade) not supported in this Delphi version.',
  126.                mtInformation, [mbOk], 0);
  127. {$ENDIF}
  128. end;
  129. end.