最小化后,不在任务栏上,像QQ一样,怎么实现,大家一起聊!

解决方案 »

  1.   

    WINSHELLAPI BOOL WINAPI Shell_NotifyIcon(
        DWORD dwMessage, 
        PNOTIFYICONDATA pnid
    );typedef struct _NOTIFYICONDATA { 
        DWORD cbSize; 
        HWND hWnd; 
        UINT uID; 
        UINT uFlags; 
        UINT uCallbackMessage; 
        HICON hIcon; 
        char szTip[64]; 
    } NOTIFYICONDATA, *PNOTIFYICONDATA; 
     Contains information that the system needs to process taskbar status area messages. cbSize 
    Size of this structure, in bytes. 
    hWnd 
    Handle to the window that will receive notification messages associated with an icon in the taskbar status area. 
    uID 
    Application-defined identifier of the taskbar icon. 
    uFlags 
    Array of flags that indicate which of the other members contain valid data. This member can be a combination of the following: NIF_ICON  The hIcon member is valid.  
    NIF_MESSAGE  The uCallbackMessage member is valid. 
    NIF_TIP  The szTip member is valid. uCallbackMessage 
    Application-defined message identifier. The system uses this identifier for notification messages that it sends to the window identified in hWnd. These notifications are sent when a mouse event occurs in the bounding rectangle of the icon. 
    hIcon 
    Handle to the icon to add, modify, or delete. 
    szTip 
    Tooltip text to display for the icon. 
      

  2.   

    WINSHELLAPI BOOL WINAPI Shell_NotifyIcon(
        DWORD dwMessage, 
        PNOTIFYICONDATA pnid
    ); Sends a message to the system to add, modify, or delete an icon from the taskbar status area. Returns nonzero if successful, or zero otherwise. 
    dwMessage 
    Message value to send. This parameter can be one of these values: NIM_ADD  Adds an icon to the status area. 
    NIM_DELETE  Deletes an icon from the status area. 
    NIM_MODIFY  Modifies an icon in the status area.  pnid 
    Address of a NOTIFYICONDATA structure. The content of the structure depends on the value of dwMessage. 
      

  3.   

    CSystemTray(CWnd* pwnd,UNIT uCallbackMessage,LPCTSTR szTip,HICON icon, UINT uID)Create(CWnd* pParent,UNIT uCallbackMessage,LPCTSTR szTip,HICON icon,UINT uID)
      

  4.   

    思路,
    第一点,你要实现NotifyIcon.
    第二点,你要实现删除在TASKBAR上删除.http://www.codediy.com/codebbs/index.asp
      

  5.   

    1LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if(message==WM_USER )
    {
    if(lParam==WM_RBUTTONDOWN)
    {
    CMenu menu,*pSubMenu;
    menu.LoadMenu(IDR_MENU1);
    pSubMenu=menu.GetSubMenu(m_idIcon);
    POINT pt;
    GetCursorPos(&pt);
    pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,pt.x,pt.y,this);
    }
    }
    return CFrameWnd::WindowProc(message, wParam, lParam);
    }2 m_nid.cbSize=sizeof(NOTIFYICONDATA);
    m_nid.hWnd=m_hWnd;
    m_nid.uID=0;
    m_nid.uCallbackMessage=WM_USER;
    m_nid.hIcon=AfxGetApp()->LoadIcon(IDI_ICON1);
    ::lstrcpy(m_nid.szTip,"Hello");
    m_nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
    //以上为初始化结构
    m_idIcon=0;
    ::Shell_NotifyIcon(NIM_ADD,&m_nid); //加图标,并在析构函数中删除
    ::DestroyIcon(m_nid.hIcon);
      

  6.   

    把代码拷进去。1拦windowproc
    2 Create中
      

  7.   

    可以在系统托盘中添加图标
    具体步骤见《Visual C++ MFC扩展编程实例》P79  实例5,可惜我的光盘丢了
      

  8.   

    都说得差不多了, 虽然我想说, 呵呵, up下先, :)1、要声明通告图标结构 NOTIFYICONDATA m_nid;
    2、删除添加图标 Shell_NotifyIcon(NIM_DELETE,&m_nid);
    3、要调用函数以收到托盘通告 SetNotification(CWnd* pNotifyWnd,UINT uCbMsg);
    4、处理消息 LRESULT OnTrayNotification(WPARAM uid, LPARAM lEvent);
    在此函数中处理mouse右键点击后弹出菜单(调用::TrackPopupMemu(youmenu.m_hyoumenu,0,mouse.x,mouse.y,0,m_hWnd,NULL);
      

  9.   

    在OnCreate();中加入:
    SetWindowLong(m_hWnd,GWL_EXSTYLE,WS_EX_TOOLWINDOW);呵呵
      

  10.   

    对了,还要做一个菜单 IDM_SHOW
    void CMainFrame::OnShow() 
    {
    // TODO: Add your command handler code here
    ShowWindow(SW_SHOW);

    }
    void CMainFrame::OnHide() 
    {
    // TODO: Add your command handler code here
    ShowWindow(SW_HIDE);

    }void CMainFrame::OnTimer(UINT nIDEvent) 
    {
    // TODO: Add your message handler code here and/or call default
    if(m_idIcon==0)
    {
    m_nid.hIcon=AfxGetApp()->LoadIcon(IDI_ICON2);
    m_idIcon=1;
    }
    else 
    {
    m_nid.hIcon=::LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON1));
    m_idIcon=0;
    }
    ::Shell_NotifyIcon(NIM_MODIFY,&m_nid);
    ::DestroyIcon(m_nid.hIcon);


    CFrameWnd::OnTimer(nIDEvent);
    }
    CREATE 中  SetTimer(0,2000,NULL);
      

  11.   

    QQ中有两种不在任务栏的窗体:一是QQ用户登录窗体,另一是QQ主界面,也就是QQ程序中的顶级窗体(它没有父窗体也没有所有者)。Windows下实现不在任务栏的窗体也不外乎这两种方式,就连M$的C#中的实现方法也是采用第一种方式(它是事先创建了一个隐藏窗体,然后把程序的主窗体的所有者设为这个隐藏窗体,不过QQ用户登录窗体用拥有一个不可见的父窗体罢了,这个父窗体是QQ主界面窗体的子窗体),这种方式创建出的窗体最小化时岀现在屏幕左下角,就好像MDI程序当中的MDI子窗体最小化时出现在父窗体的左下角。而QQ主界面窗体最小化时不会出现在屏幕左下角,它是通过设置窗体的一个扩展属性(WS_EX_TOOLWINDOW )实现的,有的应用程序当中有浮动工具条,它就具有这个扩展属性,但通过这种方式创建出的窗体会与普通窗体有不一样的标题条:标题条窄、标题用小字体来显示、右上角只能有关闭按钮、还没有窗体图标,不过它不会出现在Alt+Tab的窗体列表中。
      对于QQ在任务栏托盘区的图标和菜单,可参阅nustchenhf() 的帖子。
      

  12.   

    本贴给分了!shb80的回答令得我心服口服