打印本文 打印本文 关闭窗口 关闭窗口
TNotifyIcon 控件1.01
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1338  更新时间:2009/4/23 18:39:57  文章录入:mintao  责任编辑:mintao
Control(AOwner).Handle;
 New(Fpda);
  With FPda^ do
  begin
    uCallbackMessage:=WM_MY_Notify;
    cbsize:=SizeOf(FPda^);
    uID:=200;
    wnd:=Handle;
    uFlags:=NIF_ICON+NIF_Tip+NIF_MESSAGE;
   end;

if (csDesigning in ComponentState) then
begin
 if GetUserDefaultLCID =
MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED) then
      Application.MessageBox(
    ''''Write by 南昌大学 付昱纲''''#13#13''''E-mail:fyg@163.net''''#13#13''''
1998.8.17'''',
    ''''TNotifyIcon 控件 V 1.01'''',MB_OK+ MB_ICONINFORMATION)
 else
      Application.MessageBox(
    ''''Write by NanChang University
FuYuGang''''#13#13''''E-mail:fyg@163.net''''#13#13''''           1998.8.17'''',
    ''''TNotifyIcon Component V 1.01'''',MB_OK+ MB_ICONINFORMATION);
end;
 except
  ShowMessage(''''TNotifyIcon Create error'''');
 end;
end;

procedure TNotifyIcon.SetIcon(Icon:TICON);
begin
 FIcon.Assign(Icon);
end;

procedure TNotifyIcon.ShowIcon;
begin
try
 if FIcon.Handle=0 then
 begin
    Exit;
 end;
 if FIcon.Handle<>FPda^.hIcon then
       HideIcon;
 if FIconVisible=false then
 begin
  FPda^.hIcon:=FIcon.handle;
  FIconVisible:=true;
   Shell_NotifyIcon(NiM_ADD,FPda);
 end;
except
 ShowMessage(''''TNotifyIcon Show Error '''');
end;
end;

procedure TNotifyIcon.HideIcon;
begin
try
 if FIconVisible then
 begin
  FIconVisible:=false;
  Shell_NotifyIcon(NiM_DELETE,FPda);
 end;
except
 ShowMessage(''''TNotifyIcon Hide Error'''');
end;
end;

procedure TNotifyIcon.SetTitle(NewTitle:string);
begin
 FTitle:=NewTitle;
 StrCopy(FPda^.szTip,PChar(FTitle));
 if FIconVisible then
 begin
   HideIcon;
   ShowIcon;
 end;
end;

destructor TNotifyIcon.Destroy;
begin
try
  HideIcon;
  Dispose(FPda);
  FIcon.Free;
 inherited Destroy;
except
 ShowMessage(''''TNotifyIcon Destroy Error'''');
end;
end;

procedure TNotifyIcon.ModifyIcon(NewIcon:TIcon);
begin
try
 SetIcon(NewIcon);
 FPda^.hIcon:=FIcon.handle;
 if FIconVisible  then
   Shell_NotifyIcon(NiM_Modify,FPda);
except
 ShowMessage(''''TNotifyIcon Modify Error'''');
end;
end;

function TNotifyIcon.IsShowing:boolean;
begin
  Result:=FIconVisible;
end;

end.

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口