delphi XE2 托盘程序

//----------这是在 delphi xe2-----------//
unit Umain;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.Menus, Winapi.ShellAPI;

type
TForm1 = class(TForm)
Button1: TButton;
TrayIcon1: TTrayIcon;
procedure Button1Click(Sender: TObject);
procedure TrayIcon1DblClick(Sender: TObject);
private
procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
begin
TrayIcon1.Visible := True;
Form1.Hide;
end;

procedure TForm1.TrayIcon1DblClick(Sender: TObject);
begin
Form1.Show;
TrayIcon1.Visible := False;
end;

procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);
begin
if Msg.Cmdtype = SC_MINIMIZE then
begin
trayIcon1.Visible := True;
Form1.Hide;
end;
if msg.cmdtype = sc_maximize then
begin
showmessage('测试');
end;
end;
end.

posted on 2012-02-07 17:49  long6  阅读(962)  评论(0编辑  收藏  举报

导航