如何用最简单的方法使application只显示成系统托盘,而不出现在任务栏。

解决方案 »

  1.   

    送你一个很好用的控件,不用你写一句代码:
    http://liulangren.xiloo.com/compdown/cooltray4.3.rar
    我经常用它!
      

  2.   

    最好不要用控件了,这个本来就很简单的
    uses ShellAPI;var
    ServerTrayIconData : TNotifyIconData;
    在FormCreate中写
      ServerTrayIconData.cbSize := SizeOf(ServerTrayIconData);
      ServerTrayIconData.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
      ServerTrayIconData.uID := UINT(Self);
      ServerTrayIconData.Wnd := Handle;
      ServerTrayIconData.hIcon := Application.Icon.Handle;
      ServerTrayIconData.szTip := '服务器端';
      ServerTrayIconData.uCallbackMessage := SERVER_TRAY_MESSAGE;
      Shell_NotifyIcon(NIM_ADD, @ServerTrayIconData);
    在FormActivate中写
    Application.Minimize;
    放一个
    ApplicationEvents控件在Additional页面上
    在它的onMinimize事件中写
    ShowWindow(Application.Handle, SW_HIDE);就好了,如果要点击托盘做出反应就要加消息const
      SERVER_TRAY_MESSAGE = WM_USER + 100;    procedure ServerTrayMessage(var Message: TMessage); message SERVER_TRAY_MESSAGE;
    procedure TMainForm.ServerTrayMessage(var Message: TMessage);
    begin
      if Message.Msg = SERVER_TRAY_MESSAGE then
      begin
        case Message.LParam of
          WM_LBUTTONDBLCLK:
          begin
            if IsIconic(Application.Handle) then begin
              ShowWindow(Application.Handle, SW_NORMAL);
              SetForegroundWindow(Application.Handle);
            end;
          end;
        end;
      end;
    end;
    就好了不用外部控件的
      

  3.   

    托盘程序按照楼上的来做
    在任务栏不显示窗体用
    Application.ShowMainForm := false;
    or
    SetWindowLong(handle,gwl_exstyle,ws_ex_toolwindow);