procedure trayDblClick(Sender: TObject);
3.功能实现
var
frmMain: TfrmMain;
tray: TTrayNotifyIcon;
//窗口初始化
procedure TfrmMain.FormCreate(Sender: TObject);
begin
tray := TTrayNotifyIcon.Create(self); //将窗体创建为托盘
tray.Icon := application.Icon; //定义托盘的显示图标
tray.IconVisible := true; //托盘可见
tray.Hint := '营收数据自检系统';
tray.PopupMenu := pm1; //给托盘定义一个右击时的弹出菜单
tray.OnDblClick := trayDblClick; //给托盘定义一个双击事件;
end;
//------------------------------------------------------------------------------
// 双击托盘图标
//------------------------------------------------------------------------------
procedure TfrmMain.trayDblClick(Sender: TObject);
begin
if frmMain.Showing then frmMain.Hide
else
frmMain.Show;
end;