各位大虾:
   请问如何实现类似qq的托盘图标,即图标出现在任务栏的右下角,然后可以操纵右下角的图标(如单击右健出现选择菜单)。
  应该比较简单吧,先谢谢大家先

解决方案 »

  1.   

    完整代码
    unit fshbx;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, shellapi,
      Menus, ExtCtrls;const WM_NOTIFYICON = WM_USER + 1;
    type
      Tserverfrom = class(TForm)
        PopupMenu1: TPopupMenu;
        about1: TMenuItem;
        exit1: TMenuItem;
        Timer1: TTimer;
        procedure exit1Click(Sender: TObject);
        procedure about1Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
        procedure Timer1Timer(Sender: TObject);
      private
        check: string;
        Notifydata: Tnotifyicondata;
        procedure addicon;
        procedure removeicon;
        { Private declarations }
      protected
        procedure onnotifyicon(var message: TMessage); message WM_NOTIFYICON;
      public
        { Public declarations }
      end;
    var
      serverfrom: Tserverfrom;implementation{$R *.DFM}procedure Tserverfrom.addicon;
    begin
      notifydata.cbSize := sizeof(notifydata);
      with notifydata do
      begin
        wnd := handle;
        uid := 1;
        uflags := NIF_TIP or NIF_ICON or NIF_MESSAGE;
        hicon := application.Icon.Handle;
        sztip := '应用服务器';
        ucallbackmessage := WM_NOTIFYICON;
      end;
      shell_notifyicon(NIM_ADD, @notifydata);
    end;procedure Tserverfrom.removeicon;
    begin
      notifydata.uID := 1;
      shell_notifyicon(NIM_DELETE, @notifydata);
    end;procedure Tserverfrom.onnotifyicon(var message: Tmessage);
    var
      mousepos: Tpoint;
    begin
      if message.lparam = WM_LBUTTONDBLCLK then
        showmessage('不要乱动!');
      if message.lparam = WM_LBUTTONDBLCLK then
        showmessage('左键双击');
      if (message.lparam = WM_RBUTTONDBLCLK) then
      begin
        getcursorpos(mousepos);
        setforegroundwindow(application.handle);
        application.ProcessMessages;
        popupmenu1.Popup(mousepos.x, mousepos.y);
      end;
    end;procedure Tserverfrom.exit1Click(Sender: TObject);
    begin
      removeicon;
      close;
    end;procedure Tserverfrom.about1Click(Sender: TObject);
    begin
      showmessage('应用服务器');
    end;procedure Tserverfrom.FormCreate(Sender: TObject);
    begin
      addicon;
      showwindow(application.handle, SW_HIDE);
      Application.ShowMainForm := False;
      check :='-255';
    end;procedure Tserverfrom.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      removeicon;
    end;procedure Tserverfrom.Timer1Timer(Sender: TObject);
    begin
      removeicon;
      if check = '-255' then
      begin
        Application.Icon.LoadFromFile('D:\delphivcl\ico\ico\Funny\grrr!.ico');
        check :='0';
      end
      else
      begin
        Application.Icon.LoadFromFile('D:\delphivcl\ico\ico\Funny\mr remote.ico');
        check :='-255';
      end;
      addicon;
    end;end.
      

  2.   

    先谢过,兄台(huayuxing)应该是delphi高手吧,不知是否知道Delphi中如何实现文件的加密
      

  3.   

    sorry ,i'm not ganshou, just like you