用搜索在论坛上找一下,多得很

解决方案 »

  1.   

    var
      ICONData : TNotifyICONData;...........
    在oncreate里写
    with ICONData do begin
         cbsize := sizeof(icondata);
         wnd := self.handle;
         uid := 0;
         uflags := nif_icon or nif_message or nif_tip;
         ucallbackmessage:=MI_ICONEVEN;
         hicon := application.icon.handle;
         strcopy(szTip,pchar('................'));
       end;
       Shell_NotifyICON(Nim_add,@icondata);
    close时别忘了
      Shell_Notifyicon(nim_delete,@icondata);
    还要处理在图标上的鼠标左右键
    自定义一个消息
    procedure WMICONClick(var message: TMessage);message MI_ICONEVEN;procedure TForm1.WMICONClick(var message: TMessage);
    var p : TPoint;
    begin
      GetCursorPos(P);
      Case Message.LParam  of
      WM_LBUTTONDOWN:
        begin
          SetForegroundWindow(Application.Handle);
          Application.ProcessMessages; //哈哈哈哈哈; 好,好!!!
          PopupMenu1.Popup(p.x , p.y);
        end;
    //  WM_LBUTTONDBLCLK:
      WM_RBUTTONDOWN:
        begin
          SetForegroundWindow(Application.Handle);
          Application.ProcessMessages;
          PopupMenu2.Popup(p.x,p.y);
        end;
      end;
    end;