计算机二级Delphi控件:简单的系统托盘组件
来源:优易学  2011-6-5 16:50:51   【优易学:中国教育考试门户网】   资料下载   IT书店

 

  procedure TTrayIcon.DelTrayIcon;
  begin
  Shell_NotifyIcon(NIM_DELETE, @IconData);
  end;
  destructor TTrayIcon.Destroy;
  begin
  Visible := False;
  Classes.DeallocateHWnd(FHandle);
  inherited;
  end;
  procedure TTrayIcon.SetTrayIcon;
  begin
  IconData.hIcon := Application.Icon.Handle;
  StrLCopy(IconData.szTip, PChar(Application.Title), SizeOf(IconData.szTip)-1);
  IconData.szTip[SizeOf(IconData.szTip)-1] := #0;
  end;
  procedure TTrayIcon.Loaded;
  begin
  inherited Loaded;
  if csDesigning in ComponentState then Exit;
  if FVisible then AddTrayIcon;
  end;
  procedure TTrayIcon.SetVisible(const Value: Boolean);
  begin
  if Value <> FVisible then
  begin
  FVisible := Value;
  if csDesigning in ComponentState then Exit;
  if Value then AddTrayIcon else DelTrayIcon;
  end;
  end;
  procedure TTrayIcon.WndProc(var Message: TMessage);
  begin
  with Message do
  if Msg = WM_TRAYICONEVENT then
  try
  case LParam of
  WM_LBUTTONUP:
  if Assigned(FOnClick) then FOnClick(Self);
  WM_RBUTTONUP:
  if Assigned(FOnRightClick) then FOnRightClick(Self);
  end;
  except
  Application.HandleException(Self);
  end
  else Result := DefWindowProc(FHandle, Msg, WParam, LParam);
  end;
  end.

上一页  [1] [2] 

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训