请教托盘程序的实现和MSN提示的实现

解决方案 »

  1.   

    托盘可以下一个控件,方便啊,如TrayIcon,MSN提示可就不知道了,不过我拿分先
      

  2.   

    procedure TFScanner.FormCreate(Sender: TObject);
    var
      Nid: TNotifyIconData;
    begin
      MyThread := TScanThread.Create(False);
      Nid.cbSize := sizeof(Nid);
      Nid.Wnd := Self.Handle;
      Nid.uID := 0;
      Nid.hIcon := Application.Icon.Handle;
      Nid.szTip := 'LigSms监测程序';
      Nid.uCallbackMessage := MY_MESSAGE;
      Nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
      if not Shell_NotifyIcon(NIM_ADD,@Nid) then
      begin
        MessageBox(handle,'程序初始化失败,请重新启动','程序错误',MB_OK or MB_ICONERROR);
        Exit;
      end;
    end.
    老早做的程序了
      

  3.   

    这两个程序示例我都有,呵呵,你找对人了,给我发消息,将Email发给我,我给你发过来
      

  4.   

    const
        WM_TrayMessage=WM_User+100;
    ..............
    procedure AppMinimized(Sender: TObject);
    procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage;
    private
    .........
    var 
     NID:TNotifyIconData;
    ...........
    procedure TForm1.WMTrayMessage(var msg:TMessage);
    var
      p:TPoint;
    begin
      if msg.LParam=WM_LButtonDown then
      begin
        ShowWindow(Application.Handle,SW_Show);
        Application.Restore;
      end
      else if msg.LParam=WM_RButtonDown then
      begin
        GetCursorPos(p); 
    pmTray.Popup(p.x,p.y);  
      end;
    end;procedure TForm1.AppMinimized(Sender:TObject);
    begin
      NID.cbSize:=SizeOf(TNotifyIconData);
      NID.hIcon:=Application.Icon.Handle;
      NID.szTip:= 'test';
      NID.uCallbackMessage:=WM_TrayMessage;
      NID.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
      NID.uID:=0;
      NID.Wnd:=Handle;
      Shell_NotifyIcon(NIM_ADD,@NID);
      ShowWindow(Application.Handle,SW_Hide);
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
              Application.OnMinimize:=AppMinimized;
            AppMinimized(nil);
            Application.Title := 'test';
             Application.OnMinimize:=AppMinimized;
             AppMinimized(nil);
             form1.WindowState:=wsMinimized;  
    end;
      

  5.   

    const
        WM_TrayMessage=WM_User+100;
    ..............
    procedure AppMinimized(Sender: TObject);
    procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage;
    private
    .........
    var 
     NID:TNotifyIconData;
    ...........
    procedure TForm1.WMTrayMessage(var msg:TMessage);
    var
      p:TPoint;
    begin
      if msg.LParam=WM_LButtonDown then
      begin
        ShowWindow(Application.Handle,SW_Show);
        Application.Restore;
      end
      else if msg.LParam=WM_RButtonDown then
      begin
        GetCursorPos(p); 
    pmTray.Popup(p.x,p.y);  
      end;
    end;procedure TForm1.AppMinimized(Sender:TObject);
    begin
      NID.cbSize:=SizeOf(TNotifyIconData);
      NID.hIcon:=Application.Icon.Handle;
      NID.szTip:= 'test';
      NID.uCallbackMessage:=WM_TrayMessage;
      NID.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
      NID.uID:=0;
      NID.Wnd:=Handle;
      Shell_NotifyIcon(NIM_ADD,@NID);
      ShowWindow(Application.Handle,SW_Hide);
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
              Application.OnMinimize:=AppMinimized;
            AppMinimized(nil);
            Application.Title := 'test';
             Application.OnMinimize:=AppMinimized;
             AppMinimized(nil);
             form1.WindowState:=wsMinimized;  
    end;
      

  6.   

    const
        WM_TrayMessage=WM_User+100;
    ..............
    procedure AppMinimized(Sender: TObject);
    procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage;
    private
    .........
    var 
     NID:TNotifyIconData;
    ...........
    procedure TForm1.WMTrayMessage(var msg:TMessage);
    var
      p:TPoint;
    begin
      if msg.LParam=WM_LButtonDown then
      begin
        ShowWindow(Application.Handle,SW_Show);
        Application.Restore;
      end
      else if msg.LParam=WM_RButtonDown then
      begin
        GetCursorPos(p); 
    pmTray.Popup(p.x,p.y);  
      end;
    end;procedure TForm1.AppMinimized(Sender:TObject);
    begin
      NID.cbSize:=SizeOf(TNotifyIconData);
      NID.hIcon:=Application.Icon.Handle;
      NID.szTip:= 'test';
      NID.uCallbackMessage:=WM_TrayMessage;
      NID.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
      NID.uID:=0;
      NID.Wnd:=Handle;
      Shell_NotifyIcon(NIM_ADD,@NID);
      ShowWindow(Application.Handle,SW_Hide);
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
              Application.OnMinimize:=AppMinimized;
            AppMinimized(nil);
            Application.Title := 'test';
             Application.OnMinimize:=AppMinimized;
             AppMinimized(nil);
             form1.WindowState:=wsMinimized;  
    end;