我想让目标程序隐藏到后台,然后在右小角显示个图表, 点他就出出来
谁能提供下实现方法
我的油箱:[email protected]

解决方案 »

  1.   

       const
      MY_MESSAGE = WM_USER + 78;  //托盘图标返回消息
      MM_SHOW = WM_USER + 199;  //托盘图标返回消息    private
     Fnid : PNotifyIconDataA; 
    New(Fnid);
      with Fnid^ do
      begin
        Wnd := Handle;
        uID := 0;
        uFlags := NIF_ICON + NIF_MESSAGE + NIF_TIP;
        hIcon := Application.Icon.Handle;
        uCallbackMessage := MY_MESSAGE;
        StrPCopy(szTip,Application.Title);
        szTip :='讯鲨VPN';
      end;
      Shell_NotifyIcon(NIM_ADD, Fnid);
      //注册任务栏图标。
      Application.OnMinimize:=OnMinimize;退出程序时要记得释放
      Shell_NotifyIcon(NIM_DELETE, Fnid);
      

  2.   

    rxlib组件包里的RXTrayIcon下载地址
    http://www.winu.cn/thread-1666-1-1.html
    1、设置RXTrayIcon的icon和icons
    2、给popupmenu关联一个右键菜单
    3、在它的onDblClick事件中写一下代码
    procedure TFormMain.RxTrayIcon1DblClick(Sender: TObject);
    begin
     ShowWindow(Application.Handle, SW_RESTORE);
     setwindowpos(application.handle,HWND_TOPMOST,0,0,0,0,swp_hidewindow);
    end;
      

  3.   

    给楼主贴一段代码看看: unit Unit1; interface uses 
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
      Dialogs,ShellAPI, ImgList, Menus; const WM_NOTIFY = WM_USER + 101;      // TRAY消息 
          WM_TOOLTRAYICON = WM_USER+1; 
    type 
      TfrmMain = class(TForm) 
        imlToolbar: TImageList; 
        PopupMenu1: TPopupMenu; 
        N1: TMenuItem; 
        procedure FormCreate(Sender: TObject); 
        procedure N1Click(Sender: TObject); 
      private 
        { Private declarations } 
            procedure OnAppMinimize(Sender: TObject); // 应用程序最小化响应函数 
            procedure  OnNotify(var Msg : TMessage); message WM_NOTIFY; 
            procedure ToolMSG(var Msg: TWMSYSCOMMAND); Message WM_TOOLTRAYICON; 
      public 
        { Public declarations } 
      end; var 
      frmMain: TfrmMain; 
      NotifyIcon : TNotifyIconData; implementation {$R *.dfm} procedure TfrmMain.FormCreate(Sender: TObject); 
    var 
       Icon : TIcon; 
    begin         // 
            //NotifyIcon为全局变量,在程序的开头已经定义了 
            // 
            with NotifyIcon do 
            begin 
                    cbSize:=SizeOf(TNotifyIconData); 
                    Wnd:=Handle;   //指向当前窗体frmMain的句柄 
                    uID:=1; 
                    uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP; 
                    uCallBackMessage:=WM_NOTIFY; 
                    hIcon:=Application.Icon.Handle; 
                    icon := TIcon.Create(); 
                    frmmain.imlToolbar.GetIcon(0, icon); 
                    hIcon := icon.Handle; 
                    szTip:= '短信程序 '; 
            end; 
                    Application.OnMinimize := OnAppMinimize; 
    end; // 
    // 应用程序最小化时调用此函数 
    // 
    procedure TfrmMain.OnAppMinimize(Sender: TObject); 
    begin 
    //        if Config.m_Config.m_Hide then 
     //       begin 
                    frmMain.Visible := False; 
                    // 
                    // 把设置好的变量NotifyIcon加入到系统中以便处理 
                    // 
                   Shell_NotifyIcon(NIM_ADD,@NotifyIcon); 
     //       end; 
    end; // 
    // 托盘图标响应事件 
    // 
    procedure TfrmMain.OnNotify(var Msg: TMessage); 
    var 
            pos : TPoint; 
    begin 
            case Msg.LParam of 
                    WM_LBUTTONDBLCLK:   // 双击事件 
                    begin 
                            frmMain.Visible := True ; 
                            Shell_NotifyIcon(NIM_DELETE,@NotifyIcon); 
                            Application.Restore(); 
                            SetForegroundWindow(frmMain.Handle); 
                    end; 
                    WM_RBUTTONUP:       // 右键点击 
                    begin 
                            GetCursorPos(pos); 
                            frmMain.PopupMenu1.Popup(pos.X, pos.Y); 
                    end; 
            End; 
    end; procedure TfrmMain.N1Click(Sender: TObject); 
    begin 
    close; 
    end; procedure TfrmMain.ToolMSG(var Msg: TWMSYSCOMMAND); 
    begin 
         if (Msg.Msg = WM_TOOLTRAYICON) and 
            (Msg.Key = WM_LBUTTONDBLCLK) then 
             showwindow(application.handle,sw_show); 
    end; end.  
      

  4.   

    rxlib组件包 下不了  谁能提供下 谢谢 我是D7 最好有安装说明  我还没用过第3方空间呢 谢谢
      

  5.   

    http://www.delphifans.com/infoview/Article_29.html 安装说明
    http://www.tomore.com/2/2083.html 下载地址4条裤衩就看你的啦
      

  6.   

    //给你一个例子参考
    //运行后在托盘出现图标,在图标有右键菜单,可以显示,最小化,退出程序。
    unit main;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
       ShellAPI, StdCtrls, Menus;
    const
      WM_MYTRAYICONCALLBACK = WM_USER + 1000;type
      TForm1 = class(TForm)
        PopupMenu1: TPopupMenu;
        N1: TMenuItem;
        N2: TMenuItem;
        N3: TMenuItem;
        N4: TMenuItem;
        procedure N1Click(Sender: TObject);
        procedure N2Click(Sender: TObject);
        procedure N3Click(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
        MyTrayIcon: TNotifyIconData;
        procedure WMMyTrayIconCallback (var Msg: TMessage); message WM_MYTRAYICONCALLBACK;  public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.N1Click(Sender: TObject);
    begin
      Self.Visible := True;
      Application.ShowMainForm := Visible;end;procedure TForm1.N2Click(Sender: TObject);
    begin
    Self.Visible := False;
      Application.ShowMainForm := Visible;end;procedure TForm1.N3Click(Sender: TObject);
    begin
       Application.Terminate;end;procedure TForm1.FormDestroy(Sender: TObject);
    begin
      Shell_NotifyIcon(NIM_DELETE,@MyTrayIcon);
    end;procedure TForm1.WMMyTrayIconCallback(var Msg: TMessage);
    var
      pPos: TPoint;
    begin
      case Msg.LParam of
        WM_LBUTTONDBLCLK:
        begin
          Visible := not Visible;
          Application.ShowMainForm := Visible;
          SetForegroundWindow(Application.Handle);
        end;
        WM_RBUTTONDOWN:
        begin
          GetCursorPos(pPos);
          PopupMenu1.Popup(pPos.x,pPos.y);
        end;
      end;end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      Inherited;
      Self.Visible := False;
      Application.ShowMainForm := Visible;
      { 创建Tray }
      with MyTrayIcon do
      begin
        cbSize := SizeOf(TNotifyIconData);   { 记录TNotifyIconDataA的大小 }
        Wnd := Self.Handle;          { 接收Tray小图标区鼠标事件的窗口的句柄 }
        uID := 1;          { 图标的ID(Tray小图标区鼠标事件的wPara参数的值)}
        uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;  { 此条消息的有效范围(低三位有效)
              NIF_MESSAGE 0x1: uCallbackMessage参数有效
              NIF_ICON 0x2:    hIcon is valid参数有效
              NIF_TIP 0x4:     szTip is valid参数有效 }
        uCallbackMessage := WM_MYTRAYICONCALLBACK; { 系统回送消息的ID }
        hIcon := Application.Icon.Handle;          { 显示在Tray小图标区上的图标的句柄 }
        szTip := '托盘';          { 鼠标移动到图标上时系统显示的提示信息 }
      end;
      Shell_NotifyIcon(NIM_ADD,@MyTrayIcon);end;end.
      

  7.   

    http://www.tomore.com/2/2083.html 下载地址 
    这地址下不到啦 
    谁提供下 网上找了N久 都不能下了 我是D7的 谁能发给我
    [email protected]
      

  8.   

    TrayIcon好像没有D7的版本,前一阵我也找了好久,没找到。