ysTrayIcon); //将
程序图标加入系统托盘区
with lvSysProc do
begin
SmallImages:=TImageList.CreateSize(16,16);
SmallImages.ShareImages:=True;
end;
FormOldWidth:=self.Width;
FormOldHeight:=self.Height;
end;
//最小化时自动隐藏
procedure Tform1.AppOnMinimize(Sender:TObject);
begin
ShowWindow(application.handle,SW_HIDE);
end;
//响应鼠标在系统托盘区图标上点击
procedure tform1.SysTrayOnClick(var message:TMessage);
begin
with message do
begin
if (lparam=wm_lbuttondown) or (lparam=wm_rbuttondown) then
begin
application.restore;
SetForegroundWindow(Handle);
showwindow(application.handle,SW_HIDE);
end;
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Shell_NotifyIcon(NIM_DELETE,@SysTrayIcon); //取消系统托盘区图标
RegisterServiceProcess(GetcurrentProcessID,0); //取消系统服务
程序的注册
lvSysProc.SmallImages.Free;
end;
//不活动时自动隐藏
procedure TForm1.FormDeactivate(Sender: TObject);
begin
application.minimize;
end;
procedure TForm1.lblEmailClick(Sender: TObject);
begin
if ShellExecute(Handle,''Open'',Pchar(''Mailto:purpleendurer@163.com''),nil,nil,SW_SHOW)<33 then
MessageBox(form1.Handle,''无法启动电子邮件软件!'',''我很遗憾'',MB_ICONINFORMATION+MB_OK);
end;
//当窗体大小改变时调整各组件位置
procedure TForm1.FormResize(Sender: TObject);
begin
with panel1 do top:=top+self.Height-FormOldHeight;
with lvSysProc do
begin
width:=width+self.Width-FormOldWidth;
end;
with lvAboutProc do
begin
height:=height+self.Height-FormOldHeight;
width:=width+self.Width-FormOldWidth;
end;
FormOldWidth:=self.Width;
FormOldHeight:=self.Height;
end;
end.
以上
程序在Delphi 2,Windows 95中文版和Delphi 5,Windows 97中文版中均能正常编译和运行。大家有什么
问题请Email to:purpleendurer@163.com与我讨论。
作者:黄志斌
广西河池地区经济学校 邮编:547000
Email: purpleendurer@163.com