如何将我的程序放入托盘

解决方案 »

  1.   

    送你一个控件,非常管用,我经常用他,不用您写一句代码http://liulangren.xiloo.com/compdown/cooltray4.3.rar
      

  2.   

    太多了…… 去下一个 CoolTrayIcon 设置几下属性,都不用写代码。
      

  3.   

    这个可以自己来写程序实现,也可以用控件。
    Shell_NotifyIcon
      

  4.   

    http://liulangren.xiloo.com/compdown/cooltray4.3.rar我没打开?
    楼上的,能仔细讲讲吗?
      

  5.   

    unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs,ShellAPI, StdCtrls, Menus;
    const WM_NID=WM_USER+1000;
    type
        TForm2 = class(TForm)
        PopupMenu1: TPopupMenu;
        procedure FormCreate(Sender: TObject);
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
        NotifyIcon:TNotifyIconData;
        procedure WMNID(var msg:TMessage);message WM_NID;
      public
        { Public declarations }
      end;var
      Form2: TForm2;implementation{$R *.dfm}procedure TForm2.FormCreate(Sender: TObject);
    Begin
      //NotifyIcon为全局变量,在程序的开头已经定义了 
      with NotifyIcon do
      begin
      cbSize:=SizeOf(TNotifyIconData);
      Wnd:=Handle;   //指向当前窗体Form1的句柄 
      uID:=1;
     uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
      uCallBackMessage:=WM_NID;
      hIcon:=Application.Icon.Handle;
      szTip:='张家恶少';
    end;
    //把设置好的变量NotifyIcon加入到系统中以便处理 
      Shell_NotifyIcon(NIM_ADD,@NotifyIcon);End;
    procedure tform2.WMNID(var msg:TMessage);
    begin
      case msg.LParam of
           WM_LBUTTONUp:Form2.Visible:=not Form2.Visible;
           //WM_RBUTTONUP: ShowMessage('您点击的是右键');
           WM_RBUTTONUP:
           begin
             PopupMenu1.Popup(mouse.CursorPos.X,mouse.CursorPos.Y);
           end;
      End;
    End;
    end.