如:让qq弹出啦

解决方案 »

  1.   

    NOTIFYICONDATA m_tnid;
    m_tnid.cbSize=sizeof(NOTIFYICONDATA);
    m_tnid.hWnd=this->m_hWnd;
    m_tnid.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP;
    m_tnid.uCallbackMessage=MYWM_NOTIFYICON;  
    //用户定义的回调消息 m_tnid.uID=IDR_MAINFRAME;
    HICON hIcon;
    hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    m_tnid.hIcon=hIcon;
    ::Shell_NotifyIcon(NIM_ADD,&m_tnid);
      

  2.   

    给个教程你:
    http://www.vckbase.com/document/viewdoc.asp?id=492
    http://www.vckbase.com/document/viewdoc.asp?id=495
    http://www.vckbase.com/document/viewdoc.asp?id=498
      

  3.   

    同 zhaowenlong(文龙) 所说的,如你要让程序的主窗口弹出,请处理 m_tnid.uCallbackMessage=MYWM_NOTIFYICON;的 MYWM_NOTIFYICON消息,lpara里是 if(message==MYWM_NOTIFYICON)
    {
    //AfxMessageBox("OK");
     if (LOWORD(lParam) == WM_LBUTTONDBLCLK) //双击时。
     {//这里是我的对话框程序
     ::ShowWindow(AfxGetApp()->GetMainWnd()->m_hWnd,SW_SHOW);
        
     }
    }
      

  4.   

    刚好前两天我也做了个托盘的应用,共享之:
    在做托盘时用zhaowenlong(文龙)那种方法,在左击图标时弹出原始窗口,右击图标弹出浮动菜单。
    在view中增加消息处理函数如下:
    LRESULT CxxView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
    {
        // TODO: Add your specialized code here and/or call the base class
        switch (message)
        {
        case MYWM_NOTIFYICON:
            if (lParam == WM_LBUTTONDOWN)
            {
                ((CFrameWnd*)AfxGetMainWnd())->ShowWindow(SW_SHOW);
                ((CFrameWnd*)AfxGetMainWnd())->ShowWindow(SW_RESTORE);
            }
            else if (lParam == WM_RBUTTONDOWN)
            {
                AfxGetMainWnd()->SetForegroundWindow(); //弹出Popup菜单
                CMenu menu;
                menu.LoadMenu(IDR_MAINFRAME);
                CMenu* pPopup=menu.GetSubMenu(0);
                CPoint Point;
                GetCursorPos(&Point);
                pPopup->TrackPopupMenu(TPM_LEFTALIGN,Point.x,Point.y,AfxGetMainWnd(),NULL );
                AfxGetMainWnd()->PostMessage(WM_NULL, 0, 0); 
            }
            break;
        default:
            
            break;
        } return CFormView::WindowProc(message, wParam, lParam);
    }
      

  5.   

    看看人家带菜单的
    回调函数
    LRESULT CTrayNotifyIcon::OnTrayNotification(WPARAM wID, LPARAM lEvent)
    {
      //Return quickly if its not for this tray icon
      if (wID != m_NotifyIconData.uID)
        return 0L;  //As a default action use a menu resource with the same id 
      //as this was created with
      CMenu menu;
      if (!menu.LoadMenu(m_NotifyIconData.uID))
        return 0;  CMenu* pSubMenu = menu.GetSubMenu(0);
      if (!pSubMenu) 
        return 0;  if (lEvent == WM_RBUTTONUP)
      {
        //Clicking with right button brings up a context menu    // Make first menu item the default (bold font)
        ::SetMenuDefaultItem(pSubMenu->m_hMenu, 0, TRUE);    //Display and track the popup menu
        CPoint pos;
        GetCursorPos(&pos);
        ::SetForegroundWindow(m_NotifyIconData.hWnd);  
        ::TrackPopupMenu(pSubMenu->m_hMenu, 0, pos.x, pos.y, 0, m_NotifyIconData.hWnd, NULL);  } 
      else if (lEvent == WM_LBUTTONDBLCLK) 
      {
        // double click received, the default action is to execute first menu item
        ::SendMessage(m_NotifyIconData.hWnd, WM_COMMAND, pSubMenu->GetMenuItemID(0), 0);
      }  return 1; // handled
    }
      

  6.   

    我想问一下,当鼠标滑出系统托盘的时候,怎样得到鼠标不在系统托盘上的消息(WM_MOUSEMOVE)。