给我;谢了
[email protected]

解决方案 »

  1.   

    也给我一个吧;谢了
    [email protected]
      

  2.   

    前天刚写的一个类似的程序 正好贴出来吧 ^^
    uses ShellApi;const WM_TRAYNOTIFY=WM_USER+1;  private
        { Private declarations }
      public
      procedure WndProc(var Msg: TMessage); override ;   { Public declarations }    { Public declarations }procedure TFrmMain.FormCreate(Sender: TObject);
         nid:TNotifyIconData;
    beginnid.cbSize := sizeof(nid); // nid变量的字节数
    nid.Wnd := Handle; // 主窗口句柄
    nid.uID :=771021;
    nid.hIcon := Image1.Picture.Icon.Handle;//Application.Icon.Handle; // 要加入的图标句柄,可任意指?
    nid.szTip := '公路卡口'; // 提示字符串
    nid.uCallbackMessage := WM_TRAYNOTIFY; // 回调函数消息
    nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; // 指明哪些字段有?if not Shell_NotifyIcon(NIM_ADD,@nid) then
       begin
       ShowMessage('Failed!');
       Application.Terminate ;
       end;
    SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);end;
    procedure Tfrmmain.WndProc(var Msg: TMessage);
    var
    IconID:integer;
    pt:TPOINT;
    beginif msg.Msg = WM_TRAYNOTIFY thenbegin{在通知消息中,wParam参数为图标的uID,lParam参数为鼠标事件的类型。}iconID := msg.WParam;//获取鼠标的在屏幕上的位置GetCursorPos(pt);
    //通知消息的处理的基本框架结构如下:case msg.lParam ofWM_LBUTTONDOWN:begin//鼠标右键被按下end;WM_RBUTTONDOWN:begin//鼠标左键被按下end;WM_LBUTTONUP:begin//释放左键 ;end;WM_RBUTTONUP:begin PopupMenu.Popup(pt.x,pt.y); //释放鼠标右键end;WM_MOUSEMOVE:begin//鼠标在图标上移动end;WM_LBUTTONDBLCLK:beginShow;//鼠标左键双击end;WM_RBUTTONDBLCLK:begin//鼠标右键双击end;end; //end caseendelse//调用父类的WndProc方法处理其它消息inherited;end;
      

  3.   

    我也可以给你一个例子,不算太好,但是起码有托盘的例子
    主要使用sheel_api
      

  4.   

    const
        WM_TrayMessage=WM_User+100;  protected
          procedure AppMinimized(Sender: TObject);
          procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage;uses ShellApivar
      NID:TNotifyIconData{点击了任务栏的图标}
    procedure TMainForm.WMTrayMessage(var msg:TMessage);
    var
      p:TPoint;
    begin
      if msg.LParam=WM_LButtonDown then
      begin
        ShowWindow(Application.Handle,SW_Show);
        Application.Restore;
      end
      else if msg.LParam=WM_RButtonDown then
      begin
        GetCursorPos(p);
        pmTray.Popup(p.x,p.y);
      end;
    end;{应用程序最小化时图标显示在任务栏}
    procedure TMainForm.AppMinimized(Sender:TObject);
    begin
      NID.cbSize:=SizeOf(TNotifyIconData);
      NID.hIcon:=Application.Icon.Handle;
      NID.szTip:= '彩虹2.0 Beta ';
      NID.uCallbackMessage:=WM_TrayMessage;
      NID.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
      NID.uID:=0;
      NID.Wnd:=Handle;
      Shell_NotifyIcon(NIM_ADD,@NID);
      ShowWindow(Application.Handle,SW_Hide);
    end;procedure TMainForm.FormCreate(Sender: TObject);
    begin
      Application.OnMinimize:=AppMinimized;
      AppMinimized(nil);
    end;procedure TMainForm.FormDestroy(Sender: TObject);
    begin
      Shell_NotifyIcon(NIM_DELETE,@NID);
    end;