如题。

解决方案 »

  1.   

    procedure TfmTaskSearcher.FormCreate(Sender: TObject);
    var
      nid: TNotifyIconData;
    begin
      nid.cbSize := sizeof(nid);
      nid.Wnd := Handle;
      nid.uID := 0;
      nid.hIcon := Application.Icon.Handle;
      StrPCopy(nid.szTip, pProgamVersion);
      nid.uCallbackMessage := WM_ICONMESSAGE;
      nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
      if not Shell_NotifyIcon(NIM_ADD, @nid) then
      begin
        ShowMessage('System Error!');
        Application.Terminate;
      end;
    //  SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
      Caption := pProgamVersion;
      PageControl1.ActivePageIndex := 0;
      IniFileName := ExtractFileDir(ParamStr(0)) + '\Config.INI';
      CommonFileName := ExtractFileDir(ParamStr(0)) + '\CommonFiles.TXT';
      ReadIniFile;
      ReadTxtFile;
    end;procedure TfmTaskSearcher.FormClose(Sender: TObject; var Action: TCloseAction);
    var
      nid: TNotifyIconData;
    begin
      nid.cbSize := SizeOf(nid);
      nid.uID := 0;
      nid.Wnd := Handle;
      Shell_NotifyIcon(NIM_DELETE, @nid);
    end;
      

  2.   

    请问以下几段代码是什么意思啊?
    1: nid.uCallbackMessage := WM_ICONMESSAGE;  
    2: SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
    3: ReadIniFile;
    4: ReadTxtFile是不是还要调用其它的单元才能运行?
      

  3.   

    俺来说说要点吧。
    1、需要使用shellapi单元2、要填一个结构
    TnotifyIconData = record
    cbsize:Dword;{结构长度}
    Wnd:HWND;{调用者的窗口Handle}
    uID:UINT;{用户自定义参数}
    uFlags:UINT;{指定哪些字段是有效的:NIF_MESSAGE(callback字段) NIF_ICON(icon字段) NIF_TIP(tip字段)
    uCallbackMessage:UINT;{发回给程序的消息值}
    hIcon:HICON;{托盘里显示的图标的Handle}
    szTip:array[0..63] fo AnsiChar;{图标提示}
    end;
    在程序要定义一个TNotifyIconData类型的变量,然后把里面的字段都填好。3、调用Shell_NotifyIcon(dwMessage:DWORD;lpData:PNotifyIconData)函数
    dwMessage可以为:
    NIM_ADD 增加一个图标
    NIM_MODIFY 修改一个图标
    NIM_DELETE 删除一个图标4、如果需要可以定义一个函数响应一下托盘里发生的事件再看看上面的例子很容易理解。
      

  4.   

    ...
      private
        IniFileName: String;
        CommonFileName: String;
        iCount: Integer;    function IsValidDir(SearchRec: TSearchRec): Boolean;
        procedure SearchTask(const sDir, sExtension: String);
        procedure ViewFinished(const sDir, sExtension: String);
        procedure SetTimerInterval;
        procedure ReadIniFile;
        procedure WriteIniFile;
        procedure ReadTxtFile;
        procedure WriteTxtFile;
        procedure AutoStartWhenOsStart(const IsAutoStart: Boolean);
        procedure OnIconNotify(var Msg: TMessage); message WM_ICONMESSAGE;
        procedure OnSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
      public
        { Public declarations }
      end;implementation...procedure TfmTaskSearcher.OnIconNotify(var Msg: TMessage);
    var
      CurPos: TPoint;
    begin
      if Msg.LParam = WM_LBUTTONDBLCLK then
        Show
      else if Msg.LParam = WM_RBUTTONUP then
      begin
        GetCursorPos(CurPos);
        SysPopMenu.Popup(CurPos.X, CurPos.Y);
      end
      else
        inherited;
    end;procedure TfmTaskSearcher.OnSysCommand(var Msg: TWMSysCommand);
    begin
      if (Msg.CmdType = SC_CLOSE) or (Msg.CmdType = SC_MINIMIZE) then
        Hide
      else
        inherited;
    end;...
      

  5.   

    NIF_ICON or NIF_TIP or NIF_MESSAGE
    这几个在哪定义的啊?