留e-mail,我发个控件和例子给你。

解决方案 »

  1.   

    http://www.torry.net/vcl/system/trayicons/tstrayv1.zip
      

  2.   

    procedure TFormNotice.FormCreate(Sender: TObject);
    var
     Sicon:TnotifyIconData;
    begin
    SBexpend.Glyph.LoadFromResourceName(HInstance,'EXPEND0');
    {Application.OnMinimize:=Onmin;  //设置处理最小化的过程 }
    //隐藏任务栏图标
    SetWindowLong(Application.Handle,
    GWL_EXSTYLE, WS_EX_TOOLWINDOW);
    //加图标到系统托盘
     with Sicon do
     begin
      cbSize:=Sizeof(TnotifyIconData);
      Wnd:=Handle;
      UID:=MY_TRAY_ICON;
      uFlags:=NIF_MESSAGE or NIF_ICON or NIF_TIP;
      ucallbackMessage:=WM_TrayNotify;
      hIcon:=application.icon.Handle;
      Shell_NotifyIcon(NIM_ADD,@Sicon);//前边设置图标的各属性;这句
                                      //加到图标栏!
     end;
    end;
    //响应系统图标的鼠标事件
    procedure TFormNotice.WmTRayNotify(var Msg:Tmessage);
    var
     mousept: TPoint; //鼠标点击位置
    begin
    if (msg.LParam=WM_RbuttonDown) then
    begin
    getCursorPos(mousept);
     popupmenu1.Popup(mousept.x,mousept.y);
    end;
    if (Msg.LParam=WM_LBUTTONDBLCLK) then
     begin
      showwindow1Click(self);
     end;
    end;//加个popupmenu,showwindow 和exit两个菜单项对应以下操作
    procedure TFormNotice.showwindow1Click(Sender: TObject);
    begin
      showWindow(Application.Handle,SW_SHOW);
      application.Restore;
    end;//结束程序时记得注销icon;
    procedure TFormNotice.exit1Click(Sender: TObject);
    var
     Sicon:TnotifyIconData;
    begin
      with Sicon do
     begin
      cbSize:=Sizeof(TnotifyIconData);
      Wnd:=Handle;
      UID:=MY_TRAY_ICON;
      uFlags:=NIF_MESSAGE or NIF_ICON or NIF_TIP;
      ucallbackMessage:=WM_TrayNotify;
     end;
     Shell_NotifyIcon(NIM_Delete,@Sicon);
     Application.Terminate;
    end;