我写了一个TrayIcon的构件,装一下就行了

解决方案 »

  1.   

    使用use shellApI然后看帮助吧,很简单的。
      

  2.   

    可以到DELPHI深度32历险下一个构件
    http://vcl.vclxx.org
      

  3.   

    这里就有的。
    http://www.csdn.net/Dev/Delphi/
    系统->trayicon 控件。非常好的。
      

  4.   

    使用托盘区的关键是shellapi中的TNotifyIconData和Shell_NotifyIcon涵数。
    为实现动态图标,你可以在一个ImageList中准备几幅图片,在Timer事件中用ImageList
    中的图片修改托盘中的图标。以下是程序示例:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,ShellAPI,
      ImgList, ExtCtrls;const
      WM_MYTRAYICONCALLBACK = WM_USER + 1000;type  TForm1 = class(TForm)
        Timer1: TTimer;
        ImageList1: TImageList;
        procedure FormCreate(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
        MyTrayIcon : TNotifyIconDataA;
        IconIndex : integer;
        CurrentIcon : TIcon;
        procedure WMMyTrayIconCallBack(var Msg : TMessage);message WM_MYTRAYICONCALLBACK;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}{ TForm1 }procedure TForm1.WMMyTrayIconCallBack(var Msg: TMessage);
    begin
      case Msg.LParam of
        WM_LBUTTONDBLCLK :
        begin
          visible := not visible;
          Application.ShowMainForm := visible;
          SetForegroundWindow(Application.Handle);
        end;
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      IconIndex := 0;
      CurrentIcon := TIcon.Create;
      ImageList1.GetIcon(IconIndex,CurrentIcon);
      MyTrayIcon.cbSize := Sizeof(TNotifyIconDataA);
      MyTrayIcon.Wnd := handle;
      MyTrayIcon.uId := 1;
      MyTrayIcon.uFlags := NIF_ICON OR NIF_TIP OR NIF_MESSAGE;
      //MyTrayIcon.uCallbackMessage := WM_MYTRAYICONCALLBACK;
      //MyTrayIcon.hIcon := Application.Icon.Handle;
      MyTrayIcon.hIcon := CurrentIcon.Handle;
      MyTrayIcon.szTip := '托盘示例程序';
      if not Shell_NotifyIcon(NIM_ADD,@MyTrayIcon) then
        ShowMessage('创建托盘图标失败!');
      
    end;procedure TForm1.FormDestroy(Sender: TObject);
    begin
      Shell_NotifyIcon(NIM_DELETE,@MyTrayIcon);
      CurrentIcon.Free;
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      ImageList1.GetIcon(IconIndex,CurrentIcon);
      Application.Icon := CurrentIcon;
      if IconIndex < 9 then
        Inc(IconIndex)
      else
        IconIndex := 0;
      
      MyTrayIcon.hIcon := CurrentIcon.Handle;
      if not Shell_NotifyIcon(NIM_MODIFY,@MyTrayIcon) then
        ShowMessage('修改托盘图标失败!');
    end;  
      

  5.   

    我恰好 前几天也做了这样的尝试 可以和你分享一下
    和shuyi说的一样...usesShellAPIconst  WM_TRAYNOTIFY=WM_USER+1;...  public
        { Public declarations }
       procedure WndProc(var Msg: TMessage); override;var...nd0:NotifyIconData;
      hs:LongWord;implementation....procedure Tform1.FormCreate(Sender: TObject);
    begin
    hs:=Application.icon.Handle;//填充NotifyIconData记录型变量nd0
      nd0.cbSize := sizeof(NotifyIconData);
      nd0.Wnd := handle;
      nd0.uID := 0;
      nd0.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
      nd0.uCallbackMessage := WM_TRAYNOTIFY;
      nd0.hIcon := hs;
      StrPLCopy(nd0.szTip, '名字', 63); // 在任务栏状态区添加图标
     Shell_NotifyIcon(NIM_ADD, @nd0);
    end;procedure Tform1.FormDestroy(Sender: TObject);
    begin
     Shell_NotifyIcon(NIM_DELETE, @nd0);
    end;
    procedure Tform1.WndProc(var Msg: TMessage);
    var
      IconID:integer;
      pt:TPOINT;
    begin
      if msg.Msg = WM_SIZE then
      begin
       if msg.wParam=SIZE_MINIMIZED  then visible:=false
      end
      else
      begin  if msg.Msg = WM_TRAYNOTIFY then
      begin
      {
      在通知消息中,wParam参数为图标的uID,
      lParam参数为鼠标事件的类型。
      }
        iconID := msg.WParam;
        //获取鼠标的在屏幕上的位置
        GetCursorPos(pt);  //通知消息的处理的基本框架结构如下:
        case msg.lParam of
          WM_LBUTTONDOWN:
          begin
            //鼠标右键被按下
          end;
          WM_RBUTTONDOWN:
          begin
            //鼠标左键被按下
          end;
          WM_LBUTTONUP:
          begin
            //释放鼠标左键
          end;
         WM_RBUTTONUP:
          begin
            //释放鼠标右键
          end;
          WM_MOUSEMOVE:
          begin
            //鼠标在图标上移动
          end;
          WM_LBUTTONDBLCLK:;//鼠标左键双击
                begin
              if visible then visible:=false
              else visible:=true;
            end;
          WM_RBUTTONDBLCLK:
          begin
            //鼠标右键双击
          end;
        end; //end case
      end
      else//调用父类的WndProc方法处理其它消息
        inherited;
      end;
    end;
      

  6.   

    谢谢各位,我试了ameng007(阿门)程序和comsun(comsun)控件,是会在右下角状态栏出现图标,但还是达不到c++builder 的TrayIcon1的功能。因为最小化时状态栏会同时出现两个图标,我是要达到最小化时,只有右下角的图标,请各位指教!!!
      

  7.   

    仔细研究API函数Shell_NotifyIcon的功能,你自然明白
      

  8.   

    to chime:
    跟你说了去看看ShellAPI你要的效果都可以实现。