我为程序做了一个菜单,希望能够让用户选择是否有系统托盘,但是不知道具体怎么实现?
往高手来帮忙。procedure TMain.N14Click(Sender: TObject);
begin
    if (sender as TMenuITem).Checked then
      begin
         //Main.Destroy;
         //Main.Create(Application);
         Shell_NotifyIcon(NIM_ADD,@nid);
         //SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
         ShowWindow(Application.Handle,SW_Hide);
         if not Shell_NotifyIcon(NIM_ADD, @nid) then
           begin
             ShowMessage('Failed!');
             Application.Terminate;
           end;
      end
    else
        nid.cbSize := sizeof(nid); 
        nid.uID :=0; 
        nid.Wnd := Handle; 
        Shell_NotifyIcon(NIM_DELETE,@nid);
       (sender as TMenuITem).Checked :=not (sender as TMenuITem).Checked ;
我现在写的程序就是这样,没有实现,TNotifyIconData的实例结构我我已经在FormCreate声明了。

解决方案 »

  1.   

    用CoolTrayIcon组件,容易啦http://lysoft.7u7.net
      

  2.   

    uses shellapi;
    const 
      mymsg=Wm_user+1;
    var nid:tnotifyicondata;
    procedure TForm1.N2Click(Sender: TObject);
    begin
      N2.Checked:=not N2.Checked;
      if N2.Checked then
        begin
          nid.cbSize:=sizeof(tnotifyicondata);
          nid.Wnd:=handle;
          nid.uID:=0;
          nid.uFlags:=nif_message or nif_icon or nif_tip;
          nid.uCallbackMessage:=mymsg;
          nid.szTip:='ÄýÁ¦Èí¼þ¿¼ÇÚϵͳ';
          nid.hIcon:=form1.Icon.Handle;
          shell_notifyicon(nim_add,@nid);
        end
      else
        begin
          shell_notifyicon(nim_delete,@nid);
        end;
    end;
      

  3.   

    CoolTrayIcon组件?哪里有,等会去找找~
      

  4.   

    CoolTrayIcon到处都是,如果谁不想找的话加我的QQ 12416204我给你一个。
      

  5.   

    CoolTrayIcon,你可以到盒子上去下载,园地也有啊.
      

  6.   

    到盒 上了去下载CoolTrayIcon,很好用的东东。而且还有例子
      

  7.   

    谢谢!jiaai(逍遥游) 已经实现了!但是能不能告诉我,为什么我的代码就不能实现呢?我觉得两段代码大同小异啊。
     ly_liuyang(Liu Yang) 也谢谢你,但是如果能自己用代码实现,我想还是尽量不要用其他人的组件。
      

  8.   

    win98下 CoolTrayIcon 有些功能不能用,例如提示框,有没有解决办法