{......}
Const
  Wm_TrayIconCallBack = Wm_User + 1000;
{......}    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    MyTrayIcon: TNotifyIconData;
    Procedure WmTrayIconCallBack(Var Msg:TMessage);Message Wm_TrayIconCallBack;  procedure TForm1.FormCreate(Sender: TObject); 
  begin
    FillChar(MyTrayIcon,SizeOf(TNotifyIconData),0);
    with MyTrayIcon do begin
      CbSize := Sizeof(TNotifyIconData);
      Wnd := Handle;
      uId := 1;
      uFlags:=uFlags or NIF_MESSAGE or NIF_ICON or NIF_TIP;
  //    uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
      uCallbackMessage := Wm_TrayIconCallback;
 
      hIcon := Application.Icon.Handle;      szTip := '提示';
      Shell_NotifyIcon(Nim_add,@MyTrayIcon);
    end;
  end;  procedure TForm1.FormDestroy(Sender: TObject); 
  begin
    Shell_NotifyIcon(Nim_Delete,@MyTrayIcon);
  end;  procedure TForm1.WmTrayIconCallBack(var Msg: TMessage); 
  Var
    P:TPoint;
  begin
  Case Msg.LParam of
    Wm_LButtonUp:
      begin
        if AppVisible = False then
          //在ApplicationEvents.OnMinimize和OnRestore中设定其值
          Application.Restore ;
          SetforegroundWindow(Application.Handle);//左键隐藏或恢复
      end;
    Wm_RbuttonUp:
      begin
        GetCursorPos(P);
        PopTray.Popup(P.x,P.y);//右键弹出菜单
      end;
  end;
  end;

解决方案 »

  1.   

     nid :NOTIFYICONDATA;
     icon :TICON;
    begin
     Icon := TIcon.Create;
     Icon.LoadFromFile('MDIChild1.ICO');
     nid.cbSize :=sizeof(NOTIFYICONDATA);
     nid.Wnd := handle;
     nid.uID :=1;//
     nid.uFlags :=NIF_ICON or NIF_TIP;
    nid.hIcon :=icon;
    lstrcpyn(nid.szTip ,'0k',2);
    Shell_NotifyIcon(NIM_ADD,&nid);
    end ;
      

  2.   

    sorry,我上面的程序一启动就建立图标到托盘,不过我想你改一改就可以实现你要的功能了!
      

  3.   

    Guoxc(大浪乘风)'s Opion is correct.Sometimes ago,I completed it with vc.
    But the principle is the same.
    Use Shell_NotifyIcon WinAPI