RT
最近做一小程序,功能界面都差不多了,但是想实现在最小化时变成类似QQ或MSN在右下角的图标托盘,并支持右键弹出菜单
请问应该如何实现?给个提示或文章链接
3X

解决方案 »

  1.   

    网上例子很多,解释也很详细,我就不说了http://www.vckbase.com/document/viewdoc/?id=677
    http://www.yesky.com/190/1878190.shtml
      

  2.   

    还有个问题 如何将整个desktop锁定? 就是类似网吧管理软件的那种 而等待一定的时间后才能自动解缩
      

  3.   

    #pragma onceclass CTrayIcon
    {
    public:
    CTrayIcon();
    ~CTrayIcon();
    // Set notify message window
    BOOL SetNotifyWnd(CWnd* pNotifyWnd, UINT nMsg);
    BOOL SetIcon(HICON hIcon); // Set tray icon
    BOOL SetIcon(UINT nID); // Set tray icon by resource
    HICON GetIcon() const; // Get tray icon handle BOOL SetToolTip(const CString& strTip); // Set tooltip text
    BOOL SetToolTip(UINT nID); // Set tooltip text by resource
    CString GetToolTip() const; // Get tooltip text

    #if (_WIN32_IE >= 0x0500)
    BOOL ShowBalloonTip(const CString& strTitle, const CString& strMsg, UINT nTimeout=3000);
    BOOL GetBalloonTip(CString& strTitle, CString& strMsg, UINT nTimeout) const;
    #endif
    BOOL ShowTray(BOOL bShow);
    private:
    NOTIFYICONDATA m_nid;
    };/**********************************************************************
     * File Name: TrayIcon.cpp
     * Module Name: CTrayIcon
     * Copyright (C) by LQ messager
     * Description: System taskbar tray icon control
     * Author: LiJun
     * Create Data: 2005-11-18  Update Data: 2006-07-18
     * E-Mail: mailto:[email protected]
     *
     *********************************************************************/
    #include "StdAfx.h"
    #include "trayicon.h"CTrayIcon::CTrayIcon()
    {
    memset(&m_nid, 0, sizeof(NOTIFYICONDATA));
    m_nid.cbSize = sizeof(NOTIFYICONDATA);
    }CTrayIcon::~CTrayIcon()
    {
    ShowTray(FALSE);
    }BOOL CTrayIcon::SetNotifyWnd(CWnd* pNotifyWnd, UINT nMsg)
    {
    ASSERT(pNotifyWnd != NULL);
    ASSERT(::IsWindow(pNotifyWnd->m_hWnd)); m_nid.hWnd = pNotifyWnd->m_hWnd;
    if(nMsg > 0)
    {
    m_nid.uCallbackMessage = nMsg;
    if(!(m_nid.uFlags & NIF_MESSAGE))
    m_nid.uFlags |= NIF_MESSAGE;
    }
    else
    {
    m_nid.uCallbackMessage = 0;
    if(m_nid.uFlags & NIF_MESSAGE)
    m_nid.uFlags &= ~NIF_MESSAGE;
    }
    return TRUE;
    }BOOL CTrayIcon::SetIcon(HICON hIcon)
    {
    ASSERT(hIcon != NULL); if(!(m_nid.uFlags & NIF_ICON))
    m_nid.uFlags |= NIF_ICON; m_nid.hIcon = hIcon;

    return Shell_NotifyIcon(NIM_MODIFY, &m_nid);
    }BOOL CTrayIcon::SetIcon(UINT nID)
    {
    return SetIcon(AfxGetApp()->LoadIcon(nID));
    }HICON CTrayIcon::GetIcon() const
    {
    return m_nid.hIcon;
    }BOOL CTrayIcon::SetToolTip(const CString& strTip)
    {
    if(!(m_nid.uFlags & NIF_TIP))
    m_nid.uFlags |= NIF_TIP;
    lstrcpy(m_nid.szTip, strTip); return Shell_NotifyIcon(NIM_MODIFY,&m_nid);
    }BOOL CTrayIcon::SetToolTip(UINT nID)
    {
    TCHAR szText[128];
    ::LoadString(AfxGetInstanceHandle(), nID, szText, 128);
    return SetToolTip(szText);
    }CString CTrayIcon::GetToolTip() const
    {
    return m_nid.szTip;
    }#if (_WIN32_IE >= 0x0500)
    BOOL CTrayIcon::ShowBalloonTip(const CString& strTitle, const CString& strMsg, UINT nTimeout)
    {
    if(!(m_nid.uFlags & NIF_INFO))
    m_nid.uFlags |= NIF_INFO;
    m_nid.uTimeout = nTimeout;
    lstrcpy(m_nid.szInfoTitle, strTitle);
    lstrcpy(m_nid.szInfo, strMsg); return Shell_NotifyIcon(NIM_MODIFY, &m_nid);
    }BOOL CTrayIcon::GetBalloonTip(CString& strTitle, CString& strMsg, UINT nTimeout) const
    {
    strTitle = m_nid.szInfoTitle;
    strMsg  = m_nid.szInfo;
    nTimeout = m_nid.uTimeout;
    return TRUE;
    }
    #endifBOOL CTrayIcon::ShowTray(BOOL bShow)
    {
    return Shell_NotifyIcon( bShow ? NIM_ADD : NIM_DELETE, &m_nid );
    }
      

  4.   

    显示桌面
    ::SetWindowPos(::FindWindow(NULL, "Program Manager"),  NULL,0, 0, 0, 0,                         SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);隐藏桌面
    ::SetWindowPos(::FindWindow(NULL, "Program Manager"), NULL, 0, 0, 0, 0,  SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
      

  5.   

    void Lock(BOOL bFALG)
    {
    //锁住屏幕,系统不能支持鼠标和键盘事件
    if (bFALG)
    {
    SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, NULL,0);
    EnableWindow(GetDesktopWindow(),FALSE);
    }
    //屏幕解锁
    else
    {
    SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, NULL,0);
    EnableWindow(GetDesktopWindow(),TRUE);
    }
    }
    这个是锁住屏幕和解锁~~~
    主要是在2000和98系统~~~
    在远程控制里面见的比较多~~~
      

  6.   

    好像还有个函数以前听说可以~~~
    LockWindowUpdate
    具体的你自己参考一下MSDN~~~
      

  7.   

    哈哈,思危没去过网吧啊关于托盘的就不多说了,网上多D是,to 思危:
    Program Manager就是桌面的title?
      

  8.   

    呵呵,如果你们用过Win3.1(估计现在的人也没几个用过的),里面有个叫Program Manager的程序,相当于现在资源管理器,是Win3.1的Shell。
    虽然后来Win3.1被淘汰了,不过微软把这个名字继承了下了,用作现在Shell的名字,也就是我们说的桌面。而桌面真正的程序名是 progman.exe,有兴趣可以查找来看一下 。 :)
      

  9.   

    windows 3.2中文版,用过2分钟